Merge pull request #80 from klightspeed/1.2-dev

1.2 dev
This commit is contained in:
Fez Vrasta 2015-06-28 17:31:21 +02:00
commit fac83bfb82
7 changed files with 65 additions and 50 deletions

View File

@ -47,8 +47,8 @@ ark_ServerPVE=False
ark_DifficultyOffset=1 ark_DifficultyOffset=1
``` ```
Your session name may contain special characters (eg. `!![EU]!! Aw&some ARK`) which could break the startup command. Your session name may not contain special characters (eg. `!![EU]!! Aw&some ARK`) as it could break the startup command.
In this case you may want to comment out the `ark_SessionName` variable and define it inside your **GameUserSettings.ini** file. In this case you may want to comment out the `ark_SessionName` variable and define it inside your **GameUserSettings.ini** file instead.
You can override or add variables for a specific system user creating a file called `.arkmanager.cfg` in the home directory of the system user. You can override or add variables for a specific system user creating a file called `.arkmanager.cfg` in the home directory of the system user.

View File

@ -30,7 +30,6 @@ info=""
thejob="" thejob=""
instver="" instver=""
bnumber="" bnumber=""
timestamp=$( date +%T )
GREEN="\\033[1;32m" GREEN="\\033[1;32m"
RED="\\033[1;31m" RED="\\033[1;31m"
YELLOW="\\e[0;33m" YELLOW="\\e[0;33m"
@ -44,6 +43,13 @@ arkserverLog="arkserver.log" # here is logged the output of ShooterGameServer
# functions # functions
#--------------------- #---------------------
#
# timestamp
#
timestamp() {
date +%T
}
# #
# check configuration and report errors # check configuration and report errors
# #
@ -100,14 +106,6 @@ function checkForUpdate(){
fi fi
} }
#
# Set the new current version in a file
#
function setCurrentVersion(){
cd "$arkserverroot"
echo $bnumber > arkversion
}
# #
# Check if the server need to be updated # Check if the server need to be updated
# Return 0 if update is needed, else return 1 # Return 0 if update is needed, else return 1
@ -156,6 +154,7 @@ function parseSteamACF(){
function getCurrentVersion(){ function getCurrentVersion(){
if [ -f "${arkserverroot}/steamapps/appmanifest_${appid}.acf" ]; then if [ -f "${arkserverroot}/steamapps/appmanifest_${appid}.acf" ]; then
instver=`while read name val; do if [ "${name}" == "{" ]; then parseSteamACF "" "buildid"; break; fi; done <"${arkserverroot}/steamapps/appmanifest_${appid}.acf"` instver=`while read name val; do if [ "${name}" == "{" ]; then parseSteamACF "" "buildid"; break; fi; done <"${arkserverroot}/steamapps/appmanifest_${appid}.acf"`
echo $instver > "$arkserverroot/arkversion"
else else
instver="" instver=""
fi fi
@ -198,6 +197,38 @@ function isTheServerUp(){
fi fi
} }
#
# run function
#
doRun() {
arkserveropts=$serverMap
# bring in ark_... options
for varname in "${!ark_@}"; do
name="${varname#ark_}"
val="${!varname}"
# Port is actually one higher than specified
# i.e. specifying port 7777 will have the server
# use port 7778
if [ "$name" == "Port" ]; then
(( val = val - 1 ))
fi
if [ -n "$val" ]; then
arkserveropts="${arkserveropts}?${name}=${val}"
fi
done
arkserveropts="${arkserveropts}?listen"
# run the server in background
echo "`timestamp`: start"
# set max open files limit before we start the server
ulimit -n $maxOpenFiles
"$arkserverroot/$arkserverexec" "$arkserveropts"
echo "`timestamp`: exited with status $?"
}
# #
# start function # start function
# #
@ -208,32 +239,8 @@ doStart() {
tput sc tput sc
echo "The server is starting..." echo "The server is starting..."
arkserveropts=$serverMap doRun </dev/null >>"$logdir/$arkserverLog" 2>&1 & # output of this command is logged
echo "`timestamp`: start" >> "$logdir/$arkmanagerLog"
# bring in ark_... options
for varname in "${!ark_@}"; do
name="${varname#ark_}"
val="${!varname}"
# Port is actually one higher than specified
# i.e. specifying port 7777 will have the server
# use port 7778
if [ "$name" == "Port" ]; then
(( val = val - 1 ))
fi
if [ -n "$val" ]; then
arkserveropts="${arkserveropts}?${name}=${val}"
fi
done
arkserveropts="${arkserveropts}?listen"
# run the server in background
echo "$timestamp: start" >> "$logdir/$arkserverLog"
# set max open files limit before we start the server
ulimit -n $maxOpenFiles
nohup "$arkserverroot/$arkserverexec" "$arkserveropts" </dev/null >"$logdir/$arkserverLog" 2>&1 & # output of this command is logged
echo "$timestamp: start" >> "$logdir/$arkmanagerLog"
tput rc; tput ed; tput rc; tput ed;
echo "The server is now up" echo "The server is now up"
fi fi
@ -252,7 +259,7 @@ doStop() {
tput rc; tput ed; tput rc; tput ed;
echo "The server has been stopped" echo "The server has been stopped"
echo "$timestamp: stop" >> "$logdir/$arkmanagerLog" echo "`timestamp`: stop" >> "$logdir/$arkmanagerLog"
else else
echo "The server is already stopped" echo "The server is already stopped"
fi fi
@ -268,8 +275,7 @@ doInstall() {
# install the server # install the server
./$steamcmdexec +login anonymous +force_install_dir "$arkserverroot" +app_update $appid validate +quit ./$steamcmdexec +login anonymous +force_install_dir "$arkserverroot" +app_update $appid validate +quit
# the current version should be the last version. We set our version # the current version should be the last version. We set our version
getAvailableVersion getCurrentVersion
setCurrentVersion
} }
# #
@ -282,7 +288,7 @@ doUpdate() {
forceUpdate forceUpdate
else else
echo "Your server is already up to date! The most recent version is ${bnumber}." echo "Your server is already up to date! The most recent version is ${bnumber}."
echo "$timestamp: No update needed." >> "$logdir/update.log" echo "`timestamp`: No update needed." >> "$logdir/update.log"
fi; fi;
} }
@ -296,9 +302,8 @@ forceUpdate(){
cd "$steamcmdroot" cd "$steamcmdroot"
./$steamcmdexec +login anonymous +force_install_dir "$arkserverroot" +app_update $appid +quit ./$steamcmdexec +login anonymous +force_install_dir "$arkserverroot" +app_update $appid +quit
# the current version should be the last version. We set our version # the current version should be the last version. We set our version
getAvailableVersion getCurrentVersion
setCurrentVersion echo "`timestamp`: update to $instver complete" >> "$logdir/update.log"
echo "$timestamp: update to $instver complete" >> "$logdir/update.log"
# we restart the server only if it was started before the update # we restart the server only if it was started before the update
if [ $serverWasAlive -eq 1 ]; then if [ $serverWasAlive -eq 1 ]; then
@ -314,14 +319,14 @@ safeUpdate(){
if isUpdateNeeded; then if isUpdateNeeded; then
while [ ! `find $arkserverroot/ShooterGame/Saved/SavedArks -mmin -1 -name $serverMap.ark` ]; do while [ ! `find $arkserverroot/ShooterGame/Saved/SavedArks -mmin -1 -name $serverMap.ark` ]; do
echo "$timestamp: Save file older than 1 minute. Delaying update." >> "$logdir/update.log" echo "`timestamp`: Save file older than 1 minute. Delaying update." >> "$logdir/update.log"
sleep 30s sleep 30s
done done
echo "$timestamp: Save file newer than 1 minute. Performing an update." >> "$logdir/update.log" echo "`timestamp`: Save file newer than 1 minute. Performing an update." >> "$logdir/update.log"
forceUpdate forceUpdate
else else
echo "Your server is already up to date! The most recent version is ${bnumber}." echo "Your server is already up to date! The most recent version is ${bnumber}."
echo "$timestamp: No update needed." >> "$logdir/update.log" echo "`timestamp`: No update needed." >> "$logdir/update.log"
fi fi
} }
@ -378,11 +383,11 @@ case "$1" in
;; ;;
restart) restart)
doStop doStop
echo "$timestamp: stop" >> "$logdir/$arkmanagerLog" echo "`timestamp`: stop" >> "$logdir/$arkmanagerLog"
sleep 10 sleep 10
doStart doStart
echo "$timestamp: start" >> "$logdir/$arkmanagerLog" echo "`timestamp`: start" >> "$logdir/$arkmanagerLog"
echo "$timestamp: restart" >> "$logdir/$arkmanagerLog" echo "`timestamp`: restart" >> "$logdir/$arkmanagerLog"
;; ;;
install) install)
doInstall doInstall

