mirror of
https://github.com/eliasstepanik/ark-ac-server-tools.git
synced 2026-01-12 02:48:27 +00:00
Merge pull request #43 from klightspeed/dev#1.1
Dev#1.1 - add RedHat and OpenRC init scripts
This commit is contained in:
commit
0c280ca8f9
@ -7,14 +7,35 @@ if [ ! -z "$1" ]; then
|
||||
cp arkmanager "${INSTALL_ROOT}${EXECPREFIX}/bin/arkmanager"
|
||||
chmod +x "${INSTALL_ROOT}${EXECPREFIX}/bin/arkmanager"
|
||||
|
||||
# Copy arkdaemon to /etc/init.d/arkmanager ,set permissions and add it to boot
|
||||
cp arkdaemon "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
chmod +x "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
# add to startup if the system use sysinit
|
||||
if [ -x /usr/sbin/update-rc.d -a -z "${INSTALL_ROOT}" ]; then
|
||||
update-rc.d arkmanager defaults
|
||||
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"
|
||||
# Copy arkdaemon to /etc/init.d ,set permissions and add it to boot
|
||||
if [ -f /lib/lsb/init-functions ]; then
|
||||
cp lsb/arkdaemon "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
chmod +x "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
sed -i "s|^DAEMON=\"/usr|DAEMON=\"${EXECPREFIX}|" "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
# add to startup if the system use sysinit
|
||||
if [ -x /usr/sbin/update-rc.d -a -z "${INSTALL_ROOT}" ]; then
|
||||
update-rc.d arkmanager defaults
|
||||
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
|
||||
elif [ -f /sbin/runscript ]; then
|
||||
cp openrc/arkdaemon "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
chmod +x "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
sed -i "s@^DAEMON=\"/usr/bin@DAEMON=\"${EXECPREFIX}@" "${INSTALL_ROOT}/etc/init.d/arkmanager"
|
||||
if [ -x /sbin/rc-update -a -z "${INSTALL_ROOT}" ]; then
|
||||
rc-update add arkmanager default
|
||||
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
|
||||
echo "rc-update del arkmanager default"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create a folder in /var/log to let Ark tools write its own log files
|
||||
|
||||
38
tools/openrc/arkdaemon
Normal file
38
tools/openrc/arkdaemon
Normal file
@ -0,0 +1,38 @@
|
||||
#!/sbin/runscript
|
||||
# Short-Description: ARK manager deamon
|
||||
# Description: ARK manager daemon used to start the server and keep it updated
|
||||
|
||||
source /etc/arkmanager/arkmanager.cfg
|
||||
|
||||
NAME="ShooterGameServer"
|
||||
LOGFILE="${logdir}/${NAME}.log"
|
||||
DAEMON="/usr/bin/arkmanager"
|
||||
|
||||
depend(){
|
||||
require net
|
||||
}
|
||||
|
||||
start(){
|
||||
ebegin "Starting ARK manager daemon"
|
||||
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
|
||||
eend 0
|
||||
else
|
||||
eend 1
|
||||
fi
|
||||
}
|
||||
|
||||
stop(){
|
||||
ebegin "Stopping ARK manager daemon"
|
||||
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
|
||||
eend 0
|
||||
else
|
||||
eend 1
|
||||
fi
|
||||
}
|
||||
|
||||
84
tools/redhat/arkdaemon
Executable file
84
tools/redhat/arkdaemon
Executable file
@ -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
|
||||
Loading…
x
Reference in New Issue
Block a user