-
Notifications
You must be signed in to change notification settings - Fork 0
/
10-teamspeak
executable file
·99 lines (76 loc) · 2.35 KB
/
10-teamspeak
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
if [ ! -e /config ]; then
echo "+++++++++++ /config is missing +++++++++++"
echo ""
echo "You need to map /config to a directory "
echo "on the host!"
echo ""
echo "+++++++++++ Boot failed! +++++++++"
exit 1
fi
if [ ! -e /config/downloadurl ]; then
echo "++++++++++ /config/downloadurl is missing ++++++++++"
echo ""
echo "You need to place the download URL (by itself) in a "
echo "file called 'downloadurl' in the configuration "
echo "directory."
echo ""
echo "++++++++++ Boot failed! ++++++++++"
exit 1
fi
url=$(cat /config/downloadurl)
echo "Downloading TeamSpeak..."
cd /tmp
wget $url
tar -xvf *.tar.gz
cd *
echo "Downloaded and extracted TeamSpeak successfully!"
echo "Moving TeamSpeak..."
# Move TeamSpeak into /srv/teamspeak
mkdir -pv /srv/teamspeak
mv -v * /srv/teamspeak/
cd /srv/teamspeak/
chown -Rv teamspeak:teamspeak /srv/teamspeak
chown -Rv teamspeak:teamspeak /config
USERFILES="licensekey.dat query_ip_blacklist.txt query_ip_whitelist.txt serverkey.dat ts3server.sqlitedb"
# If /config/ts3server.sqlitedb exists, then this is an
# existing installation and we just need to link up the
# existing files.
if [ -e /config/ts3server.sqlitedb ]; then
# Link up the existing files
echo "Linking up database..."
for i in $USERFILES; do
if [ -e /config/$i ]; then
sudo -u teamspeak ln -v -s /config/$i $i
fi
done
else
# Start the server, wait for it to start up, and
# then shut it down and move the files into the
# configuration folder.
echo "First time start..."
sudo -u teamspeak /srv/teamspeak/ts3server_startscript.sh start
echo "Waiting..."
sleep 10
echo "Stopping..."
sudo -u teamspeak /srv/teamspeak/ts3server_startscript.sh stop
echo "Moving files..."
for i in $USERFILES; do
if [ -e $i ]; then
if [ ! -e /config/$i ]; then
sudo -u teamspeak mv -v $i /config/$i
fi
fi
done
echo "Linking up database..."
for i in $USERFILES; do
if [ -e /config/$i ]; then
sudo -u teamspeak ln -v -s /config/$i $i
fi
done
fi
echo "Removing old TeamSpeak PID..."
rm -v ts3server.pid || true
echo "Starting TeamSpeak..."
sudo -u teamspeak /srv/teamspeak/ts3server_startscript.sh start
cp ts3server.pid /run/watch/teamspeak