-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrestart.sh
More file actions
executable file
·46 lines (43 loc) · 1.09 KB
/
restart.sh
File metadata and controls
executable file
·46 lines (43 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
#
# Usage:
# ./restart.sh [update]
#
# This script stops all DST server processes, waits for them to exit, optionally updates, and restarts the servers.
# Loop to check if processes have exited
wait_process_exit() {
local remain_sleep=$1
local each_sleep=$2
for pid in $pids; do
while kill -0 ${pid} >/dev/null 2>&1; do
if [ $remain_sleep -le 0 ]; then
return 1
fi
get_msg process_waiting "${each_sleep}" "${remain_sleep}"
sleep $each_sleep
((remain_sleep -= $each_sleep))
done
done
return 0
}
cd $(dirname $0)
bin=$(pwd)
. scripts/lang.sh
cd ~/$DST_SCRIPT_PATH
sh stop.sh
pids=$(cat .lastpid | awk '{print $1}')
get_msg waiting_exit
wait_process_exit 60 5
if [ $? -ne 0 ]; then
get_msg stop_timeout
sh stop.sh 9
get_msg waiting_exit_forcibly
wait_process_exit 60 5
get_msg process_exited
fi
update=${1:-0}
if [ $update -eq 1 ]; then
get_msg updating_server
sh scripts/setup-dst.sh $STEAMCMD_PATH $DST_SCRIPT_PATH $DST_SERVER_PATH $DST_GAME_ID
fi
sh start.sh