|
1 | 1 | #!/bin/sh |
2 | 2 |
|
3 | | -# This script is based fairly heavily off bateau84/openttd's. Thanks, man! |
4 | | -savegame_path="/config/save" |
5 | | -scenario_path="/config/scenario" |
| 3 | +config_target="/config/openttd.cfg" |
| 4 | +banlist_target="/config/${BAN_LIST}" |
| 5 | +savegame_target="/config/save" |
| 6 | +scenario_target="/config/scenario/${SCENARIO}" |
6 | 7 |
|
7 | | -LOADGAME_CHECK="${loadgame}x" |
8 | | -SCENARIO_CHECK="${scenario}x" |
9 | | -BANLIST_CHECK="${BAN_LIST}x" |
10 | | -CONFIG_CHECK="${COPY_CONFIG}x" |
11 | | - |
12 | | - |
13 | | -if [ ${CONFIG_CHECK} != "x" ]; then |
| 8 | +# Check if is requested to copy data from another directory |
| 9 | +if [ "${COPY_CONFIG}x" != "x" ]; then |
14 | 10 | echo "Copying static configuration from ${COPY_CONFIG}" |
15 | 11 | cp -Lr ${COPY_CONFIG}/* /config/ |
16 | 12 | fi |
17 | 13 |
|
18 | | - |
19 | | -if [ ! -f /config/openttd.cfg ]; then |
| 14 | +# Check if exists a config file |
| 15 | +if [ ! -f ${config_target} ]; then |
20 | 16 | # we start the server then kill it quickly to write a config file |
21 | 17 | # yes this is a horrific hack but whatever |
22 | 18 | echo "No config file found: generating one" |
23 | 19 | timeout 3 /app/bin/openttd -D > /dev/null 2>&1 |
24 | 20 | fi |
25 | 21 |
|
26 | | - |
27 | | -if [ ${BANLIST_CHECK} != "x" ]; then |
28 | | - echo "Merging external Ban List from /config/${BAN_LIST}" |
29 | | - banread /config/openttd.cfg /config/${BAN_LIST} |
| 22 | +# Check if there is a ban list file to load |
| 23 | +if [ "${BAN_LIST}x" != "x" ]; then |
| 24 | + echo "Merging external Ban List from ${banlist_target}" |
| 25 | + banread ${config_path} ${banlist_target} |
30 | 26 | fi |
31 | 27 |
|
32 | 28 |
|
33 | | -savegame_target="x" |
34 | | -if [ ${LOADGAME_CHECK} != "x" ]; then |
35 | | - case ${loadgame} in |
| 29 | +if [ "${LOADGAME}x" != "x" ]; then |
| 30 | + case ${LOADGAME} in |
36 | 31 | 'false') |
37 | 32 | #Do nothing, is default |
38 | 33 | ;; |
39 | 34 | 'last-autosave') |
40 | | - savegame_target=${savegame_path}/autosave/`ls -rt ${savepath}/autosave/ | tail -n1` |
| 35 | + savegame_target=${savegame_target}/autosave/`ls -rt ${savegame_target}/autosave/ | tail -n1` |
41 | 36 | ;; |
42 | 37 | 'exit') |
43 | | - savegame_target="${savegame_path}/autosave/exit.sav" |
| 38 | + savegame_target="${savegame_target}/autosave/exit.sav" |
44 | 39 | ;; |
45 | 40 | *) |
46 | | - savegame_target="${savegame_path}/${loadgame}" |
| 41 | + savegame_target="${savegame_target}/${LOADGAME}" |
47 | 42 | esac |
48 | 43 | fi |
49 | 44 |
|
50 | | - |
51 | | -scenario_target="x" |
52 | | -if [ ${LOADGAME_CHECK} != "x" ]; then |
53 | | - scenario_target="${scenario_path}/${scenario}" |
54 | | -fi |
55 | | - |
56 | | - |
57 | | -if [ ${savegame_target} != "x" ] && [ -r ${savegame_target} ]; then |
| 45 | +if [ "${LOADGAME}x" != "x" ] && [ -r ${savegame_target} ]; then |
58 | 46 | echo "Loading from savegame - ${savegame_target}" |
59 | 47 | exec /app/bin/openttd -D -g ${savegame_target} -x -d ${DEBUG} |
60 | | -elif [ ${SCENARIO_CHECK} != "x" ] && [ -r ${scenario_target} ]; then |
61 | | - echo "Creating a new game. Start scenario ${scenario}" |
| 48 | +elif [ "${SCENARIO}x" != "x" ] && [ -r ${scenario_target} ]; then |
| 49 | + echo "Creating a new game. Start scenario ${SCENARIO}" |
62 | 50 | exec /app/bin/openttd -D -g ${scenario_target} -x -d ${DEBUG} |
63 | 51 | else |
64 | 52 | echo "Creating a new game. Start random map." |
|
0 commit comments