mirror of
https://github.com/eliasstepanik/ark-ac-server-tools.git
synced 2026-01-13 11:28:26 +00:00
update init script, add check status, lsb fonction
This commit is contained in:
parent
f5a1092487
commit
75fd8d1ea1
@ -5,10 +5,13 @@
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: ARK manager deamon
|
||||
# Description: Automaticaly start ARK server
|
||||
# Description: ARK manager daemon used to start the server and keep it updated
|
||||
#
|
||||
### END INIT INFO
|
||||
|
||||
# Using the lsb functions to perform the operations.
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
# Global variables
|
||||
source /etc/arkdaemon.cfg
|
||||
source /home/${steamuser}/.arkmanager.cfg
|
||||
@ -17,33 +20,45 @@ NAME=arkmanager_daemon
|
||||
DESC="ARK manager daemon used to start the server and keep it updated"
|
||||
PIDFILE="/var/run/${NAME}.pid"
|
||||
LOGFILE="${logdir}/${NAME}.log"
|
||||
|
||||
|
||||
DAEMON="sh /usr/bin/arkmanager update"
|
||||
|
||||
DAEMON="arkmanager"
|
||||
START_OPTS="--pidfile ${PIDFILE} --user=${steamuser} ${DAEMON}"
|
||||
|
||||
set -e
|
||||
|
||||
# If the daemon is not there, then exit.
|
||||
test -x $DAEMON || exit 5
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting ${DESC}: "
|
||||
daemon $START_OPTS >> $LOGFILE
|
||||
echo "$NAME."
|
||||
log_daemon_msg "Starting" "$NAME"
|
||||
if start-stop-daemon -b --start --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON ; then
|
||||
log_end_msg 0
|
||||
else
|
||||
log_end_msg 1
|
||||
fi
|
||||
;;
|
||||
|
||||
stop)
|
||||
echo -n "Stopping $DESC: "
|
||||
log_daemon_msg "Stopping" "$NAME"
|
||||
kill ${cat $PIDFILE}
|
||||
echo "$NAME."
|
||||
rm -f $PIDFILE
|
||||
;;
|
||||
|
||||
restart|force-reload)
|
||||
echo -n "Restarting $DESC: "
|
||||
kill $(cat $PIDFILE)
|
||||
sleep 1
|
||||
daemon $START_OPTS >> $LOGFILE
|
||||
echo "$NAME."
|
||||
$0 stop && sleep 2 && $0 start
|
||||
;;
|
||||
|
||||
status)
|
||||
# Check the status of the process.
|
||||
PID=`ps -ef | grep $DAEMON | grep -v grep | awk '{print $2}'`
|
||||
if [ -n "$PID" ]; then
|
||||
echo "$NAME is running on PID $PID"
|
||||
else
|
||||
echo "$NAME is not running"
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
N=/etc/init.d/$NAME
|
||||
echo "Usage: $N {start|stop|restart|force-reload}" >&2
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user