From e3d66e96ce86b2092efca58716b280b68dcf61c3 Mon Sep 17 00:00:00 2001 From: Sispheor Date: Sun, 21 Jun 2015 19:54:12 +0200 Subject: [PATCH] sysinit script done --- tools/arkdaemon | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) mode change 100644 => 100755 tools/arkdaemon diff --git a/tools/arkdaemon b/tools/arkdaemon old mode 100644 new mode 100755 index 5fb27d9..853c88e --- a/tools/arkdaemon +++ b/tools/arkdaemon @@ -9,21 +9,15 @@ # ### END INIT INFO -# NOTICE: this daemon can work only if your system supports start-stop-daemon - # Using the lsb functions to perform the operations. . /lib/lsb/init-functions # Global variables -source /etc/arkdaemon.cfg -source /home/${steamuser}/.arkmanager.cfg +source /etc/arkmanager/arkmanager.cfg -NAME=arkmanager_daemon -DESC="ARK manager daemon used to start the server and keep it updated" -PIDFILE="/var/run/${NAME}.pid" +NAME="ShooterGameServer" LOGFILE="${logdir}/${NAME}.log" -DAEMON="arkmanager" -START_OPTS="--pidfile ${PIDFILE} --user=${steamuser} ${DAEMON}" +DAEMON="/usr/bin/arkmanager" set -e @@ -33,7 +27,9 @@ test -x $DAEMON || exit 5 case "$1" in start) log_daemon_msg "Starting" "$NAME" - if start-stop-daemon -b --start --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON ; then + sudo -u $steamcmd_user $DAEMON start + PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'` + if [ -n "$PID" ]; then log_end_msg 0 else log_end_msg 1 @@ -42,28 +38,26 @@ case "$1" in stop) log_daemon_msg "Stopping" "$NAME" - kill ${cat $PIDFILE} - echo "$NAME." - rm -f $PIDFILE + sudo -u $steamcmd_user $DAEMON stop + PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'` + if [ -n "$PID" ]; then + log_end_msg 1 + else + log_end_msg 0 + fi ;; - restart|force-reload) - $0 stop && sleep 2 && $0 start + restart) + sudo -u $steamcmd_user $DAEMON restart ;; 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 + sudo -u $steamcmd_user $DAEMON status ;; *) # For invalid arguments, print the usage message. - echo "Usage: $0 {start|stop|restart|status|force-reload}" + echo "Usage: $0 {start|stop|restart|status}" exit 2 ;; esac