Merge pull request #48 from Sispheor/dev#1.1

dev#1.1 ready to go
This commit is contained in:
Fez Vrasta 2015-06-24 21:56:29 +02:00
commit 9ba4655315
4 changed files with 72 additions and 35 deletions

View File

@ -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

View File

@ -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"

26
tools/install.sh Normal file → Executable file
View File

@ -9,14 +9,23 @@ if [ ! -z "$1" ]; then
# 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
# 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 "update-rc.d -f arkmanager remove"
echo "systemctl disable unit"
else # systemd not present, so use sysvinit
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
fi
elif [ -f /etc/rc.d/init.d/functions ]; then
cp redhat/arkdaemon "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager"
@ -36,6 +45,9 @@ if [ ! -z "$1" ]; then
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
elif [[ /etc/systemd/system.conf ]]; then # used by systemd
cp systemd/arkdeamon.service /etc/systemd/system/arkdaemon.service
systemctl enable arkdeamon.service
fi
# Create a folder in /var/log to let Ark tools write its own log files

View File

@ -0,0 +1,11 @@
[Unit]
Description=Daemon to start ark server
After=network.target
[Service]
ExecStart=/etc/init.d/arkdaemon start
ExecStop=/etc/init.d/arkdaemon stop
Type=forking
[Install]
WantedBy=multi-user.target