diff --git a/tools/install.sh b/tools/install.sh index e955f91..4c972d9 100644 --- a/tools/install.sh +++ b/tools/install.sh @@ -18,6 +18,15 @@ if [ ! -z "$1" ]; then echo "Ark server will now start on boot, if you want to remove this feature run the following line" echo "update-rc.d -f arkmanager remove" fi + elif [ -f /etc/rc.d/init.d/functions ]; then + cp redhat/arkdaemon "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager" + chmod +x "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager" + sed -i "s@^DAEMON=\"/usr/bin@DAEMON=\"${EXECPREFIX}@" "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager" + if [ -x /sbin/chkconfig -a -z "${INSTALL_ROOT}" ]; then + chkconfig --add arkmanager + echo "Ark server will now start on boot, if you want to remove this feature run the following line" + echo "chkconfig arkmanager off" + fi fi # Create a folder in /var/log to let Ark tools write its own log files diff --git a/tools/redhat/arkdaemon b/tools/redhat/arkdaemon new file mode 100755 index 0000000..be4be54 --- /dev/null +++ b/tools/redhat/arkdaemon @@ -0,0 +1,84 @@ +#!/bin/bash +# +# /etc/rc.d/init.d/arkdaemon +# +# ARK manager daemon +# +# chkconfig: 2345 80 20 +# description: ARK manager daemon used to start the server and keep it updated +# processname: ShooterGameServer +# config: /etc/arkmanager/arkmanager.cfg + +### BEGIN INIT INFO +# Provides: ARK manager deamon +# Required-Start: networking +# Required-Stop: networking +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: ARK manager deamon +# Description: ARK manager daemon used to start the server and keep it updated +# +### END INIT INFO + +# Using the lsb functions to perform the operations. +. /etc/rc.d/init.d/functions + +# Global variables +source /etc/arkmanager/arkmanager.cfg + +NAME="ShooterGameServer" +LOGFILE="${logdir}/${NAME}.log" +DAEMON="/usr/bin/arkmanager" + +set -e + +# If the daemon is not there, then exit. +test -x $DAEMON || exit 5 + +case "$1" in + start) + echo -n "Starting $NAME: " + su -s /bin/sh -c "$DAEMON start" $steamcmd_user + sleep 5 + PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'` + if [ -n "$PID" ]; then + touch /var/lock/subsys/arkdaemon + echo "OK" + exit 0 + else + echo "Failed" + exit 1 + fi + ;; + + stop) + echo -n "Stopping $NAME: " + su -s /bin/sh -c "$DAEMON stop" $steamcmd_user + sleep 5 + PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'` + if [ -n "$PID" ]; then + echo "Failed" + exit 1 + else + echo "OK" + rm -f /var/lock/subsys/arkdaemon + exit 0 + fi + ;; + + restart) + su -s /bin/sh -c "$DAEMON restart" $steamcmd_user + exit 0 + ;; + + status) + su -s /bin/sh -c "$DAEMON status" $steamcmd_user + exit 0 + ;; + + *) + # For invalid arguments, print the usage message. + echo "Usage: $0 {start|stop|restart|status}" + exit 1 + ;; +esac