fix issue #31 and add forceupdate function

This commit is contained in:
Sispheor 2015-06-24 21:33:13 +02:00 committed by FezVrasta
parent 446147982f
commit e26a49a825
3 changed files with 43 additions and 28 deletions

View File

@ -94,7 +94,10 @@ stops ARK server
restarts ARK server restarts ARK server
#### arkmanager update #### 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 #### arkmanager status
Get the status of the server. Show if the process is running, if the server is up and the current version number Get the status of the server. Show if the process is running, if the server is up and the current version number

View File

@ -41,12 +41,6 @@ arkserverLog="arkserver.log" # here is logged the output of ShooterGameServer
#--------------------- #---------------------
# functions # functions
#--------------------- #---------------------
function testfunction(){
if [ -z $servermail ]; then
echo "mail ok"
fi
}
# #
# Check if a new version is available but not apply it # Check if a new version is available but not apply it
@ -94,7 +88,9 @@ function isUpdateNeeded(){
# #
function getCurrentVersion(){ function getCurrentVersion(){
cd "$arkserverroot" cd "$arkserverroot"
touch arkversion # If the file doesn't exist if ! [ -f arkversion ];then
touch arkversion
fi
instver=`cat "arkversion"` instver=`cat "arkversion"`
return $instver return $instver
@ -121,13 +117,20 @@ function isTheServerRunning(){
# #
# Check if the server is down and not visible in steam server list # 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=$? 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 # start function
# #
@ -207,27 +210,31 @@ doUpdate() {
cd "$arkserverroot" cd "$arkserverroot"
if isUpdateNeeded; then if isUpdateNeeded; then
# check if the server was alive before the update so we can launch it back after the update forceUpdate
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
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;
} }
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?) # Print the status of the server (running? online? version?)
# #
@ -238,7 +245,7 @@ printStatus(){
echo -e "$NORMAL" "Server running: " "$RED" "No" "$NORMAL" echo -e "$NORMAL" "Server running: " "$RED" "No" "$NORMAL"
fi fi
if isTheServerDown ;then if isTheServerUp ;then
echo -e "$NORMAL" "Server online: " "$RED" "No" "$NORMAL" echo -e "$NORMAL" "Server online: " "$RED" "No" "$NORMAL"
else else
echo -e "$NORMAL" "Server online: " "$GREEN" "Yes" "$NORMAL" echo -e "$NORMAL" "Server online: " "$GREEN" "Yes" "$NORMAL"
@ -273,6 +280,9 @@ case "$1" in
doUpdate doUpdate
#testfunction #testfunction
;; ;;
forceupdate)
forceUpdate
;;
checkupdate) checkupdate)
tput sc tput sc
echo "Querying Steam database for latest version..." echo "Querying Steam database for latest version..."
@ -292,6 +302,7 @@ case "$1" in
echo "restart Stops the server and then starts it" echo "restart Stops the server and then starts it"
echo "install Install the ARK server files from steamcmd" 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 "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 "checkupdate Check for a new ARK server version"
echo "boradcast PLACEHOLDER, not supported yet" echo "boradcast PLACEHOLDER, not supported yet"
echo "status Returns the status of the current ARK server instance" echo "status Returns the status of the current ARK server instance"

View File

@ -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 # 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 if [[ -f /etc/systemd/system.conf ]]; then # used by systemd
cp systemd/arkdeamon.service /etc/systemd/system/arkdaemon.service cp systemd/arkdeamon.service /etc/systemd/system/arkdaemon.service
systemctl daemon-reload
systemctl enable arkdeamon.service systemctl enable arkdeamon.service
echo "Ark server will now start on boot, if you want to remove this feature run the following line" echo "Ark server will now start on boot, if you want to remove this feature run the following line"
echo "systemctl disable unit" echo "systemctl disable unit"