-
Notifications
You must be signed in to change notification settings - Fork 7
/
init-freeciv-web.sh
executable file
·61 lines (50 loc) · 1.41 KB
/
init-freeciv-web.sh
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /bin/bash
# starts freeciv-proxy and freeciv-web.
# This script is started by civlauncher.py in publite2.
if [ "$#" -ne 6 ]; then
echo "init-freeciv-web.sh error: incorrect number of parameters." >&2
exit 1
fi
declare -a args
addArgs() {
local i=${#args[*]}
for v in "$@"; do
args[i]=${v}
let i++
done
}
echo "init-freeciv-web.sh port ${2}"
addArgs --debug 1
addArgs --port "${2}"
addArgs --Announce none
addArgs --exit-on-end
addArgs --meta --keep --Metaserver "http://${4}"
addArgs --type "${5}"
addArgs --read "pubscript_${6}.serv"
addArgs --log "../logs/freeciv-web-log-${2}.log"
if [ "$5" = "pbem" ]; then
addArgs --Ranklog "/var/lib/tomcat9/webapps/data/ranklogs/rank_${2}.log"
fi
savesdir=${1}
if [ "$5" = "longturn" ]; then
savesdir="${savesdir}/lt/${6}"
mkdir -p "${savesdir}"
grep -q '^#\s*autoreload\s*$' "pubscript_${6}.serv"
if [ $? -eq 0 ]; then
lastsave=$(ls -t "${savesdir}" | head -n 1)
if [ -n "${lastsave}" ]; then
addArgs --file "${lastsave%.*}"
fi
fi
else
addArgs --quitidle 20
fi
addArgs --saves "${savesdir}"
export FREECIV_SAVE_PATH=${savesdir};
rm -f "/var/lib/tomcat9/webapps/data/scorelogs/score-${2}.log"
python3 ../freeciv-proxy/freeciv-proxy.py "${3}" > "../logs/freeciv-proxy-${3}.log" 2>&1 &
proxy_pid=$! &&
${HOME}/freeciv/bin/freeciv-web "${args[@]}" > /dev/null 2> "../logs/freeciv-web-stderr-${2}.log"
rc=$?;
kill -9 $proxy_pid;
exit $rc