-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·56 lines (48 loc) · 1.61 KB
/
entrypoint.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
#!/bin/sh
config_target="/config/openttd.cfg"
banlist_target="/config/${BAN_LIST}"
savegame_target="/config/save"
scenario_target="/config/scenario/${SCENARIO}"
# Check if is requested to copy data from another directory
if [ "${COPY_CONFIG}x" != "x" ]; then
echo "Copying static configuration from ${COPY_CONFIG}"
cp -Lr ${COPY_CONFIG}/* /config/
fi
# Check if exists a config file
if [ ! -f ${config_target} ]; then
# we start the server then kill it quickly to write a config file
# yes this is a horrific hack but whatever
echo "No config file found: generating one"
timeout 3 /app/bin/openttd -D > /dev/null 2>&1
fi
# Check if there is a ban list file to load
if [ "${BAN_LIST}x" != "x" ]; then
echo "Merging external Ban List from ${banlist_target}"
banread ${config_path} ${banlist_target}
fi
if [ "${LOADGAME}x" != "x" ]; then
case ${LOADGAME} in
'false')
#Do nothing, is default
;;
'last-autosave')
savegame_target=${savegame_target}/autosave/`ls -rt ${savegame_target}/autosave/ | tail -n1`
;;
'exit')
savegame_target="${savegame_target}/autosave/exit.sav"
;;
*)
savegame_target="${savegame_target}/${LOADGAME}"
esac
fi
if [ "${LOADGAME}x" != "x" ] && [ -r ${savegame_target} ]; then
echo "Loading from savegame - ${savegame_target}"
exec /app/bin/openttd -D -g ${savegame_target} -x -d ${DEBUG}
elif [ "${SCENARIO}x" != "x" ] && [ -r ${scenario_target} ]; then
echo "Creating a new game. Start scenario ${SCENARIO}"
exec /app/bin/openttd -D -g ${scenario_target} -x -d ${DEBUG}
else
echo "Creating a new game. Start random map."
exec /app/bin/openttd -D -x -d ${DEBUG}
fi
exit 0