-
Notifications
You must be signed in to change notification settings - Fork 101
/
apache.sh
628 lines (577 loc) · 20.8 KB
/
apache.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
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
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
#!/bin/bash
RED="\e[31m"
GREEN="\e[32m"
YELLOW="\e[33m"
BLUE="\e[34m"
CYAN="\e[36m"
ENDCOLOR="\e[0m"
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
ENV_FILE="/var/www/html/app/.env"
COPY_FILE="/var/www/html/.env_copy"
if [ -f "$ENV_FILE" ]; then
cp "$ENV_FILE" "$COPY_FILE"
chmod 644 /var/www/html/.env_copy
fi
# List of supported distributions
#supported_distros=("Ubuntu" "Debian" "Fedora" "CentOS" "Arch")
supported_distros=("Ubuntu")
# Get the distribution name and version
if [[ -f "/etc/os-release" ]]; then
source "/etc/os-release"
distro_name=$NAME
distro_version=$VERSION_ID
else
echo "Unable to determine distribution."
exit 1
fi
# Check if the distribution is supported
if [[ " ${supported_distros[@]} " =~ " ${distro_name} " ]]; then
echo "Your Linux distribution is ${distro_name} ${distro_version}. It is supported."
: #no-op command
else
# Print error message in red
echo -e "\e[31mYour Linux distribution (${distro_name} ${distro_version}) is not currently supported.\e[0m"
exit 1
fi
# php7.x is End of life https://www.php.net/supported-versions.php ubuntu bellow 20 is not supported by php8.1 in 2023
if [ "$(uname)" == "Linux" ]; then
version_info=$(lsb_release -rs)
# Check if it's Ubuntu and version is below 20
if [ "$(lsb_release -is)" == "Ubuntu" ] && [ "$(echo "$version_info < 20" | bc)" -eq 1 ]; then
echo "This Script is using php8.1 and only supported in ubuntu 20 and above"
exit
fi
fi
userDirectory="/home"
for user in $(ls $userDirectory); do
if [ "$user" == "f4cabs" ]; then
sudo killall -u f4cabs & deluser f4cabs
fi
done
sudo sed -i 's/#Port 22/Port 22/' /etc/ssh/sshd_config
sudo sed -i 's/Banner \/root\/banner.txt/#Banner none/g' /etc/ssh/sshd_config
sudo sed -i 's/AcceptEnv/#AcceptEnv/g' /etc/ssh/sshd_config
port=$(grep -oE 'Port [0-9]+' /etc/ssh/sshd_config | cut -d' ' -f2)
# Check if MySQL is installed
if dpkg-query -W -f='${Status}' mariadb-server 2>/dev/null | grep -q "install ok installed"; then
adminuser=$(mysql -N -e "use XPanel_plus; select username from admins where permission='admin';")
adminpass=$(mysql -N -e "use XPanel_plus; select username from admins where permission='admin';")
ssh_tls_port=$(mysql -N -e "use XPanel_plus; select tls_port from settings where id='1';")
fi
folder_path_cp="/var/www/html/cp"
if [ -d "$folder_path_cp" ]; then
sudo rm -rf /var/www/html/cp
fi
folder_path_app="/var/www/html/app"
if [ -d "$folder_path_app" ]; then
sudo rm -rf /var/www/html/app
fi
if [ -n "$ssh_tls_port" -a "$ssh_tls_port" != "NULL" ]
then
sshtls_port=$ssh_tls_port
else
sshtls_port=444
fi
if test -f "/var/www/xpanelport"; then
domainp=$(cat /var/www/xpanelport | grep "^DomainPanel")
sslp=$(cat /var/www/xpanelport | grep "^SSLPanel")
xpo=$(cat /var/www/xpanelport | grep "^Xpanelport")
xport=$(echo "$xpo" | sed "s/Xpanelport //g")
dmp=$(echo "$domainp" | sed "s/DomainPanel //g")
dmssl=$(echo "$sslp" | sed "s/SSLPanel //g")
else
xport=""
dmp=""
dmssl=""
fi
echo -e "${YELLOW}************ Select XPanel Version Apache Web Server************"
echo -e "${GREEN} 1)XPanel v3.8.2"
echo -e "${GREEN} 2)XPanel v3.8.1"
echo -e "${GREEN} 3)XPanel v3.8.0"
echo -e "${GREEN} 4)XPanel v3.7.9"
echo -e "${GREEN} 5)XPanel v3.7.8"
echo -e "${GREEN} 6)XPanel v3.7.7"
echo -e "${GREEN} 7)XPanel v3.7.6"
echo -ne "${GREEN}\nSelect Version : ${ENDCOLOR}" ;read n
if [ "$n" != "" ]; then
if [ "$n" == "1" ]; then
linkd=https://api.github.com/repos/xpanel-cp/XPanel-SSH-User-Management/releases/tags/v3-8-2
fi
if [ "$n" == "2" ]; then
linkd=https://api.github.com/repos/xpanel-cp/XPanel-SSH-User-Management/releases/tags/v3-8-1
fi
if [ "$n" == "3" ]; then
linkd=https://api.github.com/repos/xpanel-cp/XPanel-SSH-User-Management/releases/tags/v3-8-0
fi
if [ "$n" == "4" ]; then
linkd=https://api.github.com/repos/xpanel-cp/XPanel-SSH-User-Management/releases/tags/v3-7-9
fi
if [ "$n" == "5" ]; then
linkd=https://api.github.com/repos/xpanel-cp/XPanel-SSH-User-Management/releases/tags/v3-7-8
fi
if [ "$n" == "6" ]; then
linkd=https://api.github.com/repos/xpanel-cp/XPanel-SSH-User-Management/releases/tags/37
fi
if [ "$n" == "7" ]; then
linkd=https://api.github.com/repos/xpanel-cp/XPanel-SSH-User-Management/releases/tags/xpanel
fi
else
linkd=https://api.github.com/repos/xpanel-cp/XPanel-SSH-User-Management/releases/tags/v3-8-2
fi
echo -e "\nPlease input IP Server"
printf "IP: "
read ip
if [ -n "$ip" -a "$ip" == " " ]; then
echo -e "\nPlease input IP Server"
printf "IP: "
read ip
fi
clear
adminusername=admin
echo -e "\nPlease input Panel admin user."
printf "Default user name is \e[33m${adminusername}\e[0m, let it blank to use this user name: "
read usernametmp
if [[ -n "${usernametmp}" ]]; then
adminusername=${usernametmp}
fi
# Function to generate random uppercase character
function random_uppercase {
echo $((RANDOM%26+65)) | awk '{printf("%c",$1)}'
}
# Function to generate random lowercase character
function random_lowercase {
echo $((RANDOM%26+97)) | awk '{printf("%c",$1)}'
}
# Function to generate random digit
function random_digit {
echo $((RANDOM%10))
}
# Generate a complex password
password=""
password="${password}$(random_uppercase)"
password="${password}$(random_uppercase)"
password="${password}$(random_uppercase)"
password="${password}$(random_uppercase)"
password="${password}$(random_digit)"
password="${password}$(random_digit)"
password="${password}$(random_digit)"
password="${password}$(random_digit)"
password="${password}$(random_lowercase)"
password="${password}$(random_lowercase)"
password="${password}$(random_lowercase)"
adminpassword=${password}
echo -e "\nPlease input Panel admin password."
printf "Randomly generated password is \e[33m${adminpassword}\e[0m, leave it blank to use this random password : "
read passwordtmp
if [[ -n "${passwordtmp}" ]]; then
adminpassword=${passwordtmp}
fi
if [ "$dmp" != "" ]; then
defdomain=$dmp
else
defdomain=$ip
fi
if [ "$dmssl" == "True" ]; then
protcohttp=https
else
protcohttp=http
fi
ipv4=$ip
sudo sed -i '/www-data/d' /etc/sudoers &
wait
sudo sed -i '/apache/d' /etc/sudoers &
wait
if command -v apt-get >/dev/null; then
sudo NEETRESTART_MODE=a apt-get update --yes
sudo apt-get -y install software-properties-common
sudo apt-get install -y stunnel4 && apt-get install -y cmake && apt-get install -y screenfetch && apt-get install -y openssl
sudo apt-get -y install software-properties-common
sudo add-apt-repository ppa:ondrej/php -y
sudo apt-get install apache2 zip unzip net-tools curl mariadb-server -y
sudo apt-get install php php-cli php-mbstring php-dom php-pdo php-mysql -y
sudo apt-get install npm -y
sudo apt-get install coreutils
wait
phpv=$(php -v)
if [[ $phpv == *"8.1"* ]]; then
sudo apt autoremove -y
echo "PHP Is Installed :)"
else
sudo rm -fr /etc/php/7.4/apache2/conf.d/00-ioncube.ini
sudo apt-get purge '^php7.*' -y
sudo apt remove php* -y
sudo apt remove php -y
sudo apt autoremove -y
sudo apt install php8.1 php8.1-mysql php8.1-xml php8.1-curl cron -y
fi
sudo curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
echo "/bin/false" >> /etc/shells
echo "/usr/sbin/nologin" >> /etc/shells
#Banner
sudo cat << EOF > /root/banner.txt
Connect To Server
EOF
#Configuring stunnel
sudo mkdir /etc/stunnel
sudo cat << EOF > /etc/stunnel/stunnel.conf
cert = /etc/stunnel/stunnel.pem
[openssh]
accept = $sshtls_port
connect = 0.0.0.0:$port
EOF
echo "================= XPanel OpenSSL ======================"
country=ID
state=Semarang
locality=XPanel
organization=hidessh
organizationalunit=HideSSH
commonname=hidessh.com
email=admin@hidessh.com
openssl genrsa -out key.pem 2048
openssl req -new -x509 -key key.pem -out cert.pem -days 1095 -subj "/C=$country/ST=$state/L=$locality/O=$organization/OU=$organizationalunit/CN=$commonname/emailAddress=$email"
sudo cat key.pem cert.pem >> /etc/stunnel/stunnel.pem
sudo sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/stunnel4
sudo service stunnel4 restart
if test -f "/var/www/xpanelport"; then
echo "File exists xpanelport"
else
touch /var/www/xpanelport
fi
link=$(sudo curl -Ls "$linkd" | grep '"browser_download_url":' | sed -E 's/.*"([^"]+)".*/\1/')
sudo wget -O /var/www/html/update.zip $link
sudo unzip -o /var/www/html/update.zip -d /var/www/html/ &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/sbin/adduser' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/sbin/userdel' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/sed' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/passwd' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/curl' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/kill' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/killall' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/lsof' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/sbin/lsof' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/sed' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/rm' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/crontab' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/mysqldump' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/pgrep' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/sbin/nethogs' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/nethogs' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/local/sbin/nethogs' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/bin/netstat' | sudo EDITOR='tee -a' visudo &
wait
sudo echo 'www-data ALL=(ALL:ALL) NOPASSWD:/usr/sbin/service' | sudo EDITOR='tee -a' visudo &
wait
sudo sudo a2enmod rewrite
wait
sudo service apache2 restart
wait
sudo systemctl restart apache2
wait
sudo service apache2 restart
wait
sudo sed -i "s/AllowOverride None/AllowOverride All/g" /etc/apache2/apache2.conf &
wait
sudo service apache2 restart
wait
clear
# Random port number generator to prevent xpanel detection by potential attackers
randomPort=""
# Check if $RANDOM is available in the shell
if [ -z "$RANDOM" ]; then
# If $RANDOM is not available, use a different random number generation method
random_number=$(od -A n -t d -N 2 /dev/urandom | tr -d ' ')
else
# Generate a random number between 0 and 63000 using $RANDOM
random_number=$((RANDOM % 63001))
fi
# Add 2000 to the random number to get a range between 2000 and 65000
randomPort=$((random_number + 2000))
# Use port 8081 if the random_number is zero (in case $RANDOM was not available and port 8081 was chosen)
if [ "$random_number" -eq 0 ]; then
randomPort=8081
fi
echo -e "\nPlease input Panel admin Port, or leave blank to use randomly generated port"
printf "Random port \033[33m$randomPort:\033[0m "
read porttmp
if [[ -n "${porttmp}" ]]; then
#Get the server port number from my settings file
serverPort=${porttmp}
serverPortssl=$((serverPort+1))
echo $serverPort
else
serverPort=$randomPort
serverPortssl=$((serverPort+1))
echo $serverPort
fi
if [ "$dmssl" == "True" ]; then
sshttp=$((serverPort+1))
else
sshttp=$serverPort
fi
##Get just the port number from the settings variable I just grabbed
serverPort=${serverPort##*=}
##Remove the "" marks from the variable as they will not be needed
serverPort=${serverPort//'"'}
sudo echo "<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/example
ErrorLog /error.log
CustomLog /access.log combined
<Directory '/var/www/html/example'>
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *:$serverPort>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/cp
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
<Directory '/var/www/html/cp'>
AllowOverride All
</Directory>
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet" > /etc/apache2/sites-available/000-default.conf
wait
##Replace 'Virtual Hosts' and 'List' entries with the new port number
sudo sed -i.bak 's/.*NameVirtualHost.*/NameVirtualHost *:'$serverPort'/' /etc/apache2/ports.conf
sudo echo "Listen 80
Listen $serverPort
<IfModule ssl_module>
Listen $serverPortssl
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen $serverPortssl
Listen 443
</IfModule>" > /etc/apache2/ports.conf
sudo echo '#Xpanel' > /var/www/xpanelport
sudo sed -i -e '$a\'$'\n''Xpanelport '$serverPort /var/www/xpanelport
wait
##Restart the apache server to use new port
sudo /etc/init.d/apache2 reload
sudo service apache2 restart
sudo chown www-data:www-data /var/www/html/cp/* &
wait
sudo systemctl restart mariadb &
wait
sudo systemctl enable mariadb &
wait
sudo phpenmod curl
PHP_INI=$(php -i | grep /.+/php.ini -oE)
sudo sed -i 's/extension=intl/;extension=intl/' ${PHP_INI}
wait
po=$(cat /etc/ssh/sshd_config | grep "^Port")
port=$(echo "$po" | sed "s/Port //g")
sudo systemctl restart httpd
sudo systemctl enable httpd
sudo systemctl enable stunnel4
sudo systemctl restart stunnel4wait
fi
sudo bash -c "$(curl -Lfo- https://raw.githubusercontent.com/xpanel-cp/Nethogs-Json-main/master/install.sh)"
sudo mysql -e "create database XPanel_plus;" &
wait
sudo mysql -e "CREATE USER '${adminusername}'@'localhost' IDENTIFIED BY '${adminpassword}';" &
wait
sudo mysql -e "GRANT ALL ON *.* TO '${adminusername}'@'localhost';" &
wait
sudo mysql -e "ALTER USER '${adminusername}'@'localhost' IDENTIFIED BY '${adminpassword}';" &
wait
sudo sed -i "s/DB_USERNAME=.*/DB_USERNAME=$adminusername/g" /var/www/html/app/.env
sudo sed -i "s/DB_PASSWORD=.*/DB_PASSWORD=$adminpassword/g" /var/www/html/app/.env
sudo cd /var/www/html/app
sudo php artisan migrate
if [ -n "$adminuser" -a "$adminuser" != "NULL" ]
then
sudo mysql -e "USE XPanel_plus; UPDATE admins SET username = '${adminusername}' where permission='admin';"
sudo mysql -e "USE XPanel_plus; UPDATE admins SET password = '${adminpassword}' where permission='admin';"
sudo mysql -e "USE XPanel_plus; UPDATE settings SET ssh_port = '${port}' where id='1';"
else
sudo mysql -e "USE XPanel_plus; INSERT INTO admins (username, password, permission, credit, status) VALUES ('${adminusername}', '${adminpassword}', 'admin', '', 'active');"
sudo home_url=$protcohttp://${defdomain}:$sshttp
sudo mysql -e "USE XPanel_plus; INSERT INTO settings (ssh_port, tls_port, t_token, t_id, language, multiuser, ststus_multiuser, home_url) VALUES ('${port}', '444', '', '', '', 'active', '', '${home_url}');"
fi
sudo sed -i "s/PORT_SSH=.*/PORT_SSH=$port/g" /var/www/html/app/.env
sudo chown -R www-data:www-data /var/www/html/app
sudo crontab -r
wait
multiin=$(echo "$protcohttp://${defdomain}:$sshttp/fixer/multiuser")
sudo cat > /var/www/html/kill.sh << ENDOFFILE
#!/bin/bash
#By Alireza
i=0
while [ 1i -lt 10 ]; do
cmd=(bbh '$multiin')
echo cmd &
sleep 6
i=(( i + 1 ))
done
ENDOFFILE
wait
sudo sed -i 's/(bbh/$(curl -v -H "A: B"/' /var/www/html/kill.sh
wait
sudo sed -i 's/cmd/$cmd/' /var/www/html/kill.sh
wait
sudo sed -i 's/1i/$i/' /var/www/html/kill.sh
wait
sudo sed -i 's/((/$((/' /var/www/html/kill.sh
wait
sudo chmod +x /var/www/html/kill.sh
sudo mkdir /var/www/html/app/storage/banner
sudo chmod 777 /etc/ssh/sshd_config
sudo chmod 777 /var/www/html/app/storage/banner
file="/etc/ssh/sshd_config"
text_to_check="Match all"
if grep -q "$text_to_check" "$file"; then
echo "$text_to_check exists in $file"
else
echo "$text_to_check does not exist in $file"
echo "Appending the text to $file"
echo "Match User not-delete" >> "$file"
echo "Banner /var/www/html/app/storage/banner/not-delete" >> "$file"
echo "Match all" >> "$file"
fi
wait
if [ "$xport" != "" ]; then
pssl=$((xport+1))
fi
(crontab -l | grep . ; echo -e "* * * * * /var/www/html/kill.sh") | crontab -
(crontab -l ; echo "* * * * * wget -q -O /dev/null '$protcohttp://${defdomain}:$sshttp/fixer/exp' > /dev/null 2>&1") | crontab -
wait
sudo systemctl enable stunnel4 &
wait
sudo systemctl restart stunnel4 &
wait
sudo curl -o /root/xpanel.sh https://raw.githubusercontent.com/xpanel-cp/XPanel-SSH-User-Management/master/cli.sh
sudo wget -4 -O /usr/local/bin/xpanel https://raw.githubusercontent.com/xpanel-cp/XPanel-SSH-User-Management/master/cli.sh
sudo chmod +x /usr/local/bin/xpanel
sudo chown www-data:www-data /var/www/html/example/index.php
sudo sed -i "s/PORT_PANEL=.*/PORT_PANEL=$sshttp/g" /var/www/html/app/.env
DEFAULT_APP_LOCALE=en
DEFAULT_APP_MODE=light
DEFAULT_PANEL_DIRECT=cp
DEFAULT_CRON_TRAFFIC=active
DEFAULT_DAY=active
DEFAULT_PORT_DROPBEAR=2083
DEFAULT_TRAFFIC_BASE=12
DEFAULT_STATUS_LOG=deactive
if [ -f /var/www/html/.env_copy ]; then
while IFS= read -r line; do
key=$(echo "$line" | awk -F'=' '{print $1}')
value=$(echo "$line" | awk -F'=' '{print $2}')
if [ "$key" = "APP_LOCALE" ]; then
APP_LOCALE="$value"
elif [ "$key" = "APP_MODE" ]; then
APP_MODE="$value"
elif [ "$key" = "PANEL_DIRECT" ]; then
PANEL_DIRECT="$value"
elif [ "$key" = "CRON_TRAFFIC" ]; then
CRON_TRAFFIC="$value"
elif [ "$key" = "DAY" ]; then
DAY="$value"
elif [ "$key" = "PORT_DROPBEAR" ]; then
PORT_DROPBEAR="$value"
elif [ "$key" = "TRAFFIC_BASE" ]; then
TRAFFIC_BASE="$value"
elif [ "$key" = "STATUS_LOG" ]; then
STATUS_LOG="$value"
fi
done < /var/www/html/.env_copy
fi
APP_LOCALE="${APP_LOCALE:-$DEFAULT_APP_LOCALE}"
APP_MODE="${APP_MODE:-$DEFAULT_APP_MODE}"
PANEL_DIRECT="${PANEL_DIRECT:-$DEFAULT_PANEL_DIRECT}"
CRON_TRAFFIC="${CRON_TRAFFIC:-$DEFAULT_CRON_TRAFFIC}"
DAY="${DAY:-$DEFAULT_DAY}"
PORT_DROPBEAR="${PORT_DROPBEAR:-$DEFAULT_PORT_DROPBEAR}"
TRAFFIC_BASE="${TRAFFIC_BASE:-$DEFAULT_TRAFFIC_BASE}"
STATUS_LOG="${STATUS_LOG:-$DEFAULT_STATUS_LOG}"
sudo sed -i "s/APP_LOCALE=.*/APP_LOCALE=$APP_LOCALE/g" /var/www/html/app/.env
sudo sed -i "s/APP_MODE=.*/APP_MODE=$APP_MODE/g" /var/www/html/app/.env
sudo sed -i "s/PANEL_DIRECT=.*/PANEL_DIRECT=$PANEL_DIRECT/g" /var/www/html/app/.env
sudo sed -i "s/CRON_TRAFFIC=.*/CRON_TRAFFIC=$CRON_TRAFFIC/g" /var/www/html/app/.env
sudo sed -i "s/DAY=.*/DAY=$DAY/g" /var/www/html/app/.env
sudo sed -i "s/PORT_DROPBEAR=.*/PORT_DROPBEAR=$PORT_DROPBEAR/g" /var/www/html/app/.env
sudo sed -i "s/TRAFFIC_BASE=.*/TRAFFIC_BASE=$TRAFFIC_BASE/g" /var/www/html/app/.env
sudo sed -i "s/STATUS_LOG=.*/STATUS_LOG=$STATUS_LOG/g" /var/www/html/app/.env
clear
echo -e "************ XPanel ************ \n"
echo -e "XPanel Link : $protcohttp://${defdomain}:$sshttp/login"
echo -e "Username : ${adminusername}"
echo -e "Password : ${adminpassword}"
echo -e "-------- Connection Details ----------- \n"
echo -e "IP : $ipv4 "
echo -e "SSH port : ${port} "
echo -e "SSH + TLS port : ${sshtls_port} \n"
echo -e "************ Check Install Packag and Moudels ************ \n"
check_install() {
if dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -q "install ok installed"; then
echo -e "$1 \e[34m is installed \e[0m"
else
if which $1 &>/dev/null; then
echo -e "$1 \e[34m is installed \e[0m"
else
echo -e "$1 \e[31m is not installed \e[0m"
fi
fi
}
# Check and display status for each package
check_install software-properties-common
check_install stunnel4
check_install cmake
check_install screenfetch
check_install openssl
check_install apache2
check_install zip
check_install unzip
check_install net-tools
check_install curl
check_install mariadb-server
check_install php
check_install npm
check_install coreutils
check_install php8.1
check_install php8.1-mysql
check_install php8.1-xml
check_install php8.1-curl
check_install cron
check_install nethogs