Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Making Init Script SysV compatible: http://fedoraproject.org/wiki/Pac…

  • Loading branch information...
commit 57d477bcde77efeb51e541e79c15ba66ad646709 1 parent 57a4e47
Jeffrey Ness jness authored
Showing with 110 additions and 52 deletions.
  1. +110 −52 webmin-init
162 webmin-init
View
@@ -1,71 +1,129 @@
#!/bin/sh
-# chkconfig: 235 99 10
+#
+# webmin A web-based administration interface for Unix systems.
+#
+# chkconfig: - 99 10
# description: Start or stop the Webmin server
#
+
### BEGIN INIT INFO
# Provides: webmin
# Required-Start: $network $syslog
# Required-Stop: $network
# Default-Start: 2 3 5
-# Default-Stop: 0 1 6
+# Default-Stop: 0 1 2 3 4 5 6
# Description: Start or stop the Webmin server
### END INIT INFO
+# Source function library.
+. /etc/rc.d/init.d/functions
+
start=/etc/webmin/start
stop=/etc/webmin/stop
-lockfile=/var/lock/subsys/webmin
confFile=/etc/webmin/miniserv.conf
pidFile=/var/webmin/miniserv.pid
-name='Webmin'
+prog='webmin'
+
+[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
+
+lockfile=/var/lock/subsys/webmin
+
+start() {
+ $start >/dev/null 2>&1 </dev/null
+ RETVAL=$?
+ if [ "$RETVAL" = "0" ]; then
+ touch $lockfile >/dev/null 2>&1
+ fi
+ return $RETVAL
+}
+
+stop() {
+ $stop
+ RETVAL=$?
+ if [ "$RETVAL" = "0" ]; then
+ rm -f $lockfile
+ fi
+ pidfile=`grep "^pidfile=" $confFile | sed -e 's/pidfile=//g'`
+ if [ "$pidfile" = "" ]; then
+ pidfile=$pidFile
+ fi
+ rm -f $pidfile
+ return $RETVAL
+}
+
+status() {
+ pidfile=`grep "^pidfile=" $confFile | sed -e 's/pidfile=//g'`
+ if [ "$pidfile" = "" ]; then
+ pidfile=$pidFile
+ fi
+ if [ -s $pidfile ]; then
+ pid=`cat $pidfile`
+ kill -0 $pid >/dev/null 2>&1
+ if [ "$?" = "0" ]; then
+ echo "$prog (pid $pid) is running"
+ RETVAL=0
+ else
+ echo "$prog is stopped"
+ RETVAL=1
+ fi
+ else
+ echo "$prog is stopped"
+ RETVAL=1
+ fi
+ return $RETVAL
+}
+
+restart() {
+ $stop ; $start
+ RETVAL=$?
+ return $RETVAL
+}
+
+reload() {
+ $stop ; $start
+ RETVAL=$?
+ return $RETVAL
+}
+
+
+rh_status() {
+ # run checks to determine if the service is running or use generic status
+ status $prog
+}
+
+rh_status_q() {
+ rh_status >/dev/null 2>&1
+}
+
case "$1" in
-'start')
- $start >/dev/null 2>&1 </dev/null
- RETVAL=$?
- if [ "$RETVAL" = "0" ]; then
- touch $lockfile >/dev/null 2>&1
- fi
- ;;
-'stop')
- $stop
- RETVAL=$?
- if [ "$RETVAL" = "0" ]; then
- rm -f $lockfile
- fi
- pidfile=`grep "^pidfile=" $confFile | sed -e 's/pidfile=//g'`
- if [ "$pidfile" = "" ]; then
- pidfile=$pidFile
- fi
- rm -f $pidfile
- ;;
-'status')
- pidfile=`grep "^pidfile=" $confFile | sed -e 's/pidfile=//g'`
- if [ "$pidfile" = "" ]; then
- pidfile=$pidFile
- fi
- if [ -s $pidfile ]; then
- pid=`cat $pidfile`
- kill -0 $pid >/dev/null 2>&1
- if [ "$?" = "0" ]; then
- echo "$name (pid $pid) is running"
- RETVAL=0
- else
- echo "$name is stopped"
- RETVAL=1
- fi
- else
- echo "$name is stopped"
- RETVAL=1
- fi
- ;;
-'restart')
- $stop ; $start
- RETVAL=$?
- ;;
-*)
- echo "Usage: $0 { start | stop | restart }"
- RETVAL=1
- ;;
+ start)
+ rh_status_q && exit 0
+ $1
+ ;;
+ stop)
+ rh_status_q || exit 0
+ $1
+ ;;
+ restart)
+ $1
+ ;;
+ reload)
+ rh_status_q || exit 7
+ $1
+ ;;
+ status)
+ rh_status
+ ;;
+ condrestart|try-restart)
+ rh_status_q || exit 0
+ restart
+ ;;
+ *)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload}"
+ exit 2
+
esac
-exit $RETVAL
+exit $?
+
Please sign in to comment.
Something went wrong with that request. Please try again.