[shellinabox/el5] Fix for #893129

Simone Caronni slaanesh at fedoraproject.org
Wed Jan 9 10:54:47 UTC 2013


commit 1c82ff78a930e6023d323675ac15339aa72e0b51
Author: Simone Caronni <negativo17 at gmail.com>
Date:   Wed Jan 9 11:53:57 2013 +0100

    Fix for #893129

 shellinabox.spec  |    6 ++-
 shellinaboxd.init |  116 +++++++++++++++++++++++++++++++++--------------------
 2 files changed, 77 insertions(+), 45 deletions(-)
---
diff --git a/shellinabox.spec b/shellinabox.spec
index 46056a7..d9c8991 100644
--- a/shellinabox.spec
+++ b/shellinabox.spec
@@ -3,7 +3,7 @@
 
 Name:           shellinabox
 Version:        2.14
-Release:        17.%{commit}%{?dist}
+Release:        18.%{commit}%{?dist}
 Summary:        Web based AJAX terminal emulator
 Group:          System Environment/Daemons
 License:        GPLv2
@@ -169,6 +169,10 @@ fi
 
 
 %changelog
+* Wed Jan 09 2013 Simone Caronni <negativo17 at gmail.com> - 2.14-18.git88822c1f
+- Updated init script according to Fedora template (#893129)
+  https://fedoraproject.org/wiki/Packaging:SysVInitScript?rd=Packaging/SysVInitScript
+
 * Fri Dec 14 2012 Simone Caronni <negativo17 at gmail.com> - 2.14-17.git88822c1f
 - Fix the commit / dist tags order in the revision.
 
diff --git a/shellinaboxd.init b/shellinaboxd.init
index 98180c4..bc3b3f3 100644
--- a/shellinaboxd.init
+++ b/shellinaboxd.init
@@ -1,47 +1,69 @@
-#!/bin/bash
+#!/bin/sh
 #
-# shellinaboxd   This shell script takes care of starting and stopping
-#               shellinabox.
+# shellinaboxd Takes care of starting and stopping shellinabox.
 #
 # chkconfig: - 80 20
 # description: Publish command line shell through AJAX interface.
-# processname: shellinaboxd
+
+### BEGIN INIT INFO
+# Required-Start: $local_fs $network
+# Required-Stop: $local_fs $network
+# Default-Start: 3 4 5
+# Default-Stop: 0 1 2 6
+# Short-Description: Publish command line shell through AJAX interface.
+# Description: Shell In A Box implements a web server that can export arbitrary
+#              command line tools to a web based terminal emulator. This
+#              emulator is accessible to any JavaScript and CSS enabled web
+#              browser and does not require any additional browser plugins.
+### END INIT INFO
+
 # config: /etc/sysconfig/shellinaboxd
 # pidfile: /var/run/shellinaboxd.pid
 
 # Source function library.
 . /etc/rc.d/init.d/functions
 
-RETVAL=0
-WORKING_DIR=/usr/share/shellinabox
+exec="/usr/sbin/shellinaboxd"
 prog="shellinaboxd"
+WORKING_DIR=/usr/share/shellinabox
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
 
-# Source configuration.
-if [ -f /etc/sysconfig/$prog ] ; then
-        . /etc/sysconfig/$prog
-fi
+lockfile=/var/lock/subsys/$prog
 
 start() {
-        [ "$EUID" != "0" ] && exit 4
-
-        echo -n "Starting $prog: "
-        cd $WORKING_DIR
-        daemon $prog -u $USER -g $GROUP --cert=${CERTDIR} --port=${PORT} --background=/var/run/$prog.pid $OPTS
-        RETVAL=$?
-        echo
-        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
-        return $RETVAL
+    [ -x $exec ] || exit 5
+    [ -f $config ] || exit 6
+    echo -n $"Starting $prog: "
+    cd $WORKING_DIR
+    daemon $prog -u $USER -g $GROUP --cert=${CERTDIR} --port=${PORT} --background=/var/run/$prog.pid $OPTS
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && touch $lockfile
+    return $retval
 }
 
+
 stop() {
-        [ "$EUID" != "0" ] && exit 4
-
-        echo -n "Shutting down $prog: "
-        killproc $prog
-        RETVAL=$?
-        echo
-        [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
-        return $RETVAL
+    echo -n $"Stopping $prog: "
+    # stop it here, often "killproc $prog"
+    retval=$?
+    echo
+    [ $retval -eq 0 ] && rm -f $lockfile
+    return $retval
+}
+
+restart() {
+    stop
+    start
+}
+
+reload() {
+    restart
+}
+
+force_reload() {
+    restart
 }
 
 rh_status() {
@@ -53,29 +75,35 @@ rh_status_q() {
     rh_status >/dev/null 2>&1
 }
 
+
 case "$1" in
     start)
-                start
-                ;;
+        rh_status_q && exit 0
+        $1
+        ;;
     stop)
-                stop
-                ;;
+        rh_status_q || exit 0
+        $1
+        ;;
+    restart)
+        $1
+        ;;
+    reload)
+        rh_status_q || exit 7
+        $1
+        ;;
+    force-reload)
+        force_reload
+        ;;
     status)
-		rh_status
-		;;
+        rh_status
+        ;;
     condrestart|try-restart)
-		rh_status_q || exit 0
-		restart
-		;;
-    restart|force-reload)
-                stop
-                start
-                ;;
+        rh_status_q || exit 0
+        restart
+        ;;
     *)
-        echo "Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|status}"
-        [ "$1" = "usage" ] && exit 0
+        echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
         exit 2
-        ;;
 esac
 exit $?
-


More information about the scm-commits mailing list