diff --git a/README.md b/README.md index 7b64a76..7bb845e 100644 --- a/README.md +++ b/README.md @@ -94,7 +94,10 @@ stops ARK server restarts ARK server #### arkmanager update -manually updates ARK server +manually updates ARK server if a new version is available + +#### arkmanager forceupdate +Apply update without check the current version #### 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 c350fe7..b3548c5 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -41,12 +41,6 @@ arkserverLog="arkserver.log" # here is logged the output of ShooterGameServer #--------------------- # functions #--------------------- -function testfunction(){ - if [ -z $servermail ]; then - echo "mail ok" - fi - -} # # Check if a new version is available but not apply it @@ -94,7 +88,9 @@ function isUpdateNeeded(){ # function getCurrentVersion(){ cd "$arkserverroot" - touch arkversion # If the file doesn't exist + if ! [ -f arkversion ];then + touch arkversion + fi instver=`cat "arkversion"` return $instver @@ -121,13 +117,20 @@ function isTheServerRunning(){ # # Check if the server is down and not visible in steam server list # -function isTheServerDown(){ - lsof -i |grep $ark_Port > /dev/null +# +function isTheServerUp(){ + lsof -i :"$ark_Port" > /dev/null result=$? - return $result + # In this case, the result is: + # 1 if the command fail. The port is not listenning + # 0 if the command succeed. The port is listenning + if [ $result -eq 0 ];then + return 1 + else + return 0 + fi } - # # start function # @@ -207,27 +210,31 @@ doUpdate() { cd "$arkserverroot" if isUpdateNeeded; then - # check if the server was alive before the update so we can launch it back after the update - serverWasAlive=0 - if isTheServerRunning ;then - serverWasAlive=1 - fi - doStop - cd "$steamcmdroot" - ./$steamcmdexec +login anonymous +force_install_dir "$arkserverroot" +app_update $appid +quit - echo "$bnumber" > "$arkserverroot/arkversion" - echo "$timestamp: update to $bnumber complete" >> "$logdir/update.log" - - # we restart the server only if it was started before the update - if [ $serverWasAlive -eq 1 ]; then - doStart - fi + 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; } +forceUpdate(){ + # check if the server was alive before the update so we can launch it back after the update + serverWasAlive=0 + if isTheServerRunning ;then + serverWasAlive=1 + fi + doStop + cd "$steamcmdroot" + ./$steamcmdexec +login anonymous +force_install_dir "$arkserverroot" +app_update $appid +quit + echo "$bnumber" > "$arkserverroot/arkversion" + echo "$timestamp: update to $bnumber complete" >> "$logdir/update.log" + + # we restart the server only if it was started before the update + if [ $serverWasAlive -eq 1 ]; then + doStart + fi +} + # # Print the status of the server (running? online? version?) # @@ -238,7 +245,7 @@ printStatus(){ echo -e "$NORMAL" "Server running: " "$RED" "No" "$NORMAL" fi - if isTheServerDown ;then + if isTheServerUp ;then echo -e "$NORMAL" "Server online: " "$RED" "No" "$NORMAL" else echo -e "$NORMAL" "Server online: " "$GREEN" "Yes" "$NORMAL" @@ -273,6 +280,9 @@ case "$1" in doUpdate #testfunction ;; + forceupdate) + forceUpdate + ;; checkupdate) tput sc echo "Querying Steam database for latest version..." @@ -292,6 +302,7 @@ case "$1" in echo "restart Stops the server and then starts it" echo "install Install the ARK server files from steamcmd" 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 "boradcast PLACEHOLDER, not supported yet" echo "status Returns the status of the current ARK server instance" diff --git a/tools/install.sh b/tools/install.sh index 102f804..d4f008f 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -12,6 +12,7 @@ if [ ! -z "$1" ]; then # on debian 8, sysvinit and systemd are present. If systemd is available we use it instead of sysvinit if [[ -f /etc/systemd/system.conf ]]; then # used by systemd cp systemd/arkdeamon.service /etc/systemd/system/arkdaemon.service + systemctl daemon-reload systemctl enable arkdeamon.service echo "Ark server will now start on boot, if you want to remove this feature run the following line" echo "systemctl disable unit"