mirror of
https://github.com/eliasstepanik/ark-ac-server-tools.git
synced 2026-01-22 22:48:29 +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-Start: 2 3 4 5
|
||||||
# Default-Stop: 0 1 6
|
# Default-Stop: 0 1 6
|
||||||
# Short-Description: ARK manager deamon
|
# 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
|
### END INIT INFO
|
||||||
|
|
||||||
|
# Using the lsb functions to perform the operations.
|
||||||
|
. /lib/lsb/init-functions
|
||||||
|
|
||||||
# Global variables
|
# Global variables
|
||||||
source /etc/arkdaemon.cfg
|
source /etc/arkdaemon.cfg
|
||||||
source /home/${steamuser}/.arkmanager.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"
|
DESC="ARK manager daemon used to start the server and keep it updated"
|
||||||
PIDFILE="/var/run/${NAME}.pid"
|
PIDFILE="/var/run/${NAME}.pid"
|
||||||
LOGFILE="${logdir}/${NAME}.log"
|
LOGFILE="${logdir}/${NAME}.log"
|
||||||
|
DAEMON="arkmanager"
|
||||||
|
|
||||||
DAEMON="sh /usr/bin/arkmanager update"
|
|
||||||
|
|
||||||
START_OPTS="--pidfile ${PIDFILE} --user=${steamuser} ${DAEMON}"
|
START_OPTS="--pidfile ${PIDFILE} --user=${steamuser} ${DAEMON}"
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# If the daemon is not there, then exit.
|
||||||
|
test -x $DAEMON || exit 5
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
echo -n "Starting ${DESC}: "
|
log_daemon_msg "Starting" "$NAME"
|
||||||
daemon $START_OPTS >> $LOGFILE
|
if start-stop-daemon -b --start --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON ; then
|
||||||
echo "$NAME."
|
log_end_msg 0
|
||||||
|
else
|
||||||
|
log_end_msg 1
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
stop)
|
stop)
|
||||||
echo -n "Stopping $DESC: "
|
log_daemon_msg "Stopping" "$NAME"
|
||||||
kill ${cat $PIDFILE}
|
kill ${cat $PIDFILE}
|
||||||
echo "$NAME."
|
echo "$NAME."
|
||||||
rm -f $PIDFILE
|
rm -f $PIDFILE
|
||||||
;;
|
;;
|
||||||
|
|
||||||
restart|force-reload)
|
restart|force-reload)
|
||||||
echo -n "Restarting $DESC: "
|
$0 stop && sleep 2 && $0 start
|
||||||
kill $(cat $PIDFILE)
|
|
||||||
sleep 1
|
|
||||||
daemon $START_OPTS >> $LOGFILE
|
|
||||||
echo "$NAME."
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
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
|
N=/etc/init.d/$NAME
|
||||||
echo "Usage: $N {start|stop|restart|force-reload}" >&2
|
echo "Usage: $N {start|stop|restart|force-reload}" >&2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user