mirror of
https://github.com/eliasstepanik/ark-ac-server-tools.git
synced 2026-01-15 12:08:26 +00:00
Merge remote-tracking branch 'upstream/dev#1.1' into dev#1.1
This commit is contained in:
commit
01c35b4745
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.
|
||||
38
README.md
38
README.md
@ -10,6 +10,8 @@ We assume you have created the `steam` user to store steamcmd and your ARK serve
|
||||
|
||||
## Requirements
|
||||
|
||||
### Increase max open files
|
||||
|
||||
Edit /etc/sysctl.conf and set:
|
||||
```
|
||||
fs.file-max=100000
|
||||
@ -26,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.
|
||||
|
||||
### 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
|
||||
|
||||
To install ARK Server Tools run this command:
|
||||
|
||||
```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`.
|
||||
|
||||
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
|
||||
|
||||
@ -51,6 +79,8 @@ arkmanager install
|
||||
```
|
||||
## Commands
|
||||
|
||||
To get a complete list of the script commands you can run `arkmanager --help` or `arkmanager -h`.
|
||||
|
||||
#### arkmanager install
|
||||
installs arkmanager to the directory specified in `.arkmanager.cfg`
|
||||
|
||||
|
||||
139
tools/arkmanager
139
tools/arkmanager
@ -3,7 +3,8 @@
|
||||
# ARK: survival evolved manager
|
||||
#
|
||||
# Original author: LeXaT
|
||||
# Maintainer: FezVrasta, Sispheor
|
||||
# Maintainer: FezVrasta
|
||||
# Contributors: Sispheor, Atriusftw, lexat, puseidr
|
||||
|
||||
# Check the user is not currently running this script as root
|
||||
if [ "$(id -u)" == "0" ]; then
|
||||
@ -16,7 +17,13 @@ fi
|
||||
#---------------------
|
||||
|
||||
# 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
|
||||
info=""
|
||||
@ -28,6 +35,9 @@ GREEN="\\033[1;32m"
|
||||
RED="\\033[1;31m"
|
||||
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
|
||||
#---------------------
|
||||
@ -43,12 +53,16 @@ function testfunction(){
|
||||
#
|
||||
function checkForUpdate(){
|
||||
if isUpdateNeeded; then
|
||||
echo "Current version:" $instver
|
||||
echo "Available version:" $bnumber
|
||||
echo "Your server needs to be restarted in order to receive the latest update."
|
||||
echo "Run \"arkmanager update\" to do so"
|
||||
tput rc; tput ed;
|
||||
echo -e "Current version:" "$RED" $instver "$NORMAL"
|
||||
echo -e "Available version:" "$GREEN" $bnumber "$NORMAL"
|
||||
echo -e "Your server needs to be restarted in order to receive the latest update."
|
||||
echo -e "Run \"arkmanager update\" to do so"
|
||||
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
|
||||
}
|
||||
|
||||
@ -56,7 +70,7 @@ function checkForUpdate(){
|
||||
# Set the new current version in a file
|
||||
#
|
||||
function setCurrentVersion(){
|
||||
cd $arkserverroot
|
||||
cd "$arkserverroot"
|
||||
echo $bnumber > arkversion
|
||||
}
|
||||
|
||||
@ -79,7 +93,7 @@ function isUpdateNeeded(){
|
||||
# Return the current version number
|
||||
#
|
||||
function getCurrentVersion(){
|
||||
cd $arkserverroot
|
||||
cd "$arkserverroot"
|
||||
touch arkversion # If the file doesn't exist
|
||||
instver=`cat "arkversion"`
|
||||
return $instver
|
||||
@ -105,11 +119,10 @@ function isTheServerRunning(){
|
||||
}
|
||||
|
||||
#
|
||||
# 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
|
||||
# Check if the server is down and not visible in steam server list
|
||||
#
|
||||
function isTheServerUp(){
|
||||
lsof -i |grep $arkserverport > /dev/null
|
||||
function isTheServerDown(){
|
||||
lsof -i |grep $ark_Port > /dev/null
|
||||
result=$?
|
||||
return $result
|
||||
}
|
||||
@ -122,11 +135,35 @@ doStart() {
|
||||
if isTheServerRunning; then
|
||||
echo "The server is already running"
|
||||
else
|
||||
arkserveropts="TheIsland?SessionName=$sessioname?QueryPort=$arkqueryport?ServerPassword=$arkserverpass?ServerAdminPassword=$arkserverapass?listen"
|
||||
thejob="$arkserverroot/$arkserverexec $arkserveropts"
|
||||
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
|
||||
$thejob >/dev/null 2>&1 &
|
||||
echo "$timestamp: start" >> "$logdir/arkserver.log"
|
||||
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
|
||||
}
|
||||
|
||||
@ -135,11 +172,15 @@ doStart() {
|
||||
#
|
||||
doStop() {
|
||||
if isTheServerRunning; then
|
||||
tput sc
|
||||
echo "Stopping server..."
|
||||
# kill the server with the PID
|
||||
PID=`ps -ef | grep "$arkserverroot/$arkserverexec" | grep -v grep | awk '{print $2}'`
|
||||
kill -9 $PID
|
||||
echo "$timestamp: stop" >> "$logdir/arkserver.log"
|
||||
|
||||
tput rc; tput ed;
|
||||
echo "The server has been stopped"
|
||||
echo "$timestamp: stop" >> "$logdir/$arkmanagerLog"
|
||||
else
|
||||
echo "The server is already stopped"
|
||||
fi
|
||||
@ -149,20 +190,9 @@ doStop() {
|
||||
# install of ARK server
|
||||
#
|
||||
doInstall() {
|
||||
mkdir -p $arkserverroot
|
||||
mkdir -p "$arkserverroot"
|
||||
|
||||
# Check if steamcmd is installed, and if not, install it
|
||||
if [ ! -e $steamcmdroot/$steamcmdexec ]; then
|
||||
mkdir -p $steamcmdroot
|
||||
cd /tmp
|
||||
wget http://media.steampowered.com/installer/steamcmd_linux.tar.gz
|
||||
tar -xvzf steamcmd_linux.tar.gz -C $steamcmdroot
|
||||
cd $steamcmdroot
|
||||
./steamcmd.sh +quit
|
||||
echo "SteamCMD was installed in $steamcmdroot"
|
||||
fi
|
||||
|
||||
cd $steamcmdroot
|
||||
cd "$steamcmdroot"
|
||||
# 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
|
||||
@ -174,7 +204,7 @@ doInstall() {
|
||||
# Stop the server, update it and then start it back.
|
||||
#
|
||||
doUpdate() {
|
||||
cd $arkserverroot
|
||||
cd "$arkserverroot"
|
||||
|
||||
if isUpdateNeeded; then
|
||||
# check if the server was alive before the update so we can launch it back after the update
|
||||
@ -183,11 +213,9 @@ doUpdate() {
|
||||
serverWasAlive=1
|
||||
fi
|
||||
doStop
|
||||
cd $steamcmdroot
|
||||
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"
|
||||
|
||||
# we restart the server only if it was started before the update
|
||||
@ -195,9 +223,8 @@ doUpdate() {
|
||||
doStart
|
||||
fi
|
||||
else
|
||||
echo "No update available"
|
||||
echo "$timestamp: No update needed." >> "$logdir/update.log"
|
||||
tail -n 1 "$logdir/update.log"
|
||||
echo "Your server is already up to date! The most recent version is ${bnumber}."
|
||||
echo "$timestamp: No update needed." >> "$logdir/update.log"
|
||||
fi;
|
||||
}
|
||||
|
||||
@ -206,19 +233,18 @@ doUpdate() {
|
||||
#
|
||||
printStatus(){
|
||||
if isTheServerRunning ;then
|
||||
echo -e "$NORMAL" "Server running:" "$GREEN" "Yes"
|
||||
echo -e "$NORMAL" "Server running: " "$GREEN" "Yes" "$NORMAL"
|
||||
else
|
||||
echo -e "$NORMAL" "Server running:" "$RED" "No"
|
||||
echo -e "$NORMAL" "Server running: " "$RED" "No" "$NORMAL"
|
||||
fi
|
||||
|
||||
if isTheServerUp ;then
|
||||
echo -e "$NORMAL" "Server online:" "$GREEN" " Yes"
|
||||
if isTheServerDown ;then
|
||||
echo -e "$NORMAL" "Server online: " "$RED" "No" "$NORMAL"
|
||||
else
|
||||
echo -e "$NORMAL" "Server online:" "$RED" " No"
|
||||
echo -e "$NORMAL" "Server online: " "$GREEN" "Yes" "$NORMAL"
|
||||
fi
|
||||
getCurrentVersion
|
||||
echo -e "$NORMAL" "Server version:" "$GREEN" $instver
|
||||
echo -e "$NORMAL"
|
||||
echo -e "$NORMAL" "Server version: " "$GREEN" $instver "$NORMAL"
|
||||
|
||||
}
|
||||
|
||||
@ -234,11 +260,11 @@ case "$1" in
|
||||
;;
|
||||
restart)
|
||||
doStop
|
||||
echo "$timestamp: stop" >> "$logdir/arkserver.log"
|
||||
echo "$timestamp: stop" >> "$logdir/$arkmanagerLog"
|
||||
sleep 10
|
||||
doStart
|
||||
echo "$timestamp: start" >> "$logdir/arkserver.log"
|
||||
echo "$timestamp: restart" >> "$logdir/arkserver.log"
|
||||
echo "$timestamp: start" >> "$logdir/$arkmanagerLog"
|
||||
echo "$timestamp: restart" >> "$logdir/$arkmanagerLog"
|
||||
;;
|
||||
install)
|
||||
doInstall
|
||||
@ -248,6 +274,8 @@ case "$1" in
|
||||
#testfunction
|
||||
;;
|
||||
checkupdate)
|
||||
tput sc
|
||||
echo "Querying Steam database for latest version..."
|
||||
checkForUpdate
|
||||
;;
|
||||
broadcast)
|
||||
@ -256,7 +284,20 @@ case "$1" in
|
||||
status)
|
||||
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 "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
|
||||
|
||||
@ -3,14 +3,20 @@ steamcmdroot="/home/steam/steamcmd" # path of yo
|
||||
steamcmdexec="steamcmd.sh" # name of steamcmd executable
|
||||
steamcmd_user="steam" # name of the system user who own steamcmd folder
|
||||
|
||||
# config Server
|
||||
sessioname=YourLinuxSessionName
|
||||
# config environment
|
||||
arkserverroot="/home/steam/ARK" # path of your ARK server files (default ~/ARK)
|
||||
arkserverexec="ShooterGame/Binaries/Linux/ShooterGameServer" # name of ARK server executable
|
||||
arkqueryport="27016" # ARK query port (default 27016)
|
||||
arkserverport="7778" # ARK server port (default 7778)
|
||||
arkserverpass="SERVERPASSWORD" # ARK server password, empty: no password required to login
|
||||
arkserverapass="ADMINPASSWORD" # ARK server admin password, KEEP IT SAFE!
|
||||
|
||||
# ARK server options - use ark_<optionname>=<value>
|
||||
# comment out these values if you want to define them
|
||||
# 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
|
||||
servicename="arkserv" # Name of the service (don't change if you don't know what are you doing)
|
||||
|
||||
@ -1,31 +1,55 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ ! -z $1 ]; then
|
||||
EXECPREFIX="${EXECPREFIX:-/usr/local}"
|
||||
|
||||
if [ ! -z "$1" ]; then
|
||||
# Copy arkmanager to /usr/bin and set permissions
|
||||
cp arkmanager /usr/bin/arkmanager
|
||||
chmod +x /usr/bin/arkmanager
|
||||
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
|
||||
cp arkdaemon /etc/init.d/arkdaemon
|
||||
chmod +x /etc/init.d/arkdaemon
|
||||
# add to startup if the system use sysinit
|
||||
if [ -x /usr/sbin/update-rc.d ]; then
|
||||
update-rc.d arkdaemon 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 arkdaemon remove"
|
||||
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
|
||||
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
|
||||
elif [ -f /etc/rc.d/init.d/functions ]; then
|
||||
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/bin@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
|
||||
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/bin@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
|
||||
fi
|
||||
|
||||
# Create a folder in /var/log to let Ark tools write its own log files
|
||||
mkdir -p /var/log/arktools
|
||||
chown $1 /var/log/arktools
|
||||
mkdir -p "${INSTALL_ROOT}/var/log/arktools"
|
||||
chown "$1" "${INSTALL_ROOT}/var/log/arktools"
|
||||
|
||||
# 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"
|
||||
if [ -f "${INSTALL_ROOT}/etc/arkmanager/arkmanager.cfg" ]; then
|
||||
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."
|
||||
exit 2
|
||||
else
|
||||
cp -n arkmanager.cfg /etc/arkmanager/arkmanager.cfg
|
||||
chown $1 /etc/arkmanager/arkmanager.cfg
|
||||
cp -n arkmanager.cfg "${INSTALL_ROOT}/etc/arkmanager/arkmanager.cfg"
|
||||
chown "$1" "${INSTALL_ROOT}/etc/arkmanager/arkmanager.cfg"
|
||||
fi
|
||||
|
||||
else
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
84
tools/redhat/arkdaemon
Executable file
84
tools/redhat/arkdaemon
Executable file
@ -0,0 +1,84 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# /etc/rc.d/init.d/arkdaemon
|
||||
#
|
||||
# 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"
|
||||
|
||||
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
|
||||
sleep 5
|
||||
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`
|
||||
if [ -n "$PID" ]; then
|
||||
touch /var/lock/subsys/arkdaemon
|
||||
echo "OK"
|
||||
exit 0
|
||||
else
|
||||
echo "Failed"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
stop)
|
||||
echo -n "Stopping $NAME: "
|
||||
su -s /bin/sh -c "$DAEMON stop" $steamcmd_user
|
||||
sleep 5
|
||||
PID=`ps -ef | grep $NAME | grep -v grep | awk '{print $2}'`
|
||||
if [ -n "$PID" ]; then
|
||||
echo "Failed"
|
||||
exit 1
|
||||
else
|
||||
echo "OK"
|
||||
rm -f /var/lock/subsys/arkdaemon
|
||||
exit 0
|
||||
fi
|
||||
;;
|
||||
|
||||
restart)
|
||||
su -s /bin/sh -c "$DAEMON restart" $steamcmd_user
|
||||
exit 0
|
||||
;;
|
||||
|
||||
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
|
||||
Loading…
x
Reference in New Issue
Block a user