From 3462be3066bf606c467016117ad95e67fb3fa947 Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Sat, 27 Jun 2015 19:55:04 +1000 Subject: [PATCH 1/9] Use getCurrentVersion after update --- tools/arkmanager | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/tools/arkmanager b/tools/arkmanager index 0f1b6fa..d3cea38 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -63,14 +63,6 @@ function checkForUpdate(){ fi } -# -# Set the new current version in a file -# -function setCurrentVersion(){ - cd "$arkserverroot" - echo $bnumber > arkversion -} - # # Check if the server need to be updated # Return 0 if update is needed, else return 1 @@ -119,6 +111,7 @@ function parseSteamACF(){ function getCurrentVersion(){ 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"` + echo $instver > "$arkserverroot/arkversion" else instver="" fi @@ -229,8 +222,7 @@ doInstall() { # install the server ./$steamcmdexec +login anonymous +force_install_dir "$arkserverroot" +app_update $appid validate +quit # the current version should be the last version. We set our version - getAvailableVersion - setCurrentVersion + getCurrentVersion } # @@ -257,8 +249,7 @@ forceUpdate(){ cd "$steamcmdroot" ./$steamcmdexec +login anonymous +force_install_dir "$arkserverroot" +app_update $appid +quit # the current version should be the last version. We set our version - getAvailableVersion - setCurrentVersion + getCurrentVersion echo "$timestamp: update to $instver complete" >> "$logdir/update.log" # we restart the server only if it was started before the update From 090bf70b11f15599c6549240bd9266ea2fbcd315 Mon Sep 17 00:00:00 2001 From: Marius Linge Date: Sat, 27 Jun 2015 11:56:37 +0200 Subject: [PATCH 2/9] Includes a copy of the newest config file on installation --- tools/install.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/install.sh b/tools/install.sh index 420aba1..55d249c 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -86,7 +86,10 @@ if [ ! -z "$1" ]; then # Copy arkmanager.cfg inside linux configuation folder if it doesn't already exists mkdir -p "${INSTALL_ROOT}/etc/arkmanager" 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 copy of the new configuration file was included in /etc/arkmanager. Make sure to review any changes and update your config accordingly!" exit 2 else cp -n arkmanager.cfg "${INSTALL_ROOT}/etc/arkmanager/arkmanager.cfg" From 73816a228338e8779aa085bb2eadfed01b7b4f70 Mon Sep 17 00:00:00 2001 From: Q11x Date: Sat, 27 Jun 2015 13:30:05 +0200 Subject: [PATCH 3/9] Update README.md changed the wording a bit, so it would be easier to understand. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d63a35b..fb45856 100644 --- a/README.md +++ b/README.md @@ -65,8 +65,8 @@ ark_ServerPVE=False ark_DifficultyOffset=1 ``` -Your session name may contain special characters (eg. `!![EU]!! Aw&some ARK`) which 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. +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 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. From d7004922dd1e813de136a9086cccc4b0c9139d66 Mon Sep 17 00:00:00 2001 From: Fez Vrasta Date: Sat, 27 Jun 2015 18:10:44 +0200 Subject: [PATCH 4/9] Revert "Waiting for world save before update." --- README.md | 3 --- tools/arkmanager | 21 --------------------- 2 files changed, 24 deletions(-) diff --git a/README.md b/README.md index ff03718..d63a35b 100644 --- a/README.md +++ b/README.md @@ -99,9 +99,6 @@ manually updates ARK server if a new version is available #### arkmanager forceupdate Apply update without check the current version -#### arkmanager safeupdate -Waits for server to perform world save and then updates. - #### arkmanager status Get the status of the server. Show if the process is running, if the server is up and the current version number diff --git a/tools/arkmanager b/tools/arkmanager index 8a57114..d3cea38 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -258,26 +258,6 @@ forceUpdate(){ fi } -# -# Waits for server to perform save before update (until save file is newer than 1 minute) -# -safeUpdate(){ - cd "$arkserverroot" - - if isUpdateNeeded; then - 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" - sleep 30s - done - echo "$timestamp: Save file newer than 1 minute. Performing an update." >> "$logdir/update.log" - forceUpdate - else - echo "Your server is already up to date! The most recent version is ${bnumber}." - echo "$timestamp: No update needed." >> "$logdir/update.log" - fi -} - - # # Print the status of the server (running? online? version?) # @@ -345,7 +325,6 @@ case "$1" in echo "update Check for a new ARK server version, if needed, stops the server, updates it, and starts it again" echo "forceupdate Apply update without check the current version" echo "checkupdate Check for a new ARK server version" - echo "safeupdate Wait for server to perform world save and update. echo "boradcast PLACEHOLDER, not supported yet" echo "status Returns the status of the current ARK server instance" ;; From a6b0afda6550e2bfce6a460bf92075d2f970b66c Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Sun, 28 Jun 2015 23:32:48 +1000 Subject: [PATCH 5/9] Revert "Revert "Waiting for world save before update."" This reverts commit d7004922dd1e813de136a9086cccc4b0c9139d66. --- README.md | 3 +++ tools/arkmanager | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/README.md b/README.md index fb45856..54823ac 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,9 @@ manually updates ARK server if a new version is available #### arkmanager forceupdate Apply update without check the current version +#### arkmanager safeupdate +Waits for server to perform world save and then updates. + #### arkmanager status Get the status of the server. Show if the process is running, if the server is up and the current version number diff --git a/tools/arkmanager b/tools/arkmanager index d3cea38..8a57114 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -258,6 +258,26 @@ forceUpdate(){ fi } +# +# Waits for server to perform save before update (until save file is newer than 1 minute) +# +safeUpdate(){ + cd "$arkserverroot" + + if isUpdateNeeded; then + 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" + sleep 30s + done + echo "$timestamp: Save file newer than 1 minute. Performing an update." >> "$logdir/update.log" + forceUpdate + else + echo "Your server is already up to date! The most recent version is ${bnumber}." + echo "$timestamp: No update needed." >> "$logdir/update.log" + fi +} + + # # Print the status of the server (running? online? version?) # @@ -325,6 +345,7 @@ case "$1" in echo "update Check for a new ARK server version, if needed, stops the server, updates it, and starts it again" echo "forceupdate Apply update without check the current version" echo "checkupdate Check for a new ARK server version" + echo "safeupdate Wait for server to perform world save and update. echo "boradcast PLACEHOLDER, not supported yet" echo "status Returns the status of the current ARK server instance" ;; From 4b74bf3e6972a949ecd4a62e161293053ebb57b4 Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Sun, 28 Jun 2015 14:20:30 +1000 Subject: [PATCH 6/9] Increase open file limits before start and restart --- tools/lsb/arkdaemon | 2 ++ tools/openrc/arkdaemon | 1 + tools/redhat/arkdaemon | 2 ++ tools/systemd/arkdaemon.init | 2 ++ 4 files changed, 7 insertions(+) diff --git a/tools/lsb/arkdaemon b/tools/lsb/arkdaemon index ad802c3..f728ede 100755 --- a/tools/lsb/arkdaemon +++ b/tools/lsb/arkdaemon @@ -28,6 +28,7 @@ test -x $DAEMON || exit 5 case "$1" in start) log_daemon_msg "Starting" "$NAME" + ulimit -n 100000 su -s /bin/sh -c "$DAEMON start" $steamcmd_user sleep 5 PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'` @@ -53,6 +54,7 @@ case "$1" in ;; restart) + ulimit -n 100000 su -s /bin/sh -c "$DAEMON restart" $steamcmd_user ;; diff --git a/tools/openrc/arkdaemon b/tools/openrc/arkdaemon index 7104607..d83f94c 100644 --- a/tools/openrc/arkdaemon +++ b/tools/openrc/arkdaemon @@ -14,6 +14,7 @@ depend(){ start(){ ebegin "Starting ARK manager daemon" + ulimit -n 100000 su -s /bin/sh -c "$DAEMON start" $steamcmd_user sleep 5 PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'` diff --git a/tools/redhat/arkdaemon b/tools/redhat/arkdaemon index e51925c..411bcd1 100755 --- a/tools/redhat/arkdaemon +++ b/tools/redhat/arkdaemon @@ -42,6 +42,7 @@ test -x $DAEMON || exit 5 case "$1" in start) echo -n "Starting $NAME: " + ulimit -n 100000 su -s /bin/sh -c "$DAEMON start" $steamcmd_user > /dev/null sleep 5 PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'` @@ -74,6 +75,7 @@ case "$1" in restart) echo -n "Restarting $NAME: " + ulimit -n 100000 su -s /bin/sh -c "$DAEMON restart" $steamcmd_user > /dev/null echo "OK" ;; diff --git a/tools/systemd/arkdaemon.init b/tools/systemd/arkdaemon.init index 6faa93e..2cde2ab 100755 --- a/tools/systemd/arkdaemon.init +++ b/tools/systemd/arkdaemon.init @@ -39,6 +39,7 @@ test -x $DAEMON || exit 5 case "$1" in start) echo -n "Starting $NAME: " + ulimit -n 100000 su -s /bin/sh -c "$DAEMON start" $steamcmd_user > /dev/null sleep 5 PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'` @@ -69,6 +70,7 @@ case "$1" in restart) echo -n "Restarting $NAME: " + ulimit -n 100000 su -s /bin/sh -c "$DAEMON restart" $steamcmd_user > /dev/null echo "OK" ;; From 9bd8973f87d5a559ac328fde22852ec846b9748d Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Sun, 28 Jun 2015 23:43:36 +1000 Subject: [PATCH 7/9] Replace timestamp variable with timestamp function --- tools/arkmanager | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tools/arkmanager b/tools/arkmanager index 3cd0921..124ab05 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -30,7 +30,6 @@ info="" thejob="" instver="" bnumber="" -timestamp=$( date +%T ) GREEN="\\033[1;32m" RED="\\033[1;31m" YELLOW="\\e[0;33m" @@ -44,6 +43,13 @@ arkserverLog="arkserver.log" # here is logged the output of ShooterGameServer # functions #--------------------- +# +# timestamp +# +timestamp() { + date +%T +} + # # check configuration and report errors # @@ -222,11 +228,11 @@ doStart() { arkserveropts="${arkserveropts}?listen" # run the server in background - echo "$timestamp: start" >> "$logdir/$arkserverLog" + echo "`timestamp`: start" >> "$logdir/$arkserverLog" # set max open files limit before we start the server ulimit -n $maxOpenFiles nohup "$arkserverroot/$arkserverexec" "$arkserveropts" "$logdir/$arkserverLog" 2>&1 & # output of this command is logged - echo "$timestamp: start" >> "$logdir/$arkmanagerLog" + echo "`timestamp`: start" >> "$logdir/$arkmanagerLog" tput rc; tput ed; echo "The server is now up" fi @@ -245,7 +251,7 @@ doStop() { tput rc; tput ed; echo "The server has been stopped" - echo "$timestamp: stop" >> "$logdir/$arkmanagerLog" + echo "`timestamp`: stop" >> "$logdir/$arkmanagerLog" else echo "The server is already stopped" fi @@ -274,7 +280,7 @@ doUpdate() { forceUpdate else 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; } @@ -289,7 +295,7 @@ forceUpdate(){ ./$steamcmdexec +login anonymous +force_install_dir "$arkserverroot" +app_update $appid +quit # the current version should be the last version. We set our version getCurrentVersion - 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 if [ $serverWasAlive -eq 1 ]; then @@ -305,14 +311,14 @@ safeUpdate(){ if isUpdateNeeded; then 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 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 else 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 } @@ -369,11 +375,11 @@ case "$1" in ;; restart) doStop - echo "$timestamp: stop" >> "$logdir/$arkmanagerLog" + echo "`timestamp`: stop" >> "$logdir/$arkmanagerLog" sleep 10 doStart - echo "$timestamp: start" >> "$logdir/$arkmanagerLog" - echo "$timestamp: restart" >> "$logdir/$arkmanagerLog" + echo "`timestamp`: start" >> "$logdir/$arkmanagerLog" + echo "`timestamp`: restart" >> "$logdir/$arkmanagerLog" ;; install) doInstall From ac88ed1a7a5ad73e16abc1b654b9ce713d4c05c9 Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Sun, 28 Jun 2015 23:45:42 +1000 Subject: [PATCH 8/9] Add doRun function; background as subprocess --- tools/arkmanager | 58 +++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/tools/arkmanager b/tools/arkmanager index 124ab05..4f93f45 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -197,6 +197,38 @@ function isTheServerUp(){ 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" + +} + # # start function # @@ -207,31 +239,7 @@ doStart() { tput sc echo "The server is starting..." - 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" >> "$logdir/$arkserverLog" - # set max open files limit before we start the server - ulimit -n $maxOpenFiles - nohup "$arkserverroot/$arkserverexec" "$arkserveropts" "$logdir/$arkserverLog" 2>&1 & # output of this command is logged + doRun >"$logdir/$arkserverLog" 2>&1 & # output of this command is logged echo "`timestamp`: start" >> "$logdir/$arkmanagerLog" tput rc; tput ed; echo "The server is now up" From a28426e4a0bfe9a9617d8bd2e38dcf6caf6a922e Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Sun, 28 Jun 2015 23:48:09 +1000 Subject: [PATCH 9/9] Log server exit status --- tools/arkmanager | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/arkmanager b/tools/arkmanager index 4f93f45..c668302 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -226,7 +226,7 @@ doRun() { # set max open files limit before we start the server ulimit -n $maxOpenFiles "$arkserverroot/$arkserverexec" "$arkserveropts" - + echo "`timestamp`: exited with status $?" } #