forked from pterodactyl-installer/pterodactyl-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-panel.sh
executable file
·904 lines (736 loc) · 26.1 KB
/
install-panel.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
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
#!/bin/bash
#############################################################################
# #
# Project 'pterodactyl-installer' for panel #
# #
# Copyright (C) 2018 - 2020, Vilhelm Prytz, <[email protected]>, et al. #
# #
# This script is licensed under the terms of the GNU GPL v3.0 license #
# https://github.com/vilhelmprytz/pterodactyl-installer/blob/master/LICENSE #
# #
# This script is not associated with the official Pterodactyl Project. #
# https://github.com/vilhelmprytz/pterodactyl-installer #
# #
#############################################################################
# exit with error status code if user is not root
if [[ $EUID -ne 0 ]]; then
echo "* This script must be executed with root privileges (sudo)." 1>&2
exit 1
fi
# check for curl
CURLPATH="$(command -v curl)"
if [ -z "$CURLPATH" ]; then
echo "* curl is required in order for this script to work."
echo "* install using apt on Debian/Ubuntu or yum on CentOS"
exit 1
fi
# define version using information from GitHub
get_latest_release() {
curl --silent "https://api.github.com/repos/$1/releases/latest" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
echo "* Retrieving release information.."
PTERODACTYL_VERSION="$(get_latest_release "pterodactyl/panel")"
echo "* Latest version is $PTERODACTYL_VERSION"
# variables
WEBSERVER="nginx"
FQDN=""
# default MySQL credentials
MYSQL_DB="pterodactyl"
MYSQL_USER="pterodactyl"
MYSQL_PASSWORD=""
# assume SSL, will fetch different config if true
ASSUME_SSL=false
CONFIGURE_LETSENCRYPT=false
# download URLs
PANEL_DL_URL="https://github.com/pterodactyl/panel/releases/latest/download/panel.tar.gz"
CONFIGS_URL="https://raw.githubusercontent.com/vilhelmprytz/pterodactyl-installer/master/configs"
# apt sources path
SOURCES_PATH="/etc/apt/sources.list"
# ufw firewall
CONFIGURE_UFW=false
# visual functions
function print_error {
COLOR_RED='\033[0;31m'
COLOR_NC='\033[0m'
echo ""
echo -e "* ${COLOR_RED}ERROR${COLOR_NC}: $1"
echo ""
}
function print_warning {
COLOR_YELLOW='\033[1;33m'
COLOR_NC='\033[0m'
echo ""
echo -e "* ${COLOR_YELLOW}WARNING${COLOR_NC}: $1"
echo ""
}
function print_brake {
for ((n=0;n<$1;n++));
do
echo -n "#"
done
echo ""
}
# other functions
function detect_distro {
if [ -f /etc/os-release ]; then
# freedesktop.org and systemd
. /etc/os-release
OS=$(echo "$ID" | awk '{print tolower($0)}')
OS_VER=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
# linuxbase.org
OS=$(lsb_release -si | awk '{print tolower($0)}')
OS_VER=$(lsb_release -sr)
elif [ -f /etc/lsb-release ]; then
# For some versions of Debian/Ubuntu without lsb_release command
. /etc/lsb-release
OS=$(echo "$DISTRIB_ID" | awk '{print tolower($0)}')
OS_VER=$DISTRIB_RELEASE
elif [ -f /etc/debian_version ]; then
# Older Debian/Ubuntu/etc.
OS="debian"
OS_VER=$(cat /etc/debian_version)
elif [ -f /etc/SuSe-release ]; then
# Older SuSE/etc.
OS="SuSE"
OS_VER="?"
elif [ -f /etc/redhat-release ]; then
# Older Red Hat, CentOS, etc.
OS="Red Hat/CentOS"
OS_VER="?"
else
# Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
OS=$(uname -s)
OS_VER=$(uname -r)
fi
OS=$(echo "$OS" | awk '{print tolower($0)}')
OS_VER_MAJOR=$(echo "$OS_VER" | cut -d. -f1)
}
function check_os_comp {
if [ "$OS" == "ubuntu" ]; then
if [ "$OS_VER_MAJOR" == "16" ]; then
SUPPORTED=true
PHP_SOCKET="/run/php/php7.2-fpm.sock"
elif [ "$OS_VER_MAJOR" == "18" ]; then
SUPPORTED=true
PHP_SOCKET="/run/php/php7.2-fpm.sock"
else
SUPPORTED=false
fi
elif [ "$OS" == "zorin" ]; then
if [ "$OS_VER_MAJOR" == "15" ]; then
SUPPORTED=true
PHP_SOCKET="/run/php/php7.2-fpm.sock"
else
SUPPORTED=false
fi
elif [ "$OS" == "debian" ]; then
if [ "$OS_VER_MAJOR" == "8" ]; then
SUPPORTED=true
PHP_SOCKET="/run/php/php7.3-fpm.sock"
elif [ "$OS_VER_MAJOR" == "9" ]; then
SUPPORTED=true
PHP_SOCKET="/run/php/php7.3-fpm.sock"
elif [ "$OS_VER_MAJOR" == "10" ]; then
SUPPORTED=true
PHP_SOCKET="/run/php/php7.3-fpm.sock"
else
SUPPORTED=false
fi
elif [ "$OS" == "centos" ]; then
if [ "$OS_VER_MAJOR" == "7" ]; then
SUPPORTED=true
PHP_SOCKET="/var/run/php-fpm/pterodactyl.sock"
elif [ "$OS_VER_MAJOR" == "8" ]; then
SUPPORTED=true
PHP_SOCKET="/var/run/php-fpm/pterodactyl.sock"
else
SUPPORTED=false
fi
else
SUPPORTED=false
fi
# exit if not supported
if [ "$SUPPORTED" == true ]; then
echo "* $OS $OS_VER is supported."
else
echo "* $OS $OS_VER is not supported"
print_error "Unsupported OS"
exit 1
fi
}
#################################
## main installation functions ##
#################################
function install_composer {
echo "* Installing composer.."
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
echo "* Composer installed!"
}
function ptdl_dl {
echo "* Downloading pterodactyl panel files .. "
mkdir -p /var/www/pterodactyl
cd /var/www/pterodactyl || exit
curl -Lo panel.tar.gz "$PANEL_DL_URL"
tar --strip-components=1 -xzvf panel.tar.gz
chmod -R 755 storage/* bootstrap/cache/
cp .env.example .env
composer install --no-dev --optimize-autoloader
php artisan key:generate --force
echo "* Downloaded pterodactyl panel files & installed composer dependencies!"
}
function configure {
print_brake 88
echo "* Please follow the steps below. The installer will ask you for configuration details."
print_brake 88
echo ""
php artisan p:environment:setup
print_brake 67
echo "* The installer will now ask you for MySQL database credentials."
print_brake 67
echo ""
php artisan p:environment:database
print_brake 70
echo "* The installer will now ask you for mail setup / mail credentials."
print_brake 70
echo ""
php artisan p:environment:mail
# configures database
print_warning "You must type 'yes' or else the installer will fail! The default response 'no' will not properly initialize the database!"
php artisan migrate --seed
echo "* The installer will now ask you to create the initial admin user account."
php artisan p:user:make
# set folder permissions now
set_folder_permissions
}
# set the correct folder permissions depending on OS and webserver
function set_folder_permissions {
# if os is ubuntu or debian, we do this
if [ "$OS" == "debian" ] || [ "$OS" == "ubuntu" ] || [ "$OS" == "zorin" ]; then
chown -R www-data:www-data ./*
elif [ "$OS" == "centos" ] && [ "$WEBSERVER" == "nginx" ]; then
chown -R nginx:nginx ./*
elif [ "$OS" == "centos" ] && [ "$WEBSERVER" == "apache" ]; then
chown -R apache:apache ./*
else
print_error "Invalid webserver and OS setup."
exit 1
fi
}
# insert cronjob
function insert_cronjob {
echo "* Installing cronjob.. "
crontab -l | { cat; echo "* * * * * php /var/www/pterodactyl/artisan schedule:run >> /dev/null 2>&1"; } | crontab -
echo "* Cronjob installed!"
}
function install_pteroq {
echo "* Installing pteroq service.."
curl -o /etc/systemd/system/pteroq.service $CONFIGS_URL/pteroq.service
systemctl enable pteroq.service
systemctl start pteroq
echo "* Installed pteroq!"
}
function create_database {
if [ "$OS" == "centos" ]; then
# secure MariaDB
echo "* MariaDB secure installation. The following are safe defaults."
echo "* Set root password? [Y/n] Y"
echo "* Remove anonymous users? [Y/n] Y"
echo "* Disallow root login remotely? [Y/n] Y"
echo "* Remove test database and access to it? [Y/n] Y"
echo "* Reload privilege tables now? [Y/n] Y"
echo "*"
mysql_secure_installation
echo "* The script should have asked you to set the MySQL root password earlier (not to be confused with the pterodactyl database user password)"
echo "* MySQL will now ask you to enter the password before each command."
echo "* Create MySQL user."
mysql -u root -p -e "CREATE USER '${MYSQL_USER}'@'127.0.0.1' IDENTIFIED BY '${MYSQL_PASSWORD}';"
echo "* Create database."
mysql -u root -p -e "CREATE DATABASE ${MYSQL_DB};"
echo "* Grant privileges."
mysql -u root -p -e "GRANT ALL PRIVILEGES ON ${MYSQL_DB}.* TO '${MYSQL_USER}'@'127.0.0.1' WITH GRANT OPTION;"
echo "* Flush privileges."
mysql -u root -p -e "FLUSH PRIVILEGES;"
else
echo "* Performing MySQL queries.."
echo "* Creating MySQL user.."
mysql -u root -e "CREATE USER '${MYSQL_USER}'@'127.0.0.1' IDENTIFIED BY '${MYSQL_PASSWORD}';"
echo "* Creating database.."
mysql -u root -e "CREATE DATABASE ${MYSQL_DB};"
echo "* Granting privileges.."
mysql -u root -e "GRANT ALL PRIVILEGES ON ${MYSQL_DB}.* TO '${MYSQL_USER}'@'127.0.0.1' WITH GRANT OPTION;"
echo "* Flushing privileges.."
mysql -u root -e "FLUSH PRIVILEGES;"
echo "* MySQL database created & configured!"
fi
}
##################################
# OS specific install functions ##
##################################
function apt_update {
apt update -y && apt upgrade -y
}
function ubuntu18_dep {
echo "* Installing dependencies for Ubuntu 18.."
# Add "add-apt-repository" command
apt -y install software-properties-common
# Add additional repositories for PHP, Redis, and MariaDB
# Update repositories list
apt update
# Install Dependencies
apt -y install php7.2 php7.2-cli php7.2-gd php7.2-mysql php7.2-pdo php7.2-mbstring php7.2-tokenizer php7.2-bcmath php7.2-xml php7.2-fpm php7.2-curl php7.2-zip mariadb-server nginx curl tar unzip git redis-server redis
# enable services
systemctl start mariadb
systemctl enable mariadb
systemctl start redis-server
systemctl enable redis-server
echo "* Dependencies for Ubuntu installed!"
}
function ubuntu16_dep {
echo "* Installing dependencies for Ubuntu 16.."
# Add "add-apt-repository" command
apt -y install software-properties-common
# Add additional repositories for PHP, Redis, and MariaDB
LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
add-apt-repository -y ppa:chris-lea/redis-server
# Update repositories list
apt update
# Install Dependencies
apt -y install php7.2 php7.2-cli php7.2-gd php7.2-mysql php7.2-pdo php7.2-mbstring php7.2-tokenizer php7.2-bcmath php7.2-xml php7.2-fpm php7.2-curl php7.2-zip mariadb-server nginx curl tar unzip git redis-server
# enable services
systemctl start mariadb
systemctl enable mariadb
systemctl start redis-server
systemctl enable redis-server
echo "* Dependencies for Ubuntu installed!"
}
function debian_jessie_dep {
echo "* Installing dependencies for Debian 8/9.."
# MariaDB need dirmngr
apt -y install dirmngr
# install PHP 7.3 using sury's repo instead of PPA
# this guide shows how: https://vilhelmprytz.se/2018/08/22/install-php72-on-Debian-8-and-9.html
apt install ca-certificates apt-transport-https lsb-release -y
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" | tee /etc/apt/sources.list.d/php.list
# redis-server is not installed using the PPA, as it's already available in the Debian repo
# Update repositories list
apt update
# Install Dependencies
apt -y install php7.3 php7.3-cli php7.3-gd php7.3-mysql php7.3-pdo php7.3-mbstring php7.3-tokenizer php7.3-bcmath php7.3-xml php7.3-fpm php7.3-curl php7.3-zip mariadb-server nginx curl tar unzip git redis-server
# enable services
systemctl start mariadb
systemctl enable mariadb
systemctl start redis-server
systemctl enable redis-server
echo "* Dependencies for Debian 8/9 installed!"
}
function debian_dep {
echo "* Installing dependencies for Debian 10.."
# MariaDB need dirmngr
apt -y install dirmngr
# Update repositories list
apt update
# install dependencies
apt -y install php7.3 php7.3-cli php7.3-common php7.3-gd php7.3-mysql php7.3-mbstring php7.3-bcmath php7.3-xml php7.3-fpm php7.3-curl php7.3-zip mariadb-server nginx curl tar unzip git redis-server
# enable services
systemctl start mariadb
systemctl enable mariadb
systemctl start redis-server
systemctl enable redis-server
echo "* Dependencies for Debian 10 installed!"
}
function centos7_dep {
echo "* Installing dependencies for CentOS 7.."
# update first
yum update -y
# SELinux tools
yum install -y policycoreutils policycoreutils-python selinux-policy selinux-policy-targeted libselinux-utils setroubleshoot-server setools setools-console mcstrans
# install php7.3
yum install -y epel-release http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install -y yum-utils
yum-config-manager --disable remi-php54
yum-config-manager --enable remi-php73
yum update -y
# Install MariaDB
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
# install dependencies
yum -y install php php-common php-fpm php-cli php-json php-mysqlnd php-mcrypt php-gd php-mbstring php-pdo php-zip php-bcmath php-dom php-opcache mariadb-server nginx curl tar zip unzip git redis
# enable services
systemctl enable mariadb
systemctl enable redis
systemctl start mariadb
systemctl start redis
# SELinux (allow nginx and redis)
setsebool -P httpd_can_network_connect 1
setsebool -P httpd_execmem 1
setsebool -P httpd_unified 1
echo "* Dependencies for CentOS installed!"
}
function centos8_dep {
echo "* Installing dependencies for CentOS 8.."
# update first
dnf update -y
# SELinux tools
dnf install -y policycoreutils selinux-policy selinux-policy-targeted setroubleshoot-server setools setools-console mcstrans
# Install php 7.2
dnf install -y php php-common php-fpm php-cli php-json php-mysqlnd php-gd php-mbstring php-pdo php-zip php-bcmath php-dom php-opcache
# MariaDB (use from official repo)
dnf install -y mariadb mariadb-server
# Other dependencies
dnf install -y nginx curl tar zip unzip git redis
# enable services
systemctl enable mariadb
systemctl enable redis
systemctl start mariadb
systemctl start redis
# SELinux (allow nginx and redis)
setsebool -P httpd_can_network_connect 1
setsebool -P httpd_execmem 1
setsebool -P httpd_unified 1
echo "* Dependencies for CentOS installed!"
}
#################################
## OTHER OS SPECIFIC FUNCTIONS ##
#################################
function ubuntu_universedep {
# Probably should change this, this is more of a bandaid fix for this
# This function is ran before software-properties-common is installed
apt update -y
apt install software-properties-common -y
if grep -q universe "$SOURCES_PATH"; then
# even if it detects it as already existent, we'll still run the apt command to make sure
add-apt-repository universe
echo "* Ubuntu universe repo already exists."
else
add-apt-repository universe
fi
}
function centos_php {
curl -o /etc/php-fpm.d/www-pterodactyl.conf $CONFIGS_URL/www-pterodactyl.conf
systemctl enable php-fpm
systemctl start php-fpm
}
function firewall_ufw {
apt update
apt install ufw -y
echo -e "\n* Enabling Uncomplicated Firewall (UFW)"
echo "* Opening port 22 (SSH), 80 (HTTP) and 443 (HTTPS)"
# pointing to /dev/null silences the command output
ufw allow ssh > /dev/null
ufw allow http > /dev/null
ufw allow https > /dev/null
ufw enable
ufw status numbered | sed '/v6/d'
}
function debian_based_letsencrypt {
# Install certbot and setup the certificate using the FQDN
apt install certbot -y
systemctl stop nginx
echo -e "\nMake sure you choose Option 1, and create a Standalone Web Server during the certificate"
certbot certonly -d "$FQDN"
systemctl restart nginx
}
#######################################
## WEBSERVER CONFIGURATION FUNCTIONS ##
#######################################
function configure_nginx {
echo "* Configuring nginx .."
if [ "$ASSUME_SSL" == true ]; then
DL_FILE="nginx_ssl.conf"
else
DL_FILE="nginx.conf"
fi
if [ "$OS" == "centos" ]; then
# remove default config
rm -rf /etc/nginx/conf.d/default
# download new config
curl -o /etc/nginx/conf.d/pterodactyl.conf $CONFIGS_URL/$DL_FILE
# replace all <domain> places with the correct domain
sed -i -e "s@<domain>@${FQDN}@g" /etc/nginx/conf.d/pterodactyl.conf
# replace all <php_socket> places with correct socket "path"
sed -i -e "s@<php_socket>@${PHP_SOCKET}@g" /etc/nginx/conf.d/pterodactyl.conf
else
# remove default config
rm -rf /etc/nginx/sites-enabled/default
# download new config
curl -o /etc/nginx/sites-available/pterodactyl.conf $CONFIGS_URL/$DL_FILE
# replace all <domain> places with the correct domain
sed -i -e "s@<domain>@${FQDN}@g" /etc/nginx/sites-available/pterodactyl.conf
# replace all <php_socket> places with correct socket "path"
sed -i -e "s@<php_socket>@${PHP_SOCKET}@g" /etc/nginx/sites-available/pterodactyl.conf
# enable pterodactyl
ln -s /etc/nginx/sites-available/pterodactyl.conf /etc/nginx/sites-enabled/pterodactyl.conf
fi
# restart nginx
systemctl restart nginx
echo "* nginx configured!"
}
function configure_apache {
echo "soon .."
}
###########
## OTHER ##
###########
function install_daemon {
echo "* It is recommended to have the panel and daemon on two separate nodes."
echo -n "* Would you like to also install the Pterodactyl daemon on this machine? (y/N): "
read -r INSTALL_DAEMON
if [[ "$INSTALL_DAEMON" =~ [Yy] ]]; then
bash <(curl -s https://raw.githubusercontent.com/vilhelmprytz/pterodactyl-installer/master/install-daemon.sh)
fi
}
####################
## MAIN FUNCTIONS ##
####################
function perform_install {
echo "* Starting installation.. this might take a while!"
[ "$CONFIGURE_UFW" == true ] && firewall_ufw
# do different things depending on OS
if [ "$OS" == "ubuntu" ]; then
ubuntu_universedep
apt_update
# different dependencies depending on if it's 18 or 16
if [ "$OS_VER_MAJOR" == "18" ]; then
ubuntu18_dep
elif [ "$OS_VER_MAJOR" == "16" ]; then
ubuntu16_dep
else
print_error "Unsupported version of Ubuntu."
exit 1
fi
install_composer
ptdl_dl
create_database
configure
insert_cronjob
install_pteroq
if [ "$OS_VER_MAJOR" == "18" ]; then
if [ "$CONFIGURE_LETSENCRYPT" == true ]; then
debian_based_letsencrypt
fi
fi
elif [ "$OS" == "zorin" ]; then
ubuntu_universedep
apt_update
if [ "$OS_VER_MAJOR" == "15" ]; then
ubuntu18_dep
else
print_error "Unsupported version of Zorin."
exit 1
fi
install_composer
ptdl_dl
create_database
configure
insert_cronjob
install_pteroq
elif [ "$OS" == "debian" ]; then
apt_update
if [ "$OS_VER_MAJOR" == "8" ] || [ "$OS_VER_MAJOR" == "9" ]; then
debian_jessie_dep
elif [ "$OS_VER_MAJOR" == "10" ]; then
debian_dep
fi
install_composer
ptdl_dl
create_database
configure
insert_cronjob
install_pteroq
if [ "$OS_VER_MAJOR" == "9" ] || [ "$OS_VER_MAJOR" == "10" ]; then
if [ "$CONFIGURE_LETSENCRYPT" == true ]; then
debian_based_letsencrypt
fi
fi
elif [ "$OS" == "centos" ]; then
if [ "$OS_VER_MAJOR" == "7" ]; then
centos7_dep
elif [ "$OS_VER_MAJOR" == "8" ]; then
centos8_dep
fi
centos_php
install_composer
ptdl_dl
create_database
configure
insert_cronjob
install_pteroq
else
# exit
print_error "OS not supported."
exit 1
fi
# perform webserver configuration
if [ "$WEBSERVER" == "nginx" ]; then
configure_nginx
elif [ "$WEBSERVER" == "apache" ]; then
configure_apache
else
print_error "Invalid webserver."
exit 1
fi
}
function ask_letsencrypt {
if [ "$CONFIGURE_UFW" == false ]; then
echo -e "* ${COLOR_RED}Note${COLOR_NC}: Let's Encrypt requires port 80/443 to be opened! You have opted out of the automatic UFW configuration; use this at your own risk (if port 80/443 is closed, the script will fail)!"
fi
echo -e -n "* Do you want to automatically configure HTTPS using Let's Encrypt? (y/N): "
read -r CONFIRM_SSL
if [[ "$CONFIRM_SSL" =~ [Yy] ]]; then
CONFIGURE_LETSENCRYPT=true
ASSUME_SSL=true
fi
}
function main {
# check if we can detect an already existing installation
if [ -d "/var/www/pterodactyl" ]; then
print_warning "The script has detected that you already have Pterodactyl panel on your system! You cannot run the script multiple times, it will fail!"
echo -e -n "* Are you sure you want to proceed? (y/N): "
read -r CONFIRM_PROCEED
if [[ ! "$CONFIRM_PROCEED" =~ [Yy] ]]; then
print_error "Installation aborted!"
exit 1
fi
fi
# detect distro
detect_distro
print_brake 70
echo "* Pterodactyl panel installation script"
echo "*"
echo "* Copyright (C) 2018 - 2020, Vilhelm Prytz, <[email protected]>, et al."
echo "* https://github.com/VilhelmPrytz/pterodactyl-installer"
echo "*"
echo "* This script is not associated with the official Pterodactyl Project."
echo "*"
echo "* Running $OS version $OS_VER."
print_brake 70
# checks if the system is compatible with this installation script
check_os_comp
while [ "$WEBSERVER_INPUT" != "1" ]; do
echo "* [1] - nginx"
echo -e "\e[9m* [2] - apache\e[0m - \e[1mApache not supported yet\e[0m"
echo ""
echo -n "* Select webserver to install pterodactyl panel with: "
read -r WEBSERVER_INPUT
if [ "$WEBSERVER_INPUT" == "1" ]; then
WEBSERVER="nginx"
else
# exit
print_error "Invalid webserver."
fi
done
# set database credentials
print_brake 72
echo "* Database configuration."
echo ""
echo "* This will be the credentials used for commuication between the MySQL"
echo "* database and the panel. You do not need to create the database"
echo "* before running this script, the script will do that for you."
echo ""
echo -n "* Database name (panel): "
read -r MYSQL_DB_INPUT
[ -z "$MYSQL_DB_INPUT" ] && MYSQL_DB="panel" || MYSQL_DB=$MYSQL_DB_INPUT
echo -n "* Username (pterodactyl): "
read -r MYSQL_USER_INPUT
[ -z "$MYSQL_USER_INPUT" ] && MYSQL_USER="pterodactyl" || MYSQL_USER=$MYSQL_USER_INPUT
# MySQL password input
while [ -z "$MYSQL_PASSWORD" ]; do
echo -n "* Password (use something strong): "
# modified from https://stackoverflow.com/a/22940001
while IFS= read -r -s -n1 char; do
[[ -z $char ]] && { printf '\n'; break; } # ENTER pressed; output \n and break.
if [[ $char == $'\x7f' ]]; then # backspace was pressed
# Only if variable is not empty
if [ -n "$MYSQL_PASSWORD" ]; then
# Remove last char from output variable.
[[ -n $MYSQL_PASSWORD ]] && MYSQL_PASSWORD=${MYSQL_PASSWORD%?}
# Erase '*' to the left.
printf '\b \b'
fi
else
# Add typed char to output variable.
MYSQL_PASSWORD+=$char
# Print '*' in its stead.
printf '*'
fi
done
[ -z "$MYSQL_PASSWORD" ] && print_error "MySQL password cannot be empty"
done
print_brake 72
# set FQDN
while [ -z "$FQDN" ]; do
echo -n "* Set the FQDN of this panel (panel.example.com): "
read -r FQDN
[ -z "$FQDN" ] && print_error "FQDN cannot be empty"
done
# UFW is available for Ubuntu/Debian
# Let's Encrypt, in this setup, is only available on Ubuntu/Debian
if [ "$OS" == "debian" ] || [ "$OS" == "ubuntu" ] || [ "$OS" == "zorin" ]; then
echo -e -n "* Do you want to automatically configure UFW (firewall)? (y/N): "
read -r CONFIRM_UFW
if [[ "$CONFIRM_UFW" =~ [Yy] ]]; then
CONFIGURE_UFW=true
fi
# Available for Debian 9/10
if [ "$OS" == "debian" ]; then
if [ "$OS_VER_MAJOR" == "9" ] || [ "$OS_VER_MAJOR" == "10" ]; then
ask_letsencrypt
fi
fi
# Available for Ubuntu 18
if [ "$OS" == "ubuntu" ] && [ "$OS_VER_MAJOR" == "18" ]; then
ask_letsencrypt
fi
fi
# If it's already true, this should be a no-brainer
if [ "$CONFIGURE_LETSENCRYPT" == false ]; then
echo "* Let's Encrypt is not going to be automatically configured by this script (either unsupported yet or user opted out)."
echo "* You can 'assume' Let's Encrypt, which means the script will download a nginx configuration that is configured to use a Let's Encrypt certificate but the script won't obtain the certificate for you."
echo "* If you assume SSL and do not obtain the certificate, your installation will not work."
echo -n "* Assume SSL or not? (y/N): "
read -r ASSUME_SSL_INPUT
if [[ "$ASSUME_SSL_INPUT" =~ [Yy] ]]; then
ASSUME_SSL=true
fi
fi
# summary
summary
# confirm installation
echo -e -n "\n* Initial configuration completed. Continue with installation? (y/N): "
read -r CONFIRM
if [[ "$CONFIRM" =~ [Yy] ]]; then
perform_install
else
# run welcome script again
print_error "Installation aborted."
exit 1
fi
}
function summary {
print_brake 62
echo "* Pterodactyl panel $PTERODACTYL_VERSION with $WEBSERVER webserver on $OS"
echo "* Database name: $MYSQL_DB"
echo "* Database user: $MYSQL_USER"
echo "* Database password: (censored)"
echo "* Hostname/FQDN: $FQDN"
echo "* Configure UFW? $CONFIGURE_UFW"
echo "* Configure Let's Encrypt? $CONFIGURE_LETSENCRYPT"
echo "* Assume SSL? $ASSUME_SSL"
print_brake 62
}
function goodbye {
print_brake 62
echo "* Pterodactyl Panel successfully installed @ $FQDN"
echo "* "
echo "* Installation is using $WEBSERVER on $OS"
echo "* Thank you for using this script."
echo -e "* ${COLOR_RED}Note${COLOR_NC}: If you haven't configured the firewall: 80/443 (HTTP/HTTPS) is required to be open!"
print_brake 62
install_daemon
}
# run script
main
goodbye