-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprovision-openttd.sh
executable file
·65 lines (50 loc) · 1.84 KB
/
provision-openttd.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
62
63
64
65
#!/bin/bash
set +eux
export OPENTTD_VERSION=1.10.1
# -----------------------------------------------------------------------------
# 1: INSTALL DEPENDENCIES
# -----------------------------------------------------------------------------
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get upgrade -qq -y
# openttd-data & openttd-opengfx: required to run openttd
# ufw: firewall
# other packages: required to clone and compile openttd
apt install -qq -y -\
build-essential \
git \
liblzo2-dev \
liblzma-dev \
libsdl1.2-dev \
openttd-data \
openttd-opengfx \
ufw \
zlib1g-dev
# -----------------------------------------------------------------------------
# 2: CREATE OPENTTD USER & CONFIGURE FIREWALL
# -----------------------------------------------------------------------------
adduser --disabled-password --gecos "" openttd
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw allow 3979/tcp
ufw allow 3979/udp
ufw --force enable
# -----------------------------------------------------------------------------
# 3: COMPILE OPENTTD
# -----------------------------------------------------------------------------
export REPO_DIR="/home/openttd/openttd-$OPENTTD_VERSION-sources"
su openttd -c \
"git clone -b $OPENTTD_VERSION --depth 1 --quiet https://github.com/OpenTTD/OpenTTD.git $REPO_DIR &&\
cd $REPO_DIR && \
./configure --enable-dedicated && \
make"
cd $REPO_DIR || exit
make install
ln -s /usr/local/games/openttd /usr/local/bin/openttd
su openttd -c \
'mkdir /home/openttd/.openttd && ln -s /usr/share/games/openttd/baseset /home/openttd/.openttd/baseset'
# -----------------------------------------------------------------------------
# 4: MAKE OPENTTD SYSTEMD SERVICE RUN ON SERVER STARTUP
# -----------------------------------------------------------------------------
systemctl enable openttd