View File

@ -86,7 +86,10 @@ if [ ! -z "$1" ]; then
# Copy arkmanager.cfg inside linux configuation folder if it doesn't already exists # Copy arkmanager.cfg inside linux configuation folder if it doesn't already exists
mkdir -p "${INSTALL_ROOT}/etc/arkmanager" mkdir -p "${INSTALL_ROOT}/etc/arkmanager"
if [ -f "${INSTALL_ROOT}/etc/arkmanager/arkmanager.cfg" ]; then if [ -f "${INSTALL_ROOT}/etc/arkmanager/arkmanager.cfg" ]; then
cp -n arkmanager.cfg "${INSTALL_ROOT}/etc/arkmanager/arkmanager.cfg.NEW"
chown "$1" "${INSTALL_ROOT}/etc/arkmanager/arkmanager.cfg.NEW"
echo "A previous version of ARK Server Tools was detected in your system, your old configuration was not overwritten. You may need to manually update it." echo "A previous version of ARK Server Tools was detected in your system, your old configuration was not overwritten. You may need to manually update it."
echo "A copy of the new configuration file was included in /etc/arkmanager. Make sure to review any changes and update your config accordingly!"
exit 2 exit 2
else else
cp -n arkmanager.cfg "${INSTALL_ROOT}/etc/arkmanager/arkmanager.cfg" cp -n arkmanager.cfg "${INSTALL_ROOT}/etc/arkmanager/arkmanager.cfg"

