File webmin-init of Package webmin

#!/bin/sh
#
# System startup script for webmin
#
### BEGIN INIT INFO
# Provides:       webmin
# Required-Start: $local_fs $remote_fs $syslog $network
# Required-Stop:  $local_fs $remote_fs $syslog $network
# Should-Start:   $time sendmail xntpd $named cron
# Should-Stop:    sendmail
# Default-Start:  3 5
# Default-Stop:   0 1 2 6
# Short-Description: Start or stop the Webmin server
# Description:    Starts and stops the Webmin server
#   used to configure your host via webinterface
### END INIT INFO

. /etc/rc.status

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'


test -x $start || { echo "$start not installed";
    if [ "$1" = "stop" ]; then exit 0;
    else exit 5; fi;
}
test -x $stop || { echo "$stop not installed";
    if [ "$1" = "stop" ]; then exit 0;  
    else exit 5; fi;
}
test -r $confFile || { echo "$confFile not existing";
    if [ "$1" = "stop" ]; then exit 0;
    else exit 5; fi;
}

# Reset status of this service
rc_reset

case "$1" in
    start)
        echo -n "Starting $name "
        startproc -p $pidFile $start >/dev/null 2>&1 </dev/null
        RETVAL=$?
    	if [ "$RETVAL" = "0" ]; then
	    	touch $lockfile >/dev/null 2>&1
    	fi
        rc_status -v
	    ;;
    stop)
        echo -n "Shutting down $name "
    	killproc -p $pidFile $stop
    	RETVAL=$?
	    if [ "$RETVAL" = "0" ]; then
		    rm -f $lockfile
    	fi
        rc_reset
        rc_status -v
	;;
    try-restart)
        ## Do a restart only if the service was active before.
        ## Note: try-restart is now part of LSB (as of 1.9).
        ## RH has a similar command named condrestart.
        $0 status
        if [ "$?" = "0" ]; then
            $0 restart
        else
            rc_reset        # Not running is not a failure.
        fi
        # Remember status and be quiet
        rc_status
    ;;
    status)
        echo -n "Checking for webmin "
    	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
                rc_reset
    		else
    			rc_failed
    		fi
    	else
            rc_failed
	    fi
        rc_status -v
	;;
    restart)
        $0 stop
        $0 start
        rc_status
	;;
    *)
	    echo "Usage: $0 {start|stop|status|try-restart|restart}"
        exit 1
	;;
esac
rc_exit
openSUSE Build Service is sponsored by