forked from pterodactyl-installer/pterodactyl-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-wings.sh
executable file
·742 lines (610 loc) · 22.1 KB
/
install-wings.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
#!/bin/bash
set -e
#############################################################################
# #
# Project 'pterodactyl-installer' for wings #
# #
# Copyright (C) 2018 - 2021, Vilhelm Prytz, <vilhelm@prytznet.se> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <https://www.gnu.org/licenses/>. #
# #
# 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 #
# #
#############################################################################
# versioning
GITHUB_SOURCE="master"
SCRIPT_RELEASE="canary"
#################################
######## General checks #########
#################################
# 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
if ! [ -x "$(command -v curl)" ]; then
echo "* curl is required in order for this script to work."
echo "* install using apt (Debian and derivatives) or yum/dnf (CentOS)"
exit 1
fi
#################################
########## Variables ############
#################################
# download URLs
WINGS_DL_BASE_URL="https://github.com/pterodactyl/wings/releases/latest/download/wings_linux_"
GITHUB_BASE_URL="https://raw.githubusercontent.com/vilhelmprytz/pterodactyl-installer/$GITHUB_SOURCE"
COLOR_RED='\033[0;31m'
COLOR_NC='\033[0m'
INSTALL_MARIADB=false
# firewall
CONFIGURE_FIREWALL=false
CONFIGURE_UFW=false
CONFIGURE_FIREWALL_CMD=false
# SSL (Let's Encrypt)
CONFIGURE_LETSENCRYPT=false
FQDN=""
EMAIL=""
# Database host
CONFIGURE_DBHOST=false
MYSQL_DBHOST_USER="pterodactyluser"
MYSQL_DBHOST_PASSWORD="password"
# regex for email input
regex="^(([A-Za-z0-9]+((\.|\-|\_|\+)?[A-Za-z0-9]?)*[A-Za-z0-9]+)|[A-Za-z0-9]+)@(([A-Za-z0-9]+)+((\.|\-|\_)?([A-Za-z0-9]+)+)*)+\.([A-Za-z]{2,})+$"
#################################
####### Version checking ########
#################################
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.."
WINGS_VERSION="$(get_latest_release "pterodactyl/wings")"
####### Other library functions ########
valid_email() {
[[ $1 =~ ${regex} ]]
}
password_input() {
local __resultvar=$1
local result=''
local default="$4"
while [ -z "$result" ]; do
echo -n "* ${2}"
# 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 "$result" ]; then
# Remove last char from output variable.
[[ -n $result ]] && result=${result%?}
# Erase '*' to the left.
printf '\b \b'
fi
else
# Add typed char to output variable.
result+=$char
# Print '*' in its stead.
printf '*'
fi
done
[ -z "$result" ] && [ -n "$default" ] && result="$default"
[ -z "$result" ] && print_error "${3}"
done
eval "$__resultvar="'$result'""
}
#################################
####### Visual functions ########
#################################
print_error() {
echo ""
echo -e "* ${COLOR_RED}ERROR${COLOR_NC}: $1"
echo ""
}
print_warning() {
COLOR_YELLOW='\033[1;33m'
COLOR_NC='\033[0m'
echo ""
echo -e "* ${COLOR_YELLOW}WARNING${COLOR_NC}: $1"
echo ""
}
print_brake() {
for ((n = 0; n < $1; n++)); do
echo -n "#"
done
echo ""
}
hyperlink() {
echo -e "\e]8;;${1}\a${1}\e]8;;\a"
}
#################################
####### OS check funtions #######
#################################
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)
}
check_os_comp() {
SUPPORTED=false
MACHINE_TYPE=$(uname -m)
case "$MACHINE_TYPE" in
x86_64)
ARCH=amd64
;;
arm64) ;&
# fallthrough
aarch64)
print_warning "Detected architecture arm64"
print_warning "You will need to use Docker images made specifically for arm64"
echo -e -n "* Are you sure you want to proceed? (y/N):"
read -r choice
if [[ ! "$choice" =~ [Yy] ]]; then
print_error "Installation aborted!"
exit 1
fi
ARCH=arm64
;;
*)
print_error "Only x86_64 and arm64 are supported for Wings"
exit 1
;;
esac
case "$OS" in
ubuntu)
[ "$OS_VER_MAJOR" == "18" ] && SUPPORTED=true
[ "$OS_VER_MAJOR" == "20" ] && SUPPORTED=true
;;
debian)
[ "$OS_VER_MAJOR" == "9" ] && SUPPORTED=true
[ "$OS_VER_MAJOR" == "10" ] && SUPPORTED=true
[ "$OS_VER_MAJOR" == "11" ] && SUPPORTED=true
;;
centos)
[ "$OS_VER_MAJOR" == "7" ] && SUPPORTED=true
[ "$OS_VER_MAJOR" == "8" ] && SUPPORTED=true
;;
*)
SUPPORTED=false
;;
esac
# 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
# check virtualization
echo -e "* Installing virt-what..."
if [ "$OS" == "debian" ] || [ "$OS" == "ubuntu" ]; then
# silence dpkg output
export DEBIAN_FRONTEND=noninteractive
# install virt-what
apt-get -y update -qq
apt-get install -y virt-what -qq
# unsilence
unset DEBIAN_FRONTEND
elif [ "$OS" == "centos" ]; then
if [ "$OS_VER_MAJOR" == "7" ]; then
yum -q -y update
# install virt-what
yum -q -y install virt-what
elif [ "$OS_VER_MAJOR" == "8" ]; then
dnf -y -q update
# install virt-what
dnf install -y -q virt-what
fi
else
print_error "Invalid OS."
exit 1
fi
virt_serv=$(virt-what)
case "$virt_serv" in
*openvz* | *lxc*)
print_warning "Unsupported type of virtualization detected. Please consult with your hosting provider whether your server can run Docker or not. Proceed at your own risk."
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
;;
*)
[ "$virt_serv" != "" ] && print_warning "Virtualization: $virt_serv detected."
;;
esac
if uname -r | grep -q "xxxx"; then
print_error "Unsupported kernel detected."
exit 1
fi
}
############################
## INSTALLATION FUNCTIONS ##
############################
apt_update() {
apt update -q -y && apt upgrade -y
}
yum_update() {
yum -y update
}
dnf_update() {
dnf -y upgrade
}
enable_docker() {
systemctl start docker
systemctl enable docker
}
install_docker() {
echo "* Installing docker .."
if [ "$OS" == "debian" ] || [ "$OS" == "ubuntu" ]; then
# Install dependencies
apt-get -y install \
apt-transport-https \
ca-certificates \
gnupg2 \
software-properties-common
# Add docker gpg key
curl -fsSL https://download.docker.com/linux/"$OS"/gpg | apt-key add -
# Show fingerprint to user
apt-key fingerprint 0EBFCD88
# Add docker repo
add-apt-repository \
"deb [arch=$ARCH] https://download.docker.com/linux/$OS \
$(lsb_release -cs) \
stable"
# Install docker
apt_update
apt-get -y install docker-ce docker-ce-cli containerd.io
# Make sure docker is enabled
enable_docker
elif [ "$OS" == "centos" ]; then
if [ "$OS_VER_MAJOR" == "7" ]; then
# Install dependencies for Docker
yum install -y yum-utils device-mapper-persistent-data lvm2
# Add repo to yum
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
# Install Docker
yum install -y docker-ce docker-ce-cli containerd.io
elif [ "$OS_VER_MAJOR" == "8" ]; then
# Install dependencies for Docker
dnf install -y dnf-utils device-mapper-persistent-data lvm2
# Add repo to dnf
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
# Install Docker
dnf install -y docker-ce docker-ce-cli containerd.io --nobest
fi
enable_docker
fi
echo "* Docker has now been installed."
}
ptdl_dl() {
echo "* Installing Pterodactyl Wings .. "
mkdir -p /etc/pterodactyl
curl -L -o /usr/local/bin/wings "$WINGS_DL_BASE_URL$ARCH"
chmod u+x /usr/local/bin/wings
echo "* Done."
}
systemd_file() {
echo "* Installing systemd service.."
curl -o /etc/systemd/system/wings.service $GITHUB_BASE_URL/configs/wings.service
systemctl daemon-reload
systemctl enable wings
echo "* Installed systemd service!"
}
install_mariadb() {
MARIADB_URL="https://downloads.mariadb.com/MariaDB/mariadb_repo_setup"
case "$OS" in
debian)
if [ "$ARCH" == "aarch64" ]; then
print_warning "MariaDB doesn't support Debian on arm64"
return
fi
[ "$OS_VER_MAJOR" == "9" ] && curl -sS $MARIADB_URL | sudo bash
apt install -y mariadb-server
;;
ubuntu)
[ "$OS_VER_MAJOR" == "18" ] && curl -sS $MARIADB_URL | sudo bash
apt install -y mariadb-server
;;
centos)
[ "$OS_VER_MAJOR" == "7" ] && curl -sS $MARIADB_URL | bash
[ "$OS_VER_MAJOR" == "7" ] && yum -y install mariadb-server
[ "$OS_VER_MAJOR" == "8" ] && dnf install -y mariadb mariadb-server
;;
esac
systemctl enable mariadb
systemctl start mariadb
}
ask_database_user() {
echo -n "* Do you want to automatically configure a user for database hosts? (y/N): "
read -r CONFIRM_DBHOST
if [[ "$CONFIRM_DBHOST" =~ [Yy] ]]; then
CONFIGURE_DBHOST=true
fi
}
configure_mysql() {
echo "* Performing MySQL queries.."
echo "* Creating MySQL user..."
mysql -u root -e "CREATE USER '${MYSQL_DBHOST_USER}'@'127.0.0.1' IDENTIFIED BY '${MYSQL_DBHOST_PASSWORD}';"
echo "* Granting privileges.."
mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO '${MYSQL_DBHOST_USER}'@'127.0.0.1' WITH GRANT OPTION;"
echo "* Flushing privileges.."
mysql -u root -e "FLUSH PRIVILEGES;"
echo "* Changing MySQL bind address.."
case "$OS" in
debian | ubuntu)
sed -ne 's/^bind-address = 127.0.0.1$/bind-address=0.0.0.0/' /etc/mysql/mariadb.conf.d/50-server.cnf
;;
centos)
sed -ne 's/^#bind-address=0.0.0.0$/bind-address=0.0.0.0/' /etc/my.cnf.d/mariadb-server.cnf
;;
esac
echo "* MySQL configured!"
}
#################################
##### OS SPECIFIC FUNCTIONS #####
#################################
ask_letsencrypt() {
if [ "$CONFIGURE_UFW" == false ] && [ "$CONFIGURE_FIREWALL_CMD" == false ]; then
print_warning "Let's Encrypt requires port 80/443 to be opened! You have opted out of the automatic firewall configuration; use this at your own risk (if port 80/443 is closed, the script will fail)!"
fi
print_warning "You cannot use Let's Encrypt with your hostname as an IP address! It must be a FQDN (e.g. node.example.org)."
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
fi
}
firewall_ufw() {
apt install ufw -y
echo -e "\n* Enabling Uncomplicated Firewall (UFW)"
echo "* Opening port 22 (SSH), 8080 (Daemon Port), 2022 (Daemon SFTP Port)"
# pointing to /dev/null silences the command output
ufw allow ssh >/dev/null
ufw allow 8080 >/dev/null
ufw allow 2022 >/dev/null
[ "$CONFIGURE_LETSENCRYPT" == true ] && ufw allow http >/dev/null
[ "$CONFIGURE_LETSENCRYPT" == true ] && ufw allow https >/dev/null
ufw --force enable
ufw --force reload
ufw status numbered | sed '/v6/d'
}
firewall_firewalld() {
echo -e "\n* Enabling firewall_cmd (firewalld)"
echo "* Opening port 22 (SSH), 8080 (Daemon Port), 2022 (Daemon SFTP Port)"
# Install
[ "$OS_VER_MAJOR" == "7" ] && yum -y -q install firewalld >/dev/null
[ "$OS_VER_MAJOR" == "8" ] && dnf -y -q install firewalld >/dev/null
# Enable
systemctl --now enable firewalld >/dev/null # Enable and start
# Configure
firewall-cmd --add-service=ssh --permanent -q # Port 22
firewall-cmd --add-port 8080/tcp --permanent -q # Port 8080
firewall-cmd --add-port 2022/tcp --permanent -q # Port 2022
[ "$CONFIGURE_LETSENCRYPT" == true ] && firewall-cmd --add-service=http --permanent -q # Port 80
[ "$CONFIGURE_LETSENCRYPT" == true ] && firewall-cmd --add-service=https --permanent -q # Port 443
firewall-cmd --permanent --zone=trusted --change-interface=pterodactyl0 -q
firewall-cmd --zone=trusted --add-masquerade --permanent
firewall-cmd --reload -q # Enable firewall
echo "* Firewall-cmd installed"
print_brake 70
}
letsencrypt() {
FAILED=false
# Install certbot
case "$OS" in
debian | ubuntu)
apt-get -y install certbot python3-certbot-nginx
;;
centos)
[ "$OS_VER_MAJOR" == "7" ] && yum -y -q install epel-release
[ "$OS_VER_MAJOR" == "7" ] && yum -y -q install certbot python-certbot-nginx
[ "$OS_VER_MAJOR" == "8" ] && dnf -y -q install epel-release
[ "$OS_VER_MAJOR" == "8" ] && dnf -y -q install certbot python3-certbot-nginx
;;
esac
# If user has nginx
systemctl stop nginx || true
# Obtain certificate
certbot certonly --no-eff-email --email "$EMAIL" --standalone -d "$FQDN" || FAILED=true
systemctl start nginx || true
# Check if it succeded
if [ ! -d "/etc/letsencrypt/live/$FQDN/" ] || [ "$FAILED" == true ]; then
print_warning "The process of obtaining a Let's Encrypt certificate failed!"
fi
}
####################
## MAIN FUNCTIONS ##
####################
perform_install() {
echo "* Installing pterodactyl wings.."
[ "$OS" == "ubuntu" ] || [ "$OS" == "debian" ] && apt_update
[ "$OS" == "centos" ] && [ "$OS_VER_MAJOR" == "7" ] && yum_update
[ "$OS" == "centos" ] && [ "$OS_VER_MAJOR" == "8" ] && dnf_update
[ "$CONFIGURE_UFW" == true ] && firewall_ufw
[ "$CONFIGURE_FIREWALL_CMD" == true ] && firewall_firewalld
install_docker
ptdl_dl
systemd_file
[ "$INSTALL_MARIADB" == true ] && install_mariadb
[ "$CONFIGURE_DBHOST" == true ] && configure_mysql
[ "$CONFIGURE_LETSENCRYPT" == true ] && letsencrypt
# return true if script has made it this far
return 0
}
main() {
# check if we can detect an already existing installation
if [ -d "/etc/pterodactyl" ]; then
print_warning "The script has detected that you already have Pterodactyl wings 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 Wings installation script @ $SCRIPT_RELEASE"
echo "*"
echo "* Copyright (C) 2018 - 2021, Vilhelm Prytz, <vilhelm@prytznet.se>"
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."
echo "* Latest pterodactyl/wings is $WINGS_VERSION"
print_brake 70
# checks if the system is compatible with this installation script
check_os_comp
echo "* "
echo "* The installer will install Docker, required dependencies for Wings"
echo "* as well as Wings itself. But it's still required to create the node"
echo "* on the panel and then place the configuration file on the node manually after"
echo "* the installation has finished. Read more about this process on the"
echo "* official documentation: $(hyperlink 'https://pterodactyl.io/wings/1.0/installing.html#configure')"
echo "* "
echo -e "* ${COLOR_RED}Note${COLOR_NC}: this script will not start Wings automatically (will install systemd service, not start it)."
echo -e "* ${COLOR_RED}Note${COLOR_NC}: this script will not enable swap (for docker)."
print_brake 42
ask_database_user
if [ "$CONFIGURE_DBHOST" == true ]; then
type mysql >/dev/null 2>&1 && HAS_MYSQL=true || HAS_MYSQL=false
if [ "$HAS_MYSQL" == false ]; then
INSTALL_MARIADB=true
fi
echo -n "* Database host username (pterodactyluser): "
read -r MYSQL_DBHOST_USER_INPUT
[ -z "$MYSQL_DBHOST_USER_INPUT" ] || MYSQL_DBHOST_USER=$MYSQL_DBHOST_USER_INPUT
password_input MYSQL_DBHOST_PASSWORD "Database host password: " "Password cannot be empty"
fi
# UFW is available for Ubuntu/Debian
if [ "$OS" == "debian" ] || [ "$OS" == "ubuntu" ]; 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
CONFIGURE_FIREWALL=true
fi
fi
# Firewall-cmd is available for CentOS
if [ "$OS" == "centos" ]; then
echo -e -n "* Do you want to automatically configure firewall-cmd (firewall)? (y/N): "
read -r CONFIRM_FIREWALL_CMD
if [[ "$CONFIRM_FIREWALL_CMD" =~ [Yy] ]]; then
CONFIGURE_FIREWALL_CMD=true
CONFIGURE_FIREWALL=true
fi
fi
ask_letsencrypt
if [ "$CONFIGURE_LETSENCRYPT" == true ]; then
while [ -z "$FQDN" ]; do
echo -n "* Set the FQDN to use for Let's Encrypt (node.example.com): "
read -r FQDN
ASK=false
[ -z "$FQDN" ] && print_error "FQDN cannot be empty" # check if FQDN is empty
bash <(curl -s $GITHUB_BASE_URL/lib/verify-fqdn.sh) "$FQDN" "$OS" || ASK=true # check if FQDN is valid
[ -d "/etc/letsencrypt/live/$FQDN/" ] && print_error "A certificate with this FQDN already exists!" && ASK=true # check if cert exists
[ "$ASK" == true ] && FQDN=""
[ "$ASK" == true ] && echo -e -n "* Do you still want to automatically configure HTTPS using Let's Encrypt? (y/N): "
[ "$ASK" == true ] && read -r CONFIRM_SSL
if [[ ! "$CONFIRM_SSL" =~ [Yy] ]] && [ "$ASK" == true ]; then
CONFIGURE_LETSENCRYPT=false
FQDN="none"
fi
done
fi
if [ "$CONFIGURE_LETSENCRYPT" == true ]; then
# set EMAIL
while ! valid_email "$EMAIL"; do
echo -n "* Enter email address for Let's Encrypt: "
read -r EMAIL
valid_email "$EMAIL" || print_error "Email cannot be empty or invalid"
done
fi
echo -n "* Proceed with installation? (y/N): "
read -r CONFIRM
[[ "$CONFIRM" =~ [Yy] ]] && perform_install && return
print_error "Installation aborted"
exit 0
}
function goodbye {
echo ""
print_brake 70
echo "* Wings installation completed"
echo "*"
echo "* To continue, you need to configure Wings to run with your panel"
echo "* Please refer to the official guide, $(hyperlink 'https://pterodactyl.io/wings/1.0/installing.html#configure')"
echo "* "
echo "* You can either copy the configuration file from the panel manually to /etc/pterodactyl/config.yml"
echo "* or, you can use the \"auto deploy\" button from the panel and simply paste the command in this terminal"
echo "* "
echo "* You can then start Wings manually to verify that it's working"
echo "*"
echo "* sudo wings"
echo "*"
echo "* Once you have verified that it is working, use CTRL+C and then start Wings as a service (runs in the background)"
echo "*"
echo "* systemctl start wings"
echo "*"
echo -e "* ${COLOR_RED}Note${COLOR_NC}: It is recommended to enable swap (for Docker, read more about it in official documentation)."
[ "$CONFIGURE_FIREWALL" == false ] && echo -e "* ${COLOR_RED}Note${COLOR_NC}: If you haven't configured your firewall, ports 8080 and 2022 needs to be open."
print_brake 70
echo ""
}
# run script
main
goodbye