mirror of
https://github.com/Wind4/vlmcsd.git
synced 2024-11-05 17:46:14 +01:00
81 lines
1.4 KiB
Bash
81 lines
1.4 KiB
Bash
#!/bin/sh
|
|
#
|
|
# VLMCSD - this script starts and stops the KMS Server daemon
|
|
#
|
|
### BEGIN SERVICE INFO
|
|
# Run level information:
|
|
# chkconfig: 2345 99 99
|
|
# description: KMS Emulator in C
|
|
# processname: vlmcsd
|
|
### END SERVICE INFO
|
|
|
|
# Source function library
|
|
source /etc/init.d/functions
|
|
|
|
# Check that networking is up.
|
|
[ ${NETWORKING} ="yes" ] || exit 0
|
|
|
|
NAME=vlmcsd
|
|
SCRIPT=/usr/bin/vlmcsd
|
|
RUNAS=
|
|
|
|
PIDFILE=/var/run/$NAME.pid
|
|
LOGFILE=/var/log/$NAME.log
|
|
|
|
start() {
|
|
if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE"); then
|
|
echo 'Service already running.'
|
|
return 1
|
|
fi
|
|
echo 'Starting service...'
|
|
local CMD="$SCRIPT -p $PIDFILE -l $LOGFILE"
|
|
su -c "$CMD" $RUNAS
|
|
echo 'Service started.'
|
|
}
|
|
|
|
stop() {
|
|
if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
|
|
echo 'Service not running.'
|
|
return 1
|
|
fi
|
|
echo 'Stopping service...'
|
|
kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
|
|
echo 'Service stopped.'
|
|
}
|
|
|
|
status() {
|
|
echo "Checking $NAME service..."
|
|
if [ -f "$PIDFILE" ]; then
|
|
local PID=$(cat "$PIDFILE")
|
|
kill -0 $PID
|
|
if [ $? -eq 0 ]; then
|
|
echo "Running, the PID is $PID."
|
|
else
|
|
echo 'The process appears to be dead but pidfile still exists.'
|
|
fi
|
|
else
|
|
echo 'Service not running.'
|
|
fi
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
start
|
|
;;
|
|
stop)
|
|
stop
|
|
;;
|
|
status)
|
|
status
|
|
;;
|
|
restart)
|
|
stop
|
|
start
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|status|restart}"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
exit 0 |