-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
384 lines (313 loc) · 13.8 KB
/
install.sh
File metadata and controls
384 lines (313 loc) · 13.8 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
#!/bin/bash
set -e
lowercase(){
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
}
OS=`lowercase \`uname\``
OS=`uname`
if [ "${OS}" = "Linux" ] ; then
if [ -f /etc/redhat-release ] ; then
DIST=`cat /etc/redhat-release |sed s/\ release.*//`
REV=`cat /etc/redhat-release | sed s/.*release\ // | sed s/\ .*//`
elif [ -f /etc/debian_version ] ; then
DIST=`cat /etc/os-release | grep '^ID' | awk -F= '{ print $2 }'`
REV=`cat /etc/os-release | grep '^VERSION_ID' | awk -F= '{ print $2 }' | cut -d '"' -f 2`
else
echo -e "\e[31mNo compatible OS found\e[0m"
exit 1
fi
DIST=`lowercase $DIST`
REV=`lowercase $REV`
else
echo -e "\e[31mPlease use a Linux distribution\e[0m"
exit 1
fi
# Update repositories list
apt update && apt upgrade -y
# Install dependencies
apt -y install git libopus-dev ffmpeg youtube-dl apt-transport-https wget sudo
# Load repositories of dotnet
wget "https://packages.microsoft.com/config/${DIST}/${REV}/packages-microsoft-prod.deb" -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
# Update all dependencies
apt update
# Install dotnet
apt -y install dotnet-sdk-3.1
# Go into the base path, clone TS3Audiobot and navigate to folder
cd /opt && git clone https://github.com/Bot-Feature/TS3AudioBot.git && cd TS3AudioBot
# Build bot with dotnet
dotnet build --framework netcoreapp3.1 --configuration Release TS3AudioBot
echo -e "Please enter you Teamspeak Hostname/IP Address: "
read address
echo -e "Please enter a Server password (leave blank for no password): "
read serverpassword
# Add getmy uid permissions for first start
echo "[[rule]]
\"+\" = [
# Basic stuff
\"cmd.getmy.*\"
]" > /opt/TS3AudioBot/TS3AudioBot/bin/Release/netcoreapp3.1/rights.toml
# Add bots and default bot directory
mkdir /opt/TS3AudioBot/TS3AudioBot/bin/Release/netcoreapp3.1/bots
mkdir /opt/TS3AudioBot/TS3AudioBot/bin/Release/netcoreapp3.1/bots/default
# Add default Bot config
echo "#Starts the instance when the TS3AudioBot is launched.
run = true
[commands]
[commands.alias]
[connect]
#The server password. Leave empty for none.
server_password = { pw = \"${serverpassword}\" }
#The default channel password. Leave empty for none.
channel_password = { }
#Overrides the displayed version for the ts3 client. Leave empty for default.
client_version = { }
#The address, ip or nickname (and port; default: 9987) of the TeamSpeak3 server
address = \"${address}\"
[connect.identity]
#||| DO NOT MAKE THIS KEY PUBLIC ||| The client identity. You can import a teamspeak3 identity here too.
key = \"\"
#The client identity offset determining the security level.
offset = 26
[reconnect]
[audio]
#When a new song starts the volume will be trimmed to between min and max.
#When the current volume already is between min and max nothing will happen.
#To completely or partially disable this feature, set min to 0 and/or max to 100.
volume = { }
[playlists]
[history]
[events]" > /opt/TS3AudioBot/TS3AudioBot/bin/Release/netcoreapp3.1/bots/default/bot.toml
# Execute after build
echo -e "\e[33mWrite the bot with !getmy uid private and copy the output. Then you have to press ctrl+c and paste the copied UID.\e[0m"
cd /opt/TS3AudioBot/TS3AudioBot/bin/Release/netcoreapp3.1/ && dotnet TS3AudioBot.dll
echo -e "Please paste your copied UID here: "
read uid
# Set permissions for api token creation after first start
echo "[[rule]]
# Set your admin Group Ids here, ex: [ 13, 42 ]
groupid = []
# And/Or your admin Client Uids here
useruid = [ \"${uid}\" ]
# By default treat requests from localhost as admin
ip = [ \"127.0.0.1\", \"::1\" ]
\"+\" = \"*\"" > /opt/TS3AudioBot/TS3AudioBot/bin/Release/netcoreapp3.1/rights.toml
# Create service file
echo "[Unit]
Description=\"TS3AudioBot\"
[Service]
ExecStart=/usr/bin/dotnet TS3AudioBot.dll
WorkingDirectory=/opt/TS3AudioBot/TS3AudioBot/bin/Release/netcoreapp3.1
Restart=always
RestartSec=10
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=TS3AudioBot
[Install]
WantedBy=multi-user.target" > /etc/systemd/system/ts3audiobot.service
# Enable service
systemctl enable ts3audiobot
# Reload daemon
systemctl daemon-reload
# Start ts3audiobot with the created service
systemctl start ts3audiobot
# Installing dependencies of youtube-dl
apt -y install python
# Download youtube-dl
sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl
# Now we configure the ts3audiobot
echo "#! IMPORTANT !
#All config tables here starting with 'bot.*' will only be used as default values for each bot.
#To make bot-instance specific changes go to the 'Bots' folder (configs.bots_path) and set your configuration values in the desired bot config.
[bot]
#This field will be automatically set when you call '!bot setup'.
#The bot will use the specified group to set/update the required permissions and add himself into it.
#You can set this field manually if you already have a preexisting group the bot should add himself to.
bot_group_id = 0
#Tries to fetch a cover image when playing.
generate_status_avatar = true
#Sets the description of the bot to the current song title.
set_status_description = true
#The language the bot should use to respond to users. (Make sure you have added the required language packs)
language = \"en\"
#Starts the instance when the TS3AudioBot is launched.
run = false
[bot.commands]
#Defines how the bot tries to match your !commands. Possible types:
# - exact : Only when the command matches exactly.
# - substring : The shortest command starting with the given prefix.
# - ic3 : 'interleaved continuous character chain' A fuzzy algorithm similar to hamming distance but preferring characters at the start.
matcher = \"ic3\"
#Defines how the bot handles messages which are too long for a single ts3 message. Options are:
# - split : The message will be split up into multiple messages.
# - drop : Does not send the message.
long_message = \"Split\"
#Limits the split count for long messages. When for example set to 1 the message will simply be trimmed to one message.
long_message_split_limit = 1
#Enables colors and text highlights for respones.
color = true
#Limits the maximum command complexity to prevent endless loops.
command_complexity = 64
[bot.commands.alias]
[bot.connect]
#The server password. Leave empty for none.
server_password = { pw = \"\", hashed = false, autohash = false }
#The default channel password. Leave empty for none.
channel_password = { pw = \"\", hashed = false, autohash = false }
#Overrides the displayed version for the ts3 client. Leave empty for default.
client_version = { build = \"\", platform = \"\", sign = \"\" }
#The address, ip or nickname (and port; default: 9987) of the TeamSpeak3 server
address = \"\"
#Default channel when connecting. Use a channel path or \"/<id>\".
#Examples: \"Home/Lobby\", \"/5\", \"Home/Afk \\/ Not Here\".
channel = \"\"
#The client badges. You can set a comma seperated string with max three GUID's. Here is a list: http://yat.qa/ressourcen/abzeichen-badges/
badges = \"\"
#Client nickname when connecting.
name = \"TS3AudioBot\"
[bot.connect.identity]
#||| DO NOT MAKE THIS KEY PUBLIC ||| The client identity. You can import a teamspeak3 identity here too.
key = \"\"
#The client identity offset determining the security level.
offset = 0
#The client identity security level which should be calculated before connecting
#or -1 to generate on demand when connecting.
level = -1
[bot.reconnect]
ontimeout = [\"1s\", \"2s\", \"5s\", \"10s\", \"30s\", \"1m\", \"5m\", \"repeat last\"]
onkick = []
onban = []
onerror = [\"30s\", \"repeat last\"]
onshutdown = [\"5m\"]
[bot.audio]
#When a new song starts the volume will be trimmed to between min and max.
#When the current volume already is between min and max nothing will happen.
#To completely or partially disable this feature, set min to 0 and/or max to 100.
volume = { default = 50.0, min = 25.0, max = 75.0 }
#The maximum volume a normal user can request. Only user with the 'ts3ab.admin.volume' permission can request higher volumes.
max_user_volume = 100.0
#Specifies the bitrate (in kbps) for sending audio.
#Values between 8 and 98 are supported, more or less can work but without guarantees.
#Reference values: 16 - very poor (~3KiB/s), 24 - poor (~4KiB/s), 32 - okay (~5KiB/s), 48 - good (~7KiB/s), 64 - very good (~9KiB/s), 96 - deluxe (~13KiB/s)
bitrate = 48
#How the bot should play music. Options are:
# - whisper : Whispers to the channel where the request came from. Other users can join with '!subscribe'.
# - voice : Sends via normal voice to the current channel. '!subscribe' will not work in this mode.
# - !... : A custom command. Use '!xecute (!a) (!b)' for example to execute multiple commands.
send_mode = \"voice\"
[bot.playlists]
[bot.history]
#Enable or disable history features completely to save resources.
enabled = true
#Whether or not deleted history ids should be filled up with new songs.
fill_deleted_ids = true
[bot.events]
#Called when the bot is connected.
onconnect = \"\"
#Called when the bot gets disconnected.
ondisconnect = \"\"
#Called when the bot does not play anything for a certain amount of time.
onidle = \"\"
#Specifies how long the bot has to be idle until the 'onidle' event gets fired.
#You can specify the time in the ISO-8601 format \"PT30S\" or like: 15s, 1h, 3m30s
idletime = \"0s\"
#Called when the last client leaves the channel of the bot. Delay can be specified
onalone = \"\"
#Specifies how long the bot has to be alone until the 'onalone' event gets fired.
#You can specify the time in the ISO-8601 format \"PT30S\" or like: 15s, 1h, 3m30s
alone_delay = \"0s\"
#Called when the bot was alone and a client joins his channel. Delay can be specified.
onparty = \"\"
#Specifies how long the bot has to be alone until the 'onalone' event gets fired.
#You can specify the time in the ISO-8601 format \"PT30S\" or like: 15s, 1h, 3m30s
party_delay = \"0s\"
#Called when a new song starts.
onsongstart = \"\"
[configs]
#Path to a folder where the configuration files for each bot template will be stored.
bots_path = \"bots\"
#Enable to contribute to the global stats tracker to help us improve our service.
#We do NOT send/store any IPs, identifiable information or logs for this.
#If you want to check how a stats packet looks like you can run the bot with 'TS3AudioBot --stats-example'.
#To disable contributing without config you can run the bot with 'TS3AudioBot --stats-disabled'. This will ignore the config value.
send_stats = true
[db]
#The path to the database file for persistent data.
path = \"ts3audiobot.db\"
[factories]
#The default path to look for local resources.
media = { path = \"\" }
[factories.youtube]
#Changes how to try to resolve youtube songs
# - youtubedl : uses youtube-dl only
# - internal : uses the internal resolver, then youtube-dl
prefer_resolver = \"YoutubeDl\"
#Set your own youtube api key to keep using the old youtube factory loader.
#This feature is unsupported and may break at any time
youtube_api_key = \"\"
[tools]
#Path to the youtube-dl binary or local git repository.
youtube-dl = { path = \"/usr/local/bin/youtube-dl\" }
#The path to ffmpeg.
[tools.ffmpeg]
path = \"ffmpeg\"
[rights]
#Path to the permission file. The file will be generated if it doesn't exist.
path = \"rights.toml\"
[plugins]
#The path to the plugins folder.
path = \"plugins\"
[plugins.load]
[web]
#An array of all urls the web api should be possible to be accessed with.
hosts = [\"*\"]
#The port for the web server.
port = 58913
[web.api]
#If you want to enable the web api.
enabled = true
#Limits the maximum command complexity to prevent endless loops.
command_complexity = 64
#See: bot.commands.matcher
matcher = \"exact\"
[web.interface]
#If you want to enable the webinterface.
enabled = false
#The webinterface folder to host. Leave empty to let the bot look for default locations.
path = \"\"" > /opt/TS3AudioBot/TS3AudioBot/bin/Release/netcoreapp3.1/ts3audiobot.toml
echo -e "\e[33mNow you can write to the bot again with !api token. Copy the output and save it securely.\e[0m Then to complete the installation enter \"y\""
read copiedtoken
# If api token is copied, than delete default bot
if [ "${copiedtoken}" == "y" ]; then
# Add default Bot config
echo "#Starts the instance when the TS3AudioBot is launched.
run = true
[commands]
[commands.alias]
[connect]
#The server password. Leave empty for none.
server_password = { pw = \"\" }
#The default channel password. Leave empty for none.
channel_password = { }
#Overrides the displayed version for the ts3 client. Leave empty for default.
client_version = { }
#The address, ip or nickname (and port; default: 9987) of the TeamSpeak3 server
address = \"\"
[connect.identity]
#||| DO NOT MAKE THIS KEY PUBLIC ||| The client identity. You can import a teamspeak3 identity here too.
key = \"\"
#The client identity offset determining the security level.
offset = 26
[reconnect]
[audio]
#When a new song starts the volume will be trimmed to between min and max.
#When the current volume already is between min and max nothing will happen.
#To completely or partially disable this feature, set min to 0 and/or max to 100.
volume = { }
[playlists]
[history]
[events]" > /opt/TS3AudioBot/TS3AudioBot/bin/Release/netcoreapp3.1/bots/default/bot.toml
systemctl restart ts3audiobot
fi
echo -e "\e[32mThe installation is now complete. The Bot Node can be added under the following URL: https://bot-feature.com/hosts\e[0m"