This repository has been archived by the owner on Aug 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
start.sh
268 lines (240 loc) · 7.01 KB
/
start.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
#!/bin/bash
# Colors
ESC_SEQ="\x1b["
COL_RESET=$ESC_SEQ"39;49;00m"
COL_RED=$ESC_SEQ"31;01m"
COL_GREEN=$ESC_SEQ"32;01m"
COL_YELLOW=$ESC_SEQ"33;01m"
COL_BLUE=$ESC_SEQ"34;01m"
COL_MAGENTA=$ESC_SEQ"35;01m"
COL_CYAN=$ESC_SEQ"36;01m"
version="6.0"
php_ver="7.2"
echo ">AutoSpeak"
echo "A teamspeak Bot "
echo "> Version [$version] +"
instances=6
installing()
{
echo;
echo -e "$COL_CYAN ****************************************$COL_RESET";
echo -e "$COL_GREEN INSTALLING: $1 $COL_RESET";
echo -e "$COL_CYAN ****************************************$COL_RESET";
echo;
}
write()
{
echo;
echo -e "$COL_CYAN **************************************** $COL_RESET";
echo -e "$2 $1 $COL_RESET";
echo -e "$COL_CYAN **************************************** $COL_RESET";
echo;
}
check_installed_packets()
{
if [ -z `which sudo` ]; then
installing "sudo"
apt-get install sudo
echo -e "$COL_RESET"
fi
if [ -z `which unzip` ]; then
installing "unzip"
apt-get install unzip
echo -e "$COL_RESET"
fi
if [ -z `which wget` ]; then
installing "wget"
apt-get install wget
echo -e "$COL_RESET"
fi
if [ -z `which screen` ]; then
installing "screen"
apt-get install screen
echo -e "$COL_RESET"
fi
if [[ -z `which php$pvp_ver` && -z `which php` ]]; then
installing "PHP"
apt-get install php
echo -e "$COL_RESET"
fi
if [[ -z `dpkg -l | grep php$php_ver-gd` ]]; then
installing "$php_ver-GD"
apt-get install php$php_ver-gd
echo -e "$COL_RESET"
fi
if [[ -z `dpkg -l | grep php$php_ver-curl` ]]; then
installing "PHP$php_ver-CURL"
apt-get install php$php_ver-curl
echo -e "$COL_RESET"
fi
if [[ -z `dpkg -l | grep php$php_ver-mysql` ]]; then
installing "PHP$php_ver-Mysql"
apt-get install php$php_ver-mysql
echo -e "$COL_RESET"
fi
}
if [[ "$1" == "start" ]]; then
check_installed_packets
if [[ -f include/language_file/eng.txt || "$2" == "eng" ]]; then
echo
echo "You started `basename $0`"
echo Your choice: "$@"
for (( i=1; $i <= $instances; i++ )) ; do
if ! screen -list | grep -q "AutoSpeak_instance_$i" ; then
sudo screen -dmS AutoSpeak_instance_$i php core.php -i $i
echo -e "AutoSpeak instance $i $COL_GREEN is ON! $COL_RESET"
sleep 3
else
echo -e "AutoSpeak instance $i $COL_GREEN is already ON! $COL_RESET"
fi
done
else
echo
echo "Uruchomiles program `basename $0`"
echo Wybrales: "$@"
for (( i=1; $i <= $instances; i++ )) ; do
if ! screen -list | grep -q "AutoSpeak_instance_$i" ; then
sudo screen -dmS AutoSpeak_instance_$i php core.php -i $i
echo -e "AutoSpeak instancja $i $COL_GREEN została włączona! $COL_RESET"
sleep 3
else
echo -e "AutoSpeak instancja $i $COL_GREEN jest już włączony! $COL_RESET"
fi
done
fi
elif [[ "$1" == "stop" ]]; then
if [[ -f include/language_file/eng.txt || "$2" == "eng" ]]; then
echo
echo "You started `basename $0`"
echo Your choice: "$@"
for (( i=1; $i <= $instances; i++ )) ; do
screen -S AutoSpeak_instance_$i -X quit
done
echo -e "AutoSpeak $COL_RED is OFF! $COL_RESET"
else
echo
echo "Uruchomiles program `basename $0`"
echo Wybrales: "$@"
for (( i=1; $i <= $instances; i++ )) ; do
screen -S AutoSpeak_instance_$i -X quit
done
echo -e "AutoSpeak $COL_RED został wyłączony! $COL_RESET"
fi
elif [[ "$1" == "restart" ]]; then
check_installed_packets
if [[ -f include/language_file/eng.txt || "$2" == "eng" ]]; then
echo
echo "You started `basename $0`"
echo Your choice: "$@"
for (( i=1; $i <= $instances; i++ )) ; do
if [ "$i" == 1 ]; then
echo -n -e "$COL_BLUE Restarting "
else
echo -n ". "
fi
screen -S AutoSpeak_instance_$i -X quit
screen -dmS AutoSpeak_instance_$i php core.php -i $i
sleep 3
done
echo ""
echo -e "AutoSpeak $COL_GREEN has been restarted successfully! $COL_RESET"
else
echo
echo "Uruchomiles program `basename $0`"
echo Wybrales: "$@"
for (( i=1; $i <= $instances; i++ )) ; do
if [ "$i" == 1 ]; then
echo -n -e "$COL_BLUE Restartuję "
else
echo -n "."
fi
screen -S AutoSpeak_instance_$i -X quit
screen -dmS AutoSpeak_instance_$i php core.php -i $i
sleep 3
done
echo -e "$COL_RESET"
echo -e "AutoSpeak $COL_GREEN został zrestartowany pomyślnie! $COL_RESET"
fi
elif [[ "$1" == "run" ]]; then
check_installed_packets
if [[ -f include/language_file/eng.txt || "$2" == "eng" ]]; then
echo
echo "You started `basename $0`"
echo Your choice: "$@"
if ! screen -list | grep -q "AutoSpeak_run" ; then
sudo screen -dmS AutoSpeak_run ./starter.sh exec_run yes
echo -e "AutoSpeak run $COL_GREEN is ON! $COL_RESET"
else
screen -S AutoSpeak_run -X quit
echo -e "AutoSpeak run $COL_RED is OFF! $COL_RESET"
fi
else
echo
echo "Uruchomiles program `basename $0`"
echo Wybrales: "$@"
if ! screen -list | grep -q "AutoSpeak_run" ; then
sudo screen -dmS AutoSpeak_run ./starter.sh exec_run yes
echo -e "AutoSpeak run $COL_GREEN została włączona! $COL_RESET"
else
screen -S AutoSpeak_run -X quit
echo -e "AutoSpeak run $COL_RED został wyłączony! $COL_RESET"
fi
fi
elif [[ "$1" == "exec_run" ]]; then
while [ 1 ]; do
sleep 3
if [ -f include/cache/command.txt ]; then
for (( i=1; $i<=2; i++ )) ; do
command=`sed -n "$i"p include/cache/command.txt`
$command
done;
rm include/cache/command.txt
fi
if [[ "$2" == "yes" ]]; then
for (( i=1; $i <= $instances; i++ )) ; do
if ! screen -list | grep -q "AutoSpeak_instance_$i" ; then
sudo screen -dmS AutoSpeak_instance_$i php core.php -i $i
sleep 3
fi
done
fi
done
elif [[ "$1" == "install" ]]; then
echo;
echo -e "$COL_CYAN Wybierz jaką masz wersje systemu $COL_RESET"
echo "[1] Debian 8 lub Debian9"
echo "[2] Ubuntu 14 lub Ubuntu 16"
read -p "» " SYSTEM;
apt-get update -y
apt-get upgrade -y
apt-get install -y sudo nano screen htop unzip wget
apt-get install -y mysql-server
apt-get install -y apache2
case $SYSTEM in
1)
sudo apt-get install -y apt-transport-https lsb-release ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
sudo apt-get update -y;;
2)
sudo apt-get install -y software-properties-common python-software-properties
sudo LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
sudo apt-get update -y;;
esac
apt-get install -y php$php_ver libapache2-mod-php$php_ver php$php_ver-curl php$php_ver-gd php$php_ver-mysql php$php_ver-mbstring php$php_ver-bz2 php$php_ver-xml
apt-get install -y phpmyadmin
ln -s /usr/share/phpmyadmin /var/www/html/phpmyadmin
sudo a2dismod php7
sudo a2dismod php7.1
sudo a2enmod php$php_ver
service apache2 restart
write " Potrzebne pakiety zostały zainstalowane" "$COL_GREEN"
else
if [[ -f include/language_file/eng.txt || "$2" == "eng" ]]; then
echo
echo -e "$COL_GREEN USAGE: ${0} {start/stop/restart/run/install} $COL_RESET"
else
echo
echo -e "$COL_GREEN UŻYCIE: ${0} {start/stop/restart/run/install} $COL_RESET"
fi
fi