View File

@ -28,6 +28,7 @@ test -x $DAEMON || exit 5
case "$1" in case "$1" in
start) start)
log_daemon_msg "Starting" "$NAME" log_daemon_msg "Starting" "$NAME"
ulimit -n 100000
su -s /bin/sh -c "$DAEMON start" $steamcmd_user su -s /bin/sh -c "$DAEMON start" $steamcmd_user
sleep 5 sleep 5
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'` PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`
@ -53,6 +54,7 @@ case "$1" in
;; ;;
restart) restart)
ulimit -n 100000
su -s /bin/sh -c "$DAEMON restart" $steamcmd_user su -s /bin/sh -c "$DAEMON restart" $steamcmd_user
;; ;;

View File

@ -14,6 +14,7 @@ depend(){
start(){ start(){
ebegin "Starting ARK manager daemon" ebegin "Starting ARK manager daemon"
ulimit -n 100000
su -s /bin/sh -c "$DAEMON start" $steamcmd_user su -s /bin/sh -c "$DAEMON start" $steamcmd_user
sleep 5 sleep 5
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'` PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`

View File

@ -42,6 +42,7 @@ test -x $DAEMON || exit 5
case "$1" in case "$1" in
start) start)
echo -n "Starting $NAME: " echo -n "Starting $NAME: "
ulimit -n 100000
su -s /bin/sh -c "$DAEMON start" $steamcmd_user > /dev/null su -s /bin/sh -c "$DAEMON start" $steamcmd_user > /dev/null
sleep 5 sleep 5
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'` PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`
@ -74,6 +75,7 @@ case "$1" in
restart) restart)
echo -n "Restarting $NAME: " echo -n "Restarting $NAME: "
ulimit -n 100000
su -s /bin/sh -c "$DAEMON restart" $steamcmd_user > /dev/null su -s /bin/sh -c "$DAEMON restart" $steamcmd_user > /dev/null
echo "OK" echo "OK"
;; ;;

View File

@ -39,6 +39,7 @@ test -x $DAEMON || exit 5
case "$1" in case "$1" in
start) start)
echo -n "Starting $NAME: " echo -n "Starting $NAME: "
ulimit -n 100000
su -s /bin/sh -c "$DAEMON start" $steamcmd_user > /dev/null su -s /bin/sh -c "$DAEMON start" $steamcmd_user > /dev/null
sleep 5 sleep 5
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'` PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`
@ -69,6 +70,7 @@ case "$1" in
restart) restart)
echo -n "Restarting $NAME: " echo -n "Restarting $NAME: "
ulimit -n 100000
su -s /bin/sh -c "$DAEMON restart" $steamcmd_user > /dev/null su -s /bin/sh -c "$DAEMON restart" $steamcmd_user > /dev/null
echo "OK" echo "OK"
;; ;;