Skip to content

Commit 9c2972b

Browse files
committed
0.36.0
1 parent 79ef0fa commit 9c2972b

File tree

2 files changed

+48
-32
lines changed

2 files changed

+48
-32
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,31 @@ OpenTTD Patchpack is a special release with a collection of patches applied to O
1313
See [official OpenTTD patchpack repository](https://github.com/JGRennison/OpenTTD-patches)
1414

1515
---
16+
17+
## Enviroment variables
18+
19+
### DEBUG
20+
21+
See [official OpenTTD documentation](https://wiki.openttd.org/Debugging) for possible values
22+
23+
### COPY_CONFIG
24+
25+
Copies all content of provided directory, used for import data inside a docker volume.
26+
27+
### BAN_LIST
28+
29+
Filename that contains list of banned user
30+
31+
### LOADGAME
32+
33+
Define if load a savegame, possible values:
34+
- false start a new game every times
35+
- last-autosave load last autosave gameplay
36+
- exit load autosave on exit
37+
- {savename} load passed filename of saved gameplay
38+
39+
### SCENARIO
40+
41+
When start a new game, load specified filename scenario
42+
43+

entrypoint.sh

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,52 @@
11
#!/bin/sh
22

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}"
67

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
1410
echo "Copying static configuration from ${COPY_CONFIG}"
1511
cp -Lr ${COPY_CONFIG}/* /config/
1612
fi
1713

18-
19-
if [ ! -f /config/openttd.cfg ]; then
14+
# Check if exists a config file
15+
if [ ! -f ${config_target} ]; then
2016
# we start the server then kill it quickly to write a config file
2117
# yes this is a horrific hack but whatever
2218
echo "No config file found: generating one"
2319
timeout 3 /app/bin/openttd -D > /dev/null 2>&1
2420
fi
2521

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}
3026
fi
3127

3228

33-
savegame_target="x"
34-
if [ ${LOADGAME_CHECK} != "x" ]; then
35-
case ${loadgame} in
29+
if [ "${LOADGAME}x" != "x" ]; then
30+
case ${LOADGAME} in
3631
'false')
3732
#Do nothing, is default
3833
;;
3934
'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`
4136
;;
4237
'exit')
43-
savegame_target="${savegame_path}/autosave/exit.sav"
38+
savegame_target="${savegame_target}/autosave/exit.sav"
4439
;;
4540
*)
46-
savegame_target="${savegame_path}/${loadgame}"
41+
savegame_target="${savegame_target}/${LOADGAME}"
4742
esac
4843
fi
4944

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
5846
echo "Loading from savegame - ${savegame_target}"
5947
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}"
6250
exec /app/bin/openttd -D -g ${scenario_target} -x -d ${DEBUG}
6351
else
6452
echo "Creating a new game. Start random map."

0 commit comments

Comments
 (0)