mirror of
https://github.com/eliasstepanik/ark-ac-server-tools.git
synced 2026-01-27 08:48:27 +00:00
commit
30d143119d
11
CONTRIBUTING.md
Normal file
11
CONTRIBUTING.md
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# Contribute to ARK Server Tools
|
||||||
|
|
||||||
|
This is an open source project, so feel free to fork it, improve it and send pull requests!
|
||||||
|
|
||||||
|
## Keep your fork updated
|
||||||
|
|
||||||
|
When you fork our repository and your version gets outdated, please, update it using `git pull --rebase`, in this way you will not create any additional useless commit.
|
||||||
|
|
||||||
|
## Got an idea?
|
||||||
|
|
||||||
|
If you have a nice idea you'd like to add to this project, please, first open a new issue describing your idea, so everybody can contribute to it and you'll be sure that nobody is working on the same thing.
|
||||||
56
README.md
56
README.md
@ -9,14 +9,8 @@ https://developer.valvesoftware.com/wiki/SteamCMD#Linux
|
|||||||
We assume you have created the `steam` user to store steamcmd and your ARK server.
|
We assume you have created the `steam` user to store steamcmd and your ARK server.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
Use this command to install soft requirement on your system
|
|
||||||
```
|
|
||||||
# Debian based/ Ubuntu
|
|
||||||
apt-get install screen
|
|
||||||
|
|
||||||
# RHEL / CentOS / Fedora
|
### Increase max open files
|
||||||
yum install screen
|
|
||||||
```
|
|
||||||
|
|
||||||
Edit /etc/sysctl.conf and set:
|
Edit /etc/sysctl.conf and set:
|
||||||
```
|
```
|
||||||
@ -34,21 +28,47 @@ session required pam_limits.so
|
|||||||
|
|
||||||
After these edits, you'll need to restart your bash session or reconnect to your SSH shell to make the changes effective.
|
After these edits, you'll need to restart your bash session or reconnect to your SSH shell to make the changes effective.
|
||||||
|
|
||||||
|
### Open firewall ports
|
||||||
|
|
||||||
|
```sh
|
||||||
|
iptables -I INPUT -p udp --dport 27016 -j ACCEPT
|
||||||
|
iptables -I INPUT -p tcp --dport 27016 -j ACCEPT
|
||||||
|
iptables -I INPUT -p udp --dport 7778 -j ACCEPT
|
||||||
|
iptables -I INPUT -p tcp --dport 7778 -j ACCEPT
|
||||||
|
```
|
||||||
|
|
||||||
|
NB: Change the ports according to the ones set in your `arkmanager.cfg` file.
|
||||||
|
|
||||||
## Install ARK Server Tools
|
## Install ARK Server Tools
|
||||||
|
|
||||||
To install ARK Server Tools run this command:
|
To install ARK Server Tools run this command:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl -s https://raw.githubusercontent.com/FezVrasta/ark-server-tools/master/netinstall.sh | sudo bash -s steam
|
curl -s http://git.io/vtf5N | sudo bash -s steam
|
||||||
```
|
```
|
||||||
|
|
||||||
NB: You may want to change the `bash -s` parameter to fit your steam user if different from `steam`.
|
NB: You may want to change the `bash -s` parameter to fit your steam user if different from `steam`.
|
||||||
|
|
||||||
This will copy the `arkmanager` and the `arkdaemon` to the proper directories and will create an empty log directory in `/var/log` for ARK Server Tools.
|
This will copy the `arkmanager` script and its daemon to the proper directories and will create an empty log directory in `/var/log` for ARK Server Tools.
|
||||||
|
|
||||||
## Configure ARK Server
|
## Configuration
|
||||||
|
|
||||||
All the needed variables are stored in the /etc/arkmanager/arkmanager.cfg configuration file change them following the comments.
|
Stored in `/etc/arkmanager/arkmanager.cfg` you can find the variables needed to start the server, like the port numbers, the system environment variables and so on.
|
||||||
|
|
||||||
|
Also, in this file, you can specify any parameter you want to add to the startup command of ARK server.
|
||||||
|
These parameters must be prefixed by the `ark_` string, some example could be:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ark_SessionName="My ARK server"
|
||||||
|
ark_MaxPlayers=50
|
||||||
|
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.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
## Install ARK Server
|
## Install ARK Server
|
||||||
|
|
||||||
@ -59,6 +79,8 @@ arkmanager install
|
|||||||
```
|
```
|
||||||
## Commands
|
## Commands
|
||||||
|
|
||||||
|
To get a complete list of the script commands you can run `arkmanager --help` or `arkmanager -h`.
|
||||||
|
|
||||||
#### arkmanager install
|
#### arkmanager install
|
||||||
installs arkmanager to the directory specified in `.arkmanager.cfg`
|
installs arkmanager to the directory specified in `.arkmanager.cfg`
|
||||||
|
|
||||||
@ -72,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
|
||||||
@ -80,13 +105,6 @@ Get the status of the server. Show if the process is running, if the server is u
|
|||||||
#### arkmanager checkupdate
|
#### arkmanager checkupdate
|
||||||
Check if a new version of the server is available but not apply it
|
Check if a new version of the server is available but not apply it
|
||||||
|
|
||||||
#### arkmanager broadcast [message]
|
|
||||||
broadcast a message to ARK server chat
|
|
||||||
|
|
||||||
```sh
|
|
||||||
arkmanager broadcast "your message here"
|
|
||||||
```
|
|
||||||
|
|
||||||
## Credits
|
## Credits
|
||||||
|
|
||||||
Original author of arkmanager: LeXaT
|
Original author of arkmanager: LeXaT
|
||||||
|
|||||||
240
tools/arkmanager
240
tools/arkmanager
@ -3,7 +3,8 @@
|
|||||||
# ARK: survival evolved manager
|
# ARK: survival evolved manager
|
||||||
#
|
#
|
||||||
# Original author: LeXaT
|
# Original author: LeXaT
|
||||||
# Maintainer: FezVrasta, Sispheor
|
# Maintainer: FezVrasta
|
||||||
|
# Contributors: Sispheor, Atriusftw, klightspeed, lexat, puseidr
|
||||||
|
|
||||||
# Check the user is not currently running this script as root
|
# Check the user is not currently running this script as root
|
||||||
if [ "$(id -u)" == "0" ]; then
|
if [ "$(id -u)" == "0" ]; then
|
||||||
@ -16,7 +17,13 @@ fi
|
|||||||
#---------------------
|
#---------------------
|
||||||
|
|
||||||
# Global variables
|
# Global variables
|
||||||
source /etc/arkmanager/arkmanager.cfg
|
if [ -f "/etc/arkmanager/arkmanager.cfg" ]; then
|
||||||
|
source /etc/arkmanager/arkmanager.cfg
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "${HOME}/.arkmanager.cfg" ]; then
|
||||||
|
source "${HOME}/.arkmanager.cfg"
|
||||||
|
fi
|
||||||
|
|
||||||
# Local variables
|
# Local variables
|
||||||
info=""
|
info=""
|
||||||
@ -28,27 +35,31 @@ GREEN="\\033[1;32m"
|
|||||||
RED="\\033[1;31m"
|
RED="\\033[1;31m"
|
||||||
NORMAL="\\033[0;39m"
|
NORMAL="\\033[0;39m"
|
||||||
|
|
||||||
|
arkmanagerLog="arkmanager.log" # here are logged the actions performed by arkmanager
|
||||||
|
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
|
||||||
#
|
#
|
||||||
function checkForUpdate(){
|
function checkForUpdate(){
|
||||||
|
tput sc
|
||||||
|
echo "Querying Steam database for latest version..."
|
||||||
|
|
||||||
if isUpdateNeeded; then
|
if isUpdateNeeded; then
|
||||||
echo "Current version:" $instver
|
tput rc; tput ed;
|
||||||
echo "Available version:" $bnumber
|
echo -e "Current version:" "$RED" $instver "$NORMAL"
|
||||||
echo "Your server needs to be restarted in order to receive the latest update."
|
echo -e "Available version:" "$GREEN" $bnumber "$NORMAL"
|
||||||
echo "Run \"arkmanager update\" to do so"
|
echo -e "Your server needs to be restarted in order to receive the latest update."
|
||||||
|
echo -e "Run \"arkmanager update\" to do so"
|
||||||
else
|
else
|
||||||
echo "No update available"
|
tput rc; tput ed;
|
||||||
|
echo -e "Current version:" "$GREEN" $instver "$NORMAL"
|
||||||
|
echo -e "Available version:" "$GREEN" $bnumber "$NORMAL"
|
||||||
|
echo "Your server is up to date!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,7 +67,7 @@ function checkForUpdate(){
|
|||||||
# Set the new current version in a file
|
# Set the new current version in a file
|
||||||
#
|
#
|
||||||
function setCurrentVersion(){
|
function setCurrentVersion(){
|
||||||
cd $arkserverroot
|
cd "$arkserverroot"
|
||||||
echo $bnumber > arkversion
|
echo $bnumber > arkversion
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,22 +86,51 @@ function isUpdateNeeded(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Parse an ACF structure
|
||||||
|
# $1 is the desired path
|
||||||
|
# $2 is the desired property
|
||||||
|
# $3 is the current path
|
||||||
|
#
|
||||||
|
function parseSteamACF(){
|
||||||
|
local sname
|
||||||
|
while read name val; do
|
||||||
|
name="${name#\"}"
|
||||||
|
name="${name%\"}"
|
||||||
|
val="${val#\"}"
|
||||||
|
val="${val%\"}"
|
||||||
|
if [ "$name" = "}" ]; then
|
||||||
|
break
|
||||||
|
elif [ "$name" == "{" ]; then
|
||||||
|
parseSteamACF "$1" "$2" "${3}.${sname}"
|
||||||
|
else
|
||||||
|
if [ "$3" == "$1" -a "$name" == "$2" ]; then
|
||||||
|
echo "$val"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sname="${name}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Return the current version number
|
# Return the current version number
|
||||||
#
|
#
|
||||||
function getCurrentVersion(){
|
function getCurrentVersion(){
|
||||||
cd $arkserverroot
|
if [ -f "${arkserverroot}/steamapps/appmanifest_${appid}.acf" ]; then
|
||||||
touch arkversion # If the file doesn't exist
|
instver=`while read name val; do if [ "${name}" == "{" ]; then parseSteamACF "" "buildid"; break; fi; done <"${arkserverroot}/steamapps/appmanifest_${appid}.acf"`
|
||||||
instver=`cat "arkversion"`
|
else
|
||||||
|
instver=""
|
||||||
|
fi
|
||||||
return $instver
|
return $instver
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Get the current available server version on steamdb
|
# Get the current available server version on steamdb
|
||||||
#
|
#
|
||||||
function getAvailableVersion(){
|
function getAvailableVersion(){
|
||||||
bnumber=`$steamcmdroot/$steamcmdexec +login anonymous +app_info_print "$appid" +quit | grep -EA 5 "^\s+\"public\"$" | grep -E "^\s+\"buildid\"\s+" | tr '[:blank:]"' ' ' | tr -s ' ' | cut -f3 | sed 's/^ //' | cut -c9-14`
|
rm -f "$steamcmd_appinfocache"
|
||||||
|
bnumber=`$steamcmdroot/$steamcmdexec +login anonymous +app_info_update 1 +app_info_print "$appid" +quit | while read name val; do if [ "${name}" == "{" ]; then parseSteamAppVer; break; fi; done`
|
||||||
return $bnumber
|
return $bnumber
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,15 +146,21 @@ function isTheServerRunning(){
|
|||||||
|
|
||||||
#
|
#
|
||||||
# Check if the server is up and visible in steam server list
|
# Check if the server is up and visible in steam server list
|
||||||
# If the server is listenning on his port return 0, else return 1
|
#
|
||||||
#
|
#
|
||||||
function isTheServerUp(){
|
function isTheServerUp(){
|
||||||
lsof -i |grep $arkserverport > /dev/null
|
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
|
||||||
#
|
#
|
||||||
@ -122,11 +168,35 @@ doStart() {
|
|||||||
if isTheServerRunning; then
|
if isTheServerRunning; then
|
||||||
echo "The server is already running"
|
echo "The server is already running"
|
||||||
else
|
else
|
||||||
arkserveropts="TheIsland?SessionName=$sessioname?QueryPort=$arkqueryport?ServerPassword=$arkserverpass?ServerAdminPassword=$arkserverapass?listen"
|
tput sc
|
||||||
thejob="$arkserverroot/$arkserverexec $arkserveropts"
|
echo "The server is starting..."
|
||||||
screen -dmS "$servicename" $thejob
|
|
||||||
echo "$timestamp: start" >> "$logdir/arkserver.log"
|
arkserveropts=$serverMap
|
||||||
tail -n 1 "$logdir/arkserver.log"
|
|
||||||
|
# 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"
|
||||||
|
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;
|
||||||
|
echo "The server is now up"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,11 +205,15 @@ doStart() {
|
|||||||
#
|
#
|
||||||
doStop() {
|
doStop() {
|
||||||
if isTheServerRunning; then
|
if isTheServerRunning; then
|
||||||
|
tput sc
|
||||||
echo "Stopping server..."
|
echo "Stopping server..."
|
||||||
screen -X -S "$servicename" -X stuff "^C"
|
# kill the server with the PID
|
||||||
sleep 10
|
PID=`ps -ef | grep "$arkserverroot/$arkserverexec" | grep -v grep | awk '{print $2}'`
|
||||||
echo "$timestamp: stop" >> "$logdir/arkserver.log"
|
kill -9 $PID
|
||||||
tail -n 1 "$logdir/arkserver.log"
|
|
||||||
|
tput rc; tput ed;
|
||||||
|
echo "The server has been stopped"
|
||||||
|
echo "$timestamp: stop" >> "$logdir/$arkmanagerLog"
|
||||||
else
|
else
|
||||||
echo "The server is already stopped"
|
echo "The server is already stopped"
|
||||||
fi
|
fi
|
||||||
@ -149,10 +223,9 @@ doStop() {
|
|||||||
# install of ARK server
|
# install of ARK server
|
||||||
#
|
#
|
||||||
doInstall() {
|
doInstall() {
|
||||||
if [ ! -d "$arkserverroot" ]; then
|
mkdir -p "$arkserverroot"
|
||||||
mkdir $arkserverroot
|
|
||||||
fi
|
cd "$steamcmdroot"
|
||||||
cd $steamcmdroot
|
|
||||||
# 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
|
||||||
@ -164,46 +237,34 @@ doInstall() {
|
|||||||
# Stop the server, update it and then start it back.
|
# Stop the server, update it and then start it back.
|
||||||
#
|
#
|
||||||
doUpdate() {
|
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
|
|
||||||
cd $logdir
|
|
||||||
echo "$bnumber" > "$arkserverroot/arkversion"
|
|
||||||
cd $steamcmdroot
|
|
||||||
echo "$timestamp: update to $bnumber complete" >> "$logdir/update.log"
|
|
||||||
tail -n 1 "$logdir/arkserver.log"
|
|
||||||
|
|
||||||
# we restart the server only if it was started before the update
|
|
||||||
if [ $serverWasAlive -eq 1 ]; then
|
|
||||||
doStart
|
|
||||||
fi
|
|
||||||
# send mail to admin
|
|
||||||
#if [ -z $servermail ]; then
|
|
||||||
# mail -a $logdir/update.log -s "Update-Log" $servermail < /dev/null
|
|
||||||
#fi
|
|
||||||
else
|
else
|
||||||
echo "No update available"
|
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"
|
||||||
tail -n 1 "$logdir/update.log"
|
|
||||||
fi;
|
fi;
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
forceUpdate(){
|
||||||
# Broadcast message to server
|
# check if the server was alive before the update so we can launch it back after the update
|
||||||
#
|
serverWasAlive=0
|
||||||
doInfo() {
|
if isTheServerRunning ;then
|
||||||
if [ ! -z $1 ]; then
|
serverWasAlive=1
|
||||||
info=$1
|
fi
|
||||||
fi
|
doStop
|
||||||
screen -S "$servicename" -p 0 -X stuff "broadcast $info $(printf \\r)"
|
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
|
||||||
|
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
|
||||||
|
doStart
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -211,19 +272,18 @@ doInfo() {
|
|||||||
#
|
#
|
||||||
printStatus(){
|
printStatus(){
|
||||||
if isTheServerRunning ;then
|
if isTheServerRunning ;then
|
||||||
echo -e "$NORMAL" "Server running:" "$GREEN" "Yes"
|
echo -e "$NORMAL" "Server running: " "$GREEN" "Yes" "$NORMAL"
|
||||||
else
|
else
|
||||||
echo -e "$NORMAL" "Server running:" "$RED" "No"
|
echo -e "$NORMAL" "Server running: " "$RED" "No" "$NORMAL"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if isTheServerUp ;then
|
if isTheServerUp ;then
|
||||||
echo -e "$NORMAL" "Server online:" "$GREEN" " Yes"
|
echo -e "$NORMAL" "Server online: " "$RED" "No" "$NORMAL"
|
||||||
else
|
else
|
||||||
echo -e "$NORMAL" "Server online:" "$RED" " No"
|
echo -e "$NORMAL" "Server online: " "$GREEN" "Yes" "$NORMAL"
|
||||||
fi
|
fi
|
||||||
getCurrentVersion
|
getCurrentVersion
|
||||||
echo -e "$NORMAL" "Server version:" "$GREEN" $instver
|
echo -e "$NORMAL" "Server version: " "$GREEN" $instver "$NORMAL"
|
||||||
echo -e "$NORMAL"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,14 +299,11 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
restart)
|
restart)
|
||||||
doStop
|
doStop
|
||||||
echo "$timestamp: stop" >> "$logdir/arkserver.log"
|
echo "$timestamp: stop" >> "$logdir/$arkmanagerLog"
|
||||||
tail -n 1 "$logdir/arkserver.log"
|
|
||||||
sleep 10
|
sleep 10
|
||||||
doStart
|
doStart
|
||||||
echo "$timestamp: start" >> "$logdir/arkserver.log"
|
echo "$timestamp: start" >> "$logdir/$arkmanagerLog"
|
||||||
tail -n 1 "$logdir/arkserver.log"
|
echo "$timestamp: restart" >> "$logdir/$arkmanagerLog"
|
||||||
echo "$timestamp: restart" >> "$logdir/arkserver.log"
|
|
||||||
tail -n 1 "$logdir/arkserver.log"
|
|
||||||
;;
|
;;
|
||||||
install)
|
install)
|
||||||
doInstall
|
doInstall
|
||||||
@ -255,6 +312,9 @@ case "$1" in
|
|||||||
doUpdate
|
doUpdate
|
||||||
#testfunction
|
#testfunction
|
||||||
;;
|
;;
|
||||||
|
forceupdate)
|
||||||
|
forceUpdate
|
||||||
|
;;
|
||||||
checkupdate)
|
checkupdate)
|
||||||
checkForUpdate
|
checkForUpdate
|
||||||
;;
|
;;
|
||||||
@ -264,7 +324,21 @@ case "$1" in
|
|||||||
status)
|
status)
|
||||||
printStatus
|
printStatus
|
||||||
;;
|
;;
|
||||||
|
-h|--help)
|
||||||
|
echo -e "Usage: arkmanager [OPTION]\n"
|
||||||
|
echo "Option Description"
|
||||||
|
echo "start Starts the server"
|
||||||
|
echo "stop Stops the server"
|
||||||
|
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"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "use arkmanager <start|stop|restart|install|update|broadcast|status>"
|
echo "arkmanager: no command specified"
|
||||||
|
echo "Try 'arkmanager -h' or 'arkmanager --help' for more information."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@ -2,15 +2,22 @@
|
|||||||
steamcmdroot="/home/steam/steamcmd" # path of your steamcmd instance
|
steamcmdroot="/home/steam/steamcmd" # path of your steamcmd instance
|
||||||
steamcmdexec="steamcmd.sh" # name of steamcmd executable
|
steamcmdexec="steamcmd.sh" # name of steamcmd executable
|
||||||
steamcmd_user="steam" # name of the system user who own steamcmd folder
|
steamcmd_user="steam" # name of the system user who own steamcmd folder
|
||||||
|
steamcmd_appinfocache="/home/steam/Steam/appinfo.vdf" # cache of the appinfo command
|
||||||
|
|
||||||
# config Server
|
# config environment
|
||||||
sessioname=YourLinuxSessionName
|
|
||||||
arkserverroot="/home/steam/ARK" # path of your ARK server files (default ~/ARK)
|
arkserverroot="/home/steam/ARK" # path of your ARK server files (default ~/ARK)
|
||||||
arkserverexec="ShooterGame/Binaries/Linux/ShooterGameServer" # name of ARK server executable
|
arkserverexec="ShooterGame/Binaries/Linux/ShooterGameServer" # name of ARK server executable
|
||||||
arkqueryport="27016" # ARK query port (default 27016)
|
|
||||||
arkserverport="7778" # ARK server port (default 7778)
|
# ARK server options - use ark_<optionname>=<value>
|
||||||
arkserverpass="SERVERPASSWORD" # ARK server password, empty: no password required to login
|
# comment out these values if you want to define them
|
||||||
arkserverapass="ADMINPASSWORD" # ARK server admin password, KEEP IT SAFE!
|
# inside your GameUserSettings.ini file
|
||||||
|
serverMap="TheIsland" # server map (default TheIsland)
|
||||||
|
ark_SessionName="ARK Server Tools" # if your session name needs special characters please use the .ini instead
|
||||||
|
ark_Port="7778" # ARK server port (default 7778)
|
||||||
|
ark_QueryPort="27016" # ARK query port (default 27016)
|
||||||
|
ark_ServerPassword="" # ARK server password, empty: no password required to login
|
||||||
|
ark_ServerAdminPassword="keyboardcat" # ARK server admin password, KEEP IT SAFE!
|
||||||
|
ark_MaxPlayers="70"
|
||||||
|
|
||||||
# config Service
|
# config Service
|
||||||
servicename="arkserv" # Name of the service (don't change if you don't know what are you doing)
|
servicename="arkserv" # Name of the service (don't change if you don't know what are you doing)
|
||||||
|
|||||||
101
tools/install.sh
Normal file → Executable file
101
tools/install.sh
Normal file → Executable file
@ -1,26 +1,97 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ ! -z $1 ]; then
|
EXECPREFIX="${EXECPREFIX:-/usr/local}"
|
||||||
# Copy arkmanager to /usr/bin and set permissions
|
|
||||||
cp arkmanager /usr/bin/arkmanager
|
|
||||||
chmod +x /usr/bin/arkmanager
|
|
||||||
|
|
||||||
# Copy arkdaemon to /etc/init.d and set permissions
|
if [ ! -z "$1" ]; then
|
||||||
cp arkdaemon /etc/init.d/arkdaemon
|
# Copy arkmanager to /usr/bin and set permissions
|
||||||
chmod +x /etc/init.d/arkdaemon
|
cp arkmanager "${INSTALL_ROOT}${EXECPREFIX}/bin/arkmanager"
|
||||||
|
chmod +x "${INSTALL_ROOT}${EXECPREFIX}/bin/arkmanager"
|
||||||
|
|
||||||
|
# Copy arkdaemon to /etc/init.d ,set permissions and add it to boot
|
||||||
|
if [ -f /lib/lsb/init-functions ]; 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
|
||||||
|
mkdir -p "${INSTALL_ROOT}${EXECPREFIX}/libexec/arkmanager"
|
||||||
|
cp lsb/arkdaemon "${INSTALL_ROOT}${EXECPREFIX}/libexec/arkmanager/arkmanager.init"
|
||||||
|
chmod +x "${INSTALL_ROOT}${EXECPREFIX}/libexec/arkmanager/arkmanager.init"
|
||||||
|
cp systemd/arkdeamon.service "${INSTALL_ROOT}/etc/systemd/system/arkmanager.service"
|
||||||
|
sed -i "s|=/usr/|=${EXECPREFIX}/|" "${INSTALL_ROOT}/etc/systemd/system/arkmanager.service"
|
||||||
|
if [ -z "${INSTALL_ROOT}" ]; then
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable arkmanager.service
|
||||||
|
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
|
||||||
|
echo "systemctl disable arkmanager.service"
|
||||||
|
fi
|
||||||
|
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
|
||||||
|
# on RHEL 7, 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
|
||||||
|
mkdir -p "${INSTALL_ROOT}${EXECPREFIX}/libexec/arkmanager"
|
||||||
|
cp redhat/arkdaemon "${INSTALL_ROOT}${EXECPREFIX}/libexec/arkmanager/arkmanager.init"
|
||||||
|
chmod +x "${INSTALL_ROOT}${EXECPREFIX}/libexec/arkmanager/arkmanager.init"
|
||||||
|
cp systemd/arkdeamon.service "${INSTALL_ROOT}/etc/systemd/system/arkmanager.service"
|
||||||
|
sed -i "s|=/usr/|=${EXECPREFIX}/|" "${INSTALL_ROOT}/etc/systemd/system/arkmanager.service"
|
||||||
|
if [ -z "${INSTALL_ROOT}" ]; then
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable arkmanager.service
|
||||||
|
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
|
||||||
|
echo "systemctl disable arkmanager.service"
|
||||||
|
fi
|
||||||
|
else # systemd not preset, so use sysvinit
|
||||||
|
cp redhat/arkdaemon "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager"
|
||||||
|
chmod +x "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager"
|
||||||
|
sed -i "s@^DAEMON=\"/usr@DAEMON=\"${EXECPREFIX}@" "${INSTALL_ROOT}/etc/rc.d/init.d/arkmanager"
|
||||||
|
if [ -x /sbin/chkconfig -a -z "${INSTALL_ROOT}" ]; then
|
||||||
|
chkconfig --add arkmanager
|
||||||
|
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
|
||||||
|
echo "chkconfig arkmanager off"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
elif [ -f /sbin/runscript ]; then
|
||||||
|
cp openrc/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"
|
||||||
|
if [ -x /sbin/rc-update -a -z "${INSTALL_ROOT}" ]; then
|
||||||
|
rc-update add arkmanager default
|
||||||
|
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 [ -f /etc/systemd/system.conf ]; then # used by systemd
|
||||||
|
mkdir -p "${INSTALL_ROOT}${EXECPREFIX}/libexec/arkmanager"
|
||||||
|
cp systemd/arkdaemon.init "${INSTALL_ROOT}${EXECPREFIX}/libexec/arkmanager/arkmanager.init"
|
||||||
|
chmod +x "${INSTALL_ROOT}${EXECPREFIX}/libexec/arkmanager/arkmanager.init"
|
||||||
|
cp systemd/arkdeamon.service "${INSTALL_ROOT}/etc/systemd/system/arkmanager.service"
|
||||||
|
sed -i "s|=/usr/|=${EXECPREFIX}/|" "${INSTALL_ROOT}/etc/systemd/system/arkmanager.service"
|
||||||
|
if [ -z "${INSTALL_ROOT}" ]; then
|
||||||
|
systemctl enable arkmanager.service
|
||||||
|
echo "Ark server will now start on boot, if you want to remove this feature run the following line"
|
||||||
|
echo "systemctl disable arkmanager.service"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Create a folder in /var/log to let Ark tools write its own log files
|
# Create a folder in /var/log to let Ark tools write its own log files
|
||||||
mkdir -p /var/log/arktools
|
mkdir -p "${INSTALL_ROOT}/var/log/arktools"
|
||||||
chown $1 /var/log/arktools
|
chown "$1" "${INSTALL_ROOT}/var/log/arktools"
|
||||||
|
|
||||||
# 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
|
||||||
if [ ! -f /etc/arkmanager/arkmanager.cfg ]; then
|
mkdir -p "${INSTALL_ROOT}/etc/arkmanager"
|
||||||
mkdir -p /etc/arkmanager
|
if [ -f "${INSTALL_ROOT}/etc/arkmanager/arkmanager.cfg" ]; then
|
||||||
cp -n arkmanager.cfg /etc/arkmanager/arkmanager.cfg
|
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."
|
||||||
chown $1 /etc/arkmanager/arkmanager.cfg
|
exit 2
|
||||||
else
|
else
|
||||||
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.";
|
cp -n arkmanager.cfg "${INSTALL_ROOT}/etc/arkmanager/arkmanager.cfg"
|
||||||
exit 2
|
chown "$1" "${INSTALL_ROOT}/etc/arkmanager/arkmanager.cfg"
|
||||||
|
sed -i "s|^steamcmd_user=\"steam\"|steamcmd_user=\"$1\"|;s|\"/home/steam|\"/home/$1|" "${INSTALL_ROOT}/etc/arkmanager/arkmanager.cfg"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
#!/bin/bash
|
||||||
### BEGIN INIT INFO
|
### BEGIN INIT INFO
|
||||||
# Provides: ARK manager deamon
|
# Provides: ARK manager deamon
|
||||||
# Required-Start: networking
|
# Required-Start: networking
|
||||||
@ -27,9 +28,11 @@ test -x $DAEMON || exit 5
|
|||||||
case "$1" in
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
log_daemon_msg "Starting" "$NAME"
|
log_daemon_msg "Starting" "$NAME"
|
||||||
sudo -u $steamcmd_user $DAEMON start
|
su -s /bin/sh -c "$DAEMON start" $steamcmd_user
|
||||||
|
sleep 5
|
||||||
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`
|
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`
|
||||||
if [ -n "$PID" ]; then
|
if [ -n "$PID" ]; then
|
||||||
|
echo "$PID" >/var/run/arkmanager.pid
|
||||||
log_end_msg 0
|
log_end_msg 0
|
||||||
else
|
else
|
||||||
log_end_msg 1
|
log_end_msg 1
|
||||||
@ -38,21 +41,23 @@ case "$1" in
|
|||||||
|
|
||||||
stop)
|
stop)
|
||||||
log_daemon_msg "Stopping" "$NAME"
|
log_daemon_msg "Stopping" "$NAME"
|
||||||
sudo -u $steamcmd_user $DAEMON stop
|
su -s /bin/sh -c "$DAEMON stop" $steamcmd_user
|
||||||
|
sleep 5
|
||||||
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`
|
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`
|
||||||
if [ -n "$PID" ]; then
|
if [ -n "$PID" ]; then
|
||||||
log_end_msg 1
|
log_end_msg 1
|
||||||
else
|
else
|
||||||
|
rm /var/run/arkmanager.pid
|
||||||
log_end_msg 0
|
log_end_msg 0
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
restart)
|
restart)
|
||||||
sudo -u $steamcmd_user $DAEMON restart
|
su -s /bin/sh -c "$DAEMON restart" $steamcmd_user
|
||||||
;;
|
;;
|
||||||
|
|
||||||
status)
|
status)
|
||||||
sudo -u $steamcmd_user $DAEMON status
|
su -s /bin/sh -c "$DAEMON status" $steamcmd_user
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
38
tools/openrc/arkdaemon
Normal file
38
tools/openrc/arkdaemon
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/sbin/runscript
|
||||||
|
# Short-Description: ARK manager deamon
|
||||||
|
# Description: ARK manager daemon used to start the server and keep it updated
|
||||||
|
|
||||||
|
source /etc/arkmanager/arkmanager.cfg
|
||||||
|
|
||||||
|
NAME="ShooterGameServer"
|
||||||
|
LOGFILE="${logdir}/${NAME}.log"
|
||||||
|
DAEMON="/usr/bin/arkmanager"
|
||||||
|
|
||||||
|
depend(){
|
||||||
|
require net
|
||||||
|
}
|
||||||
|
|
||||||
|
start(){
|
||||||
|
ebegin "Starting ARK manager daemon"
|
||||||
|
su -s /bin/sh -c "$DAEMON start" $steamcmd_user
|
||||||
|
sleep 5
|
||||||
|
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`
|
||||||
|
if [ -n "$PID" ]; then
|
||||||
|
eend 0
|
||||||
|
else
|
||||||
|
eend 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
stop(){
|
||||||
|
ebegin "Stopping ARK manager daemon"
|
||||||
|
su -s /bin/sh -c "$DAEMON start" $steamcmd_user
|
||||||
|
sleep 5
|
||||||
|
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`
|
||||||
|
if [ -n "$PID" ]; then
|
||||||
|
eend 0
|
||||||
|
else
|
||||||
|
eend 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
91
tools/redhat/arkdaemon
Executable file
91
tools/redhat/arkdaemon
Executable file
@ -0,0 +1,91 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# /etc/rc.d/init.d/arkmanager
|
||||||
|
#
|
||||||
|
# ARK manager daemon
|
||||||
|
#
|
||||||
|
# chkconfig: 2345 80 20
|
||||||
|
# description: ARK manager daemon used to start the server and keep it updated
|
||||||
|
# processname: ShooterGameServer
|
||||||
|
# config: /etc/arkmanager/arkmanager.cfg
|
||||||
|
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: ARK manager deamon
|
||||||
|
# Required-Start: networking
|
||||||
|
# Required-Stop: networking
|
||||||
|
# Default-Start: 2 3 4 5
|
||||||
|
# Default-Stop: 0 1 6
|
||||||
|
# Short-Description: ARK manager deamon
|
||||||
|
# Description: ARK manager daemon used to start the server and keep it updated
|
||||||
|
#
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
# Using the lsb functions to perform the operations.
|
||||||
|
. /etc/rc.d/init.d/functions
|
||||||
|
|
||||||
|
# Global variables
|
||||||
|
source /etc/arkmanager/arkmanager.cfg
|
||||||
|
|
||||||
|
NAME="ShooterGameServer"
|
||||||
|
LOGFILE="${logdir}/${NAME}.log"
|
||||||
|
DAEMON="/usr/bin/arkmanager"
|
||||||
|
|
||||||
|
GREEN="\\033[1;32m"
|
||||||
|
RED="\\033[1;31m"
|
||||||
|
NORMAL="\\033[0;39m"
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# If the daemon is not there, then exit.
|
||||||
|
test -x $DAEMON || exit 5
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
echo -n "Starting $NAME: "
|
||||||
|
su -s /bin/sh -c "$DAEMON start" $steamcmd_user > /dev/null
|
||||||
|
sleep 5
|
||||||
|
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`
|
||||||
|
if [ -n "$PID" ]; then
|
||||||
|
echo "${PID}" >/var/run/arkmanager.pid
|
||||||
|
touch /var/lock/subsys/arkmanager
|
||||||
|
echo "[" "$GREEN" " OK " "$NORMAL" "]"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "[" "$RED" " FAILED " "$NORMAL" "]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
stop)
|
||||||
|
echo -n "Stopping $NAME: "
|
||||||
|
su -s /bin/sh -c "$DAEMON stop" $steamcmd_user > /dev/null
|
||||||
|
sleep 5
|
||||||
|
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`
|
||||||
|
if [ -n "$PID" ]; then
|
||||||
|
echo "[" "$RED" " FAILED " "$NORMAL" "]"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "[" "$GREEN" " OK " "$NORMAL" "]"
|
||||||
|
rm -f /var/lock/subsys/arkmanager
|
||||||
|
rm -f /var/run/arkmanager.pid
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
restart)
|
||||||
|
echo -n "Restarting $NAME: "
|
||||||
|
su -s /bin/sh -c "$DAEMON restart" $steamcmd_user > /dev/null
|
||||||
|
echo "OK"
|
||||||
|
;;
|
||||||
|
|
||||||
|
status)
|
||||||
|
su -s /bin/sh -c "$DAEMON status" $steamcmd_user
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
# For invalid arguments, print the usage message.
|
||||||
|
echo "Usage: $0 {start|stop|restart|status}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
86
tools/systemd/arkdaemon.init
Executable file
86
tools/systemd/arkdaemon.init
Executable file
@ -0,0 +1,86 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# /usr/libexec/arkmanager/arkmanager.init
|
||||||
|
#
|
||||||
|
# ARK manager daemon
|
||||||
|
#
|
||||||
|
# chkconfig: 2345 80 20
|
||||||
|
# description: ARK manager daemon used to start the server and keep it updated
|
||||||
|
# processname: ShooterGameServer
|
||||||
|
# config: /etc/arkmanager/arkmanager.cfg
|
||||||
|
|
||||||
|
### BEGIN INIT INFO
|
||||||
|
# Provides: ARK manager deamon
|
||||||
|
# Required-Start: networking
|
||||||
|
# Required-Stop: networking
|
||||||
|
# Default-Start: 2 3 4 5
|
||||||
|
# Default-Stop: 0 1 6
|
||||||
|
# Short-Description: ARK manager deamon
|
||||||
|
# Description: ARK manager daemon used to start the server and keep it updated
|
||||||
|
#
|
||||||
|
### END INIT INFO
|
||||||
|
|
||||||
|
# Global variables
|
||||||
|
source /etc/arkmanager/arkmanager.cfg
|
||||||
|
|
||||||
|
NAME="ShooterGameServer"
|
||||||
|
LOGFILE="${logdir}/${NAME}.log"
|
||||||
|
DAEMON="/usr/bin/arkmanager"
|
||||||
|
|
||||||
|
GREEN="\\033[1;32m"
|
||||||
|
RED="\\033[1;31m"
|
||||||
|
NORMAL="\\033[0;39m"
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# If the daemon is not there, then exit.
|
||||||
|
test -x $DAEMON || exit 5
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
start)
|
||||||
|
echo -n "Starting $NAME: "
|
||||||
|
su -s /bin/sh -c "$DAEMON start" $steamcmd_user > /dev/null
|
||||||
|
sleep 5
|
||||||
|
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`
|
||||||
|
if [ -n "$PID" ]; then
|
||||||
|
echo "$PID" >/var/run/arkmanager.pid
|
||||||
|
echo "[" "$GREEN" " OK " "$NORMAL" "]"
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "[" "$RED" " FAILED " "$NORMAL" "]"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
stop)
|
||||||
|
echo -n "Stopping $NAME: "
|
||||||
|
su -s /bin/sh -c "$DAEMON stop" $steamcmd_user > /dev/null
|
||||||
|
sleep 5
|
||||||
|
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`
|
||||||
|
if [ -n "$PID" ]; then
|
||||||
|
echo "[" "$RED" " FAILED " "$NORMAL" "]"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "[" "$GREEN" " OK " "$NORMAL" "]"
|
||||||
|
rm /var/run/arkmanager.pid
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
|
restart)
|
||||||
|
echo -n "Restarting $NAME: "
|
||||||
|
su -s /bin/sh -c "$DAEMON restart" $steamcmd_user > /dev/null
|
||||||
|
echo "OK"
|
||||||
|
;;
|
||||||
|
|
||||||
|
status)
|
||||||
|
su -s /bin/sh -c "$DAEMON status" $steamcmd_user
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
# For invalid arguments, print the usage message.
|
||||||
|
echo "Usage: $0 {start|stop|restart|status}"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
12
tools/systemd/arkdeamon.service
Normal file
12
tools/systemd/arkdeamon.service
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Daemon to start ark server
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/usr/libexec/arkmanager/arkmanager.init start
|
||||||
|
ExecStop=/usr/libexec/arkmanager/arkmanager.init stop
|
||||||
|
Type=forking
|
||||||
|
PIDFile=/var/run/arkmanager.pid
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
Loading…
x
Reference in New Issue
Block a user