-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvoices.sh
executable file
·289 lines (256 loc) · 9.83 KB
/
voices.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
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
#! /bin/bash
# TekLabs TekBase
# Copyright since 2005 TekLab
# Christian Frankenstein
# Website: www.teklab.de
# www.teklab.us
VAR_A=$1
VAR_B=$2
VAR_C=$3
VAR_D=$4
VAR_E=$5
VAR_F=$6
VAR_G=$7
VAR_H=$8
VAR_I=$9
VAR_J=${10}
if [ "$VAR_A" = "" ]; then
./tekbase
fi
LOGF=$(date +"%Y_%m")
LOGP=$(pwd)
if [ ! -d logs ]; then
mkdir logs
chmod 0777 logs
fi
if [ ! -d restart ]; then
mkdir restart
chmod 0777 restart
fi
if [ ! -f "logs/$LOGF.txt" ]; then
echo "***TekBASE Script Log***" >> $LOGP/logs/$LOGF.txt
chmod 0666 $LOGP/logs/$LOGF.txt
fi
if [ "$VAR_A" = "start" ]; then
if [ -f $LOGP/restart/$VAR_B-voice-$VAR_C ]; then
rm $LOGP/restart/$VAR_B-voice-$VAR_C
fi
echo "#! /bin/bash" >> $LOGP/restart/$VAR_B-voice-$VAR_C
if [ "$VAR_F" = "ventrilo" ]; then
echo "check=\`ps aux | grep -v grep | grep -i screen | grep -i \"voice$VAR_C-X\"\`" >> $LOGP/restart/$VAR_B-voice-$VAR_C
fi
if [ "$VAR_F" = "mumble" ]; then
echo "if [ -f /home/$VAR_B/voice/$VAR_C/murmur.pid ]; then" >> $LOGP/restart/$VAR_B-voice-$VAR_C
echo "check=\`ps -p \`cat /home/$VAR_B/voice/$VAR_C/murmurd.pid\`\`" >> $LOGP/restart/$VAR_B-voice-$VAR_C
echo "fi" >> $LOGP/restart/$VAR_B-voice-$VAR_C
fi
echo "if [ ! -n \"\$check\" ]; then" >> $LOGP/restart/$VAR_B-voice-$VAR_C
echo "cd $LOGP;sudo -u $VAR_B ./voices 'start' '$VAR_B' '$VAR_C' '$VAR_D' '$VAR_E' '$VAR_F' '$VAR_G' '$VAR_H' '$VAR_I' '$VAR_J'" >> $LOGP/restart/$VAR_B-voice-$VAR_C
echo "fi" >> $LOGP/restart/$VAR_B-voice-$VAR_C
echo "exit 0" >> $LOGP/restart/$VAR_B-voice-$VAR_C
chmod 0755 $LOGP/restart/$VAR_B-voice-$VAR_C
cd /home/$VAR_B/voice/$VAR_D
if [ "$VAR_E" = "mumble" ]; then
if [ -f murmurd.pid ]; then
check=$(ps -p $(grep -i "mumble" murmurd.pid))
if [ -n "$check" ]; then
kill -9 $(cat murmurd.pid)
fi
check=$(ps -p $(grep -i "mumble" murmurd.pid))
rm murmurd.pid
fi
if [ ! -n "$check" ]; then
sed -i '/port=/Ic\port='$VAR_F'' mumble-server.ini
sed -i '/users=/Ic\users='$VAR_G'' mumble-server.ini
sed -i '/host=/Ic\host='$VAR_H'' mumble-server.ini
sed -i '/bandwidth=/Ic\bandwidth='$VAR_I'' mumble-server.ini
./mumble-server -ini mumble-server.ini
sleep 2
if [ -f murmurd.pid ]; then
echo "$(date) - Voice /home/$VAR_B/voice/$VAR_D was started (./mumble-server -ini mumble-server.ini)" >> $LOGP/logs/$LOGF.txt
echo "ID1"
else
echo "$(date) - Voice /home/$VAR_B/voice/$VAR_D cant be started (./mumble-server -ini mumble-server.ini)" >> $LOGP/logs/$LOGF.txt
echo "ID2"
fi
else
echo "$(date) - Voice /home/$VAR_B/voice/$VAR_D cant be stopped and restarted (./mumble-server -ini mumble-server.ini)" >> $LOGP/logs/$LOGF.txt
echo "ID3"
fi
fi
if [ "$VAR_E" = "ventrilo" ]; then
kill -9 $(ps aux | grep -v grep | grep -i screen | grep -i "voice$VAR_C-X" | awk '{print $2}')
check=$(ps aux | grep -v grep | grep -i screen | grep -i "voice$VAR_C-X")
screen -wipe
if [ ! -n "$check" ]; then
sed -i '/Port=/Ic\Port='$VAR_F'' ventrilo_srv.ini
sed -i '/MaxClients=/Ic\MaxClients='$VAR_G'' ventrilo_srv.ini
screen -A -m -d -S voice$VAR_B-X ./ventrilo_srv
check=$(ps aux | grep -v grep | grep -i screen | grep -i "voice$VAR_C-X")
if [ -n "$check" ]; then
echo "$(date) - Voice /home/$VAR_B/voice/$VAR_D was started (./ventrilo_srv)" >> $LOGP/logs/$LOGF.txt
echo "ID1"
else
echo "$(date) - Voice /home/$VAR_B/voice/$VAR_D cant be started (./ventrilo_srv)" >> $LOGP/logs/$LOGF.txt
echo "ID2"
fi
else
echo "$(date) - Voice /home/$VAR_B/voice/$VAR_D cant be stopped and restarted (./ventrilo_srv)" >> $LOGP/logs/$LOGF.txt
echo "ID3"
fi
fi
fi
if [ "$VAR_A" = "stop" ]; then
if [ -f $LOGP/restart/$VAR_B-voice-$VAR_C ]; then
rm $LOGP/restart/$VAR_B-voice-$VAR_C
fi
cd /home/$VAR_B/voice/$VAR_D
if [ "$VAR_E" = "mumble" ]; then
if [ -f murmurd.pid ]; then
check=$(ps -p $(grep -i "mumble" murmurd.pid))
if [ -n "$check" ]; then
kill -9 $(cat murmurd.pid)
fi
check=$(ps -p $(grep -i "mumble" murmurd.pid))
rm murmurd.pid
fi
fi
if [ "$VAR_E" = "ventrilo" ]; then
if [ "$VAR_C" = "vstreams" ]; then
kill -9 $(ps aux | grep -v grep | grep -i screen | grep -i "voice$VAR_C-X" | awk '{print $2}')
check=$(ps aux | grep -v grep | grep -i screen | grep -i "voice$VAR_C-X")
screen -wipe
fi
fi
if [ ! -n "$check" ]; then
echo "$(date) - Voice /home/$VAR_B/voice/$VAR_D was stopped" >> $LOGP/logs/$LOGF.txt
echo "ID1"
else
echo "$(date) - Voice /home/$VAR_B/voice/$VAR_D cant be stopped" >> $LOGP/logs/$LOGF.txt
echo "ID2"
fi
fi
if [ "$VAR_A" = "muserlist" ]; then
cd /home/$VAR_B/voice/$VAR_D
userlist=$(sqlite3 -html mumble-server.sqlite "SELECT user_id, name FROM users ORDER BY name ASC")
echo "$userlist"
fi
if [ "$VAR_A" = "museradd" ]; then
cd /home/$VAR_B/voice/$VAR_D
password=$(echo -n $VAR_F | sha1sum | awk '{print $1}')
usercount=$(sqlite3 mumble-server.sqlite "SELECT user_id FROM users ORDER BY user_id DESC LIMIT 1")
let newid=$usercount+1
sqlite3 mumble-server.sqlite "INSERT INTO users (server_id, user_id, name, pw) VALUES (1, \"$newid\", \"$VAR_E\", \"$password\")"
echo "ID1"
fi
if [ "$VAR_A" = "musermod" ]; then
cd /home/$VAR_B/voice/$VAR_D
password=$(echo -n $VAR_E | sha1sum |awk '{print $1}')
sqlite3 mumble-server.sqlite "UPDATE users SET pw=\"$password\" WHERE user_id=\"$VAR_F\""
echo "ID1"
fi
if [ "$VAR_A" = "muserdel" ]; then
cd /home/$VAR_B/voice/$VAR_D
sqlite3 mumble-server.sqlite "DELETE FROM users WHERE user_id=\"$VAR_E\""
echo "ID1"
fi
if [ "$VAR_A" = "tuserlist" ]; then
cd /home/user-webi/$VAR_D
serverid=$(sqlite server.dbs "SELECT i_server_id FROM ts2_servers WHERE i_server_udpport=\"$VAR_F\"")
userlist=$(sqlite -html server.dbs "SELECT i_client_id, s_client_name, b_client_privilege_serveradmin FROM ts2_clients WHERE i_client_server_id=\"$serverid\" ORDER BY s_client_name ASC")
userlist=$(echo ${userlist//&/_})
tscounter=0
tsnewline=""
for LINE in $userlist
do
if [ "$tscounter" != "4" ]; then
tsnewline="$tsnewline$LINE"
let tscounter=$tscounter+1
fi
if [ "$tscounter" = "4" ]; then
echo "$tsnewline%TEK%"
tsnewline=""
tscounter=0
fi
done
fi
if [ "$VAR_A" = "tuseradd" ]; then
cd /home/user-webi/$VAR_D
adddate="$(date +"%d%m%Y%H%M%S")00000"
serverid=$(sqlite server.dbs "SELECT i_server_id FROM ts2_servers WHERE i_server_udpport=\"$VAR_F\"")
sqlite server.dbs "INSERT INTO ts2_clients (i_client_server_id, b_client_privilege_serveradmin, s_client_name, s_client_password, dt_client_created) VALUES (\"$serverid\", \"$VAR_I\", \"$VAR_G\", \"$VAR_H\", \"$adddate\")"
echo "ID1"
fi
if [ "$VAR_A" = "tusermod" ]; then
cd /home/user-webi/$VAR_D
serverid=$(sqlite server.dbs "SELECT i_server_id FROM ts2_servers WHERE i_server_udpport=\"$VAR_F\"")
sqlite server.dbs "UPDATE ts2_clients SET b_client_privilege_serveradmin=\"$VAR_I\", s_client_password=\"$VAR_H\" WHERE i_client_id=\"$VAR_G\" AND i_client_server_id=\"$serverid\""
echo "ID1"
fi
if [ "$VAR_A" = "tuserdel" ]; then
cd /home/user-webi/$VAR_D
serverid=$(sqlite server.dbs "SELECT i_server_id FROM ts2_servers WHERE i_server_udpport=\"$VAR_F\"")
sqlite server.dbs "DELETE FROM ts2_clients WHERE i_client_id=\"$VAR_G\" AND i_client_server_id=\"$serverid\""
echo "ID1"
fi
if [ "$VAR_A" = "tserverchg" ]; then
cd /home/user-webi/$VAR_D
sqlite server.dbs "UPDATE ts2_servers SET i_server_maxusers=\"$VAR_H\", i_server_udpport=\"$VAR_G\" WHERE i_server_udpport=\"$VAR_F\""
echo "ID1"
fi
if [ "$VAR_A" = "tservermod" ]; then
cd /home/user-webi/$VAR_D
sqlite server.dbs "UPDATE ts2_servers SET s_server_name=\"$VAR_C\", s_server_welcomemessage=\"$VAR_E\", s_server_password=\"$VAR_G\", b_server_clan_server=\"$VAR_H\", s_server_webposturl=\"$VAR_I\", s_server_weblinkurl=\"$VAR_J\" WHERE i_server_udpport=\"$VAR_F\""
echo "ID1"
fi
if [ "$VAR_A" = "tserverdel" ]; then
cd /home/user-webi/$VAR_D
serverid=$(sqlite server.dbs "SELECT i_server_id FROM ts2_servers WHERE i_server_udpport=\"$VAR_F\"")
sqlite server.dbs "DELETE FROM ts2_server_privileges WHERE i_sp_server_id=\"$serverid\""
sqlite server.dbs "DELETE FROM ts2_channels WHERE i_channel_server_id=\"$serverid\""
sqlite server.dbs "DELETE FROM ts2_channel_privileges WHERE i_cp_server_id=\"$serverid\""
sqlite server.dbs "DELETE FROM ts2_clients WHERE i_client_server_id=\"$serverid\""
sqlite server.dbs "DELETE FROM ts2_bans WHERE i_ban_server_id=\"$serverid\""
sqlite server.dbs "DELETE FROM ts2_servers WHERE i_server_id=\"$serverid\""
echo "ID1"
fi
if [ "$VAR_A" = "tserverread" ]; then
cd /home/user-webi/$VAR_D
serverid=$(sqlite -separator %TD% server.dbs "SELECT s_server_name, s_server_welcomemessage, s_server_password, b_server_clan_server, s_server_webposturl, s_server_weblinkurl FROM ts2_servers WHERE i_server_udpport=\"$VAR_F\"")
echo "$serverid"
fi
if [ "$VAR_A" = "content" ]; then
cd /home/$VAR_B/voice/$VAR_D
check=$(cat $VAR_E)
for LINE in $check
do
echo "$LINE%TEND%"
done
fi
if [ "$VAR_A" = "tsdns" ]; then
cd /home/tsdns
if [ -f tsdns_settings.ini ]; then
sed -i '/'$VAR_B'/d' tsdns_settings.ini
fi
if [ "$VAR_C" != "" ]; then
echo -e "\n$VAR_C=$VAR_B" >> tsdns_settings.ini
fi
check=$(ps aux | grep -v grep | grep -i "tsdnsserver_linux")
if [ ! -n "$check" ]; then
if [ -f tsdnsserver_linux_86 ]; then
./tsdnsserver_linux_x86 &
fi
if [ -f tsdnsserver_linux_amd64 ]; then
./tsdnsserver_linux_amd64 &
fi
else
if [ -f tsdnsserver_linux_x86 ]; then
./tsdnsserver_linux_x86 --update
fi
if [ -f tsdnsserver_linux_amd64 ]; then
./tsdnsserver_linux_amd64 --update
fi
fi
echo "ID1"
fi
exit 0