-
Notifications
You must be signed in to change notification settings - Fork 0
/
installer.sh
192 lines (187 loc) · 7.55 KB
/
installer.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
set -e
clear
echo "====================="
echo "Qwaekactyl Installer"
echo "====================="
echo "Note that this install"
echo "Is just for ubuntu/debain"
echo ========================================
install_options(){
echo "Please select your installation option:"
echo "[1] Full Fresh Qwaekactyl Install (Dependercies, Files, Configuration)"
echo "[2] Install the Dependercies."
echo "[3] Install the Files."
echo "[4] Configure Settings."
echo "[5] Create and configure a reverse proxy."
echo "========================================"
read choice
case $choice in
1 ) installoption=1
dependercy_install
file_install
settings_configuration
reverseproxy_configuration
;;
2 ) installoption=2
dependercy_install
;;
3 ) installoption=3
file_install
;;
4 ) installoption=4
settings_configuration
;;
5 ) installoption=5
reverseproxy_configuration
;;
6 ) installoption=6
update_check
;;
* ) output "You did not enter a valid selection."
install_options
esac
}
dependercy_install() {
echo "======================================================"
echo "Starting Dependercy install."
echo "======================================================"
sudo apt update
sudo apt upgrade
sudo apt-get install nodejs
sudo apt install npm
sudo apt-get install git
echo "======================================================"
echo "Dependency Install Completed!"
echo "======================================================"
}
file_install() {
echo "======================================================"
echo "Starting File download."
echo "======================================================"
cd /var/www/
sudo git clone https://github.com/Qwaekactyl/Qwaekactyl/
cd Qwaekactyl
sudo npm install
sudo npm install forever -g
echo "======================================================"
echo "Qwaekactyl File Download Completed!"
echo "======================================================"
}
settings_configuration() {
echo "======================================================"
echo "Starting Settings Configuration."
echo "Read the Docs for more information about the settings."
echo "soon"
echo "======================================================"
cd /var/www/Qwaekactyl/
file=settings.json
echo "What is the web port? [80] (This is the port Qwaekactyl will run on)"
read WEBPORT
echo "What is the web secret? (This will be used for logins)"
read WEB_SECRET
echo "What is the pterodactyl domain? [panel.yourdomain.com]"
read PTERODACTYL_DOMAIN
echo "What is the pterodactyl key?"
read PTERODACTYL_KEY
echo "What is the Discord Oauth2 ID?"
read DOAUTH_ID
echo "What is the Discord Oauth2 Secret?"
read DOAUTH_SECRET
echo "What is the Discord Oauth2 Link?"
read DOAUTH_LINK
echo "What is the Callback path? [callback]"
read DOAUTH_CALLBACKPATH
echo "Prompt [TRUE/FALSE] (When set to true users wont have to relogin after a session)"
read DOAUTH_PROMPT
sed -i -e 's/"port":.*/"port": '$WEBPORT',/' -e 's/"secret":.*/"secret": "'$WEB_SECRET'"/' -e 's/"domain":.*/"domain": "'$PTERODACTYL_DOMAIN'",/' -e 's/"key":.*/"key": "'$PTERODACTYL_KEY'"/' -e 's/"id":.*/"id": "'$DOAUTH_ID'",/' -e 's/"link":.*/"link": "'$DOAUTH_LINK'",/' -e 's/"path":.*/"path": "'$DOAUTH_CALLBACKPATH'",/' -e 's/"prompt":.*/"prompt": '$DOAUTH_PROMPT'/' -e '0,/"secret":.*/! {0,/"secret":.*/ s/"secret":.*/"secret": "'$DOAUTH_SECRET'",/}' $file
echo "-------------------------------------------------------"
echo "Main Configuration Settings Completed!"
echo "Some Configuration need to setup manually"
}
reverseproxy_configuration() {
echo "-------------------------------------------------------"
echo "Starting Reverse Proxy Configuration."
echo "Read the Docs for more infomration about the Configuration."
echo "https://josh0086.gitbook.io/dashactyl/"
echo "-------------------------------------------------------"
echo "Select your webserver [NGINX]"
read WEBSERVER
echo "Protocol Type [HTTP]"
read PROTOCOL
if [ $PROTOCOL != "HTTP" ]; then
echo "------------------------------------------------------"
echo "HTTP is currently only supported on the install script."
echo "------------------------------------------------------"
return
fi
if [ $WEBSERVER != "NGINX" ]; then
echo "------------------------------------------------------"
echo "Aborted, only Nginx is currently supported for the reverse proxy."
echo "------------------------------------------------------"
return
fi
echo "What is your domain? [example.com]"
read DOMAIN
apt install nginx
sudo wget -O /etc/nginx/conf.d/Qwaekactyl.conf https://raw.githubusercontent.com/Qwaekactyl/Qwaekactyl-installer/main/NginxHTTPReverseProxy.conf
sudo apt-get install jq
port=$(jq -r '.["website"]["port"]' /var/www/Qwaekactyl/settings.json)
sed -i 's/PORT/'$port'/g' /etc/nginx/conf.d/Qwaekactyl.conf
sed -i 's/DOMAIN/'$DOMAIN'/g' /etc/nginx/conf.Qwaekactyl.conf
sudo nginx -t
sudo nginx -s reload
systemctl restart nginx
echo "-------------------------------------------------------"
echo "Reverse Proxy Install and configuration completed."
echo "-------------------------------------------------------"
echo "Here is the config status:"
sudo nginx -t
echo "-------------------------------------------------------"
echo "Note: if it does not say OK in the line, an error has occurred and you should try again or get help in the Qwaekactyl Discord Server."
echo "-------------------------------------------------------"
if [ $WEBSERVER = "APACHE" ]; then
echo "Apache isn't currently supported with the install script."
echo "------------------------------------------------------"
return
fi
}
update_check() {
latest=$(wget https://raw.githubusercontent.com/Qwaekactyl/Qwaekactyl-installer/main/version.json -q -O -)
#latest='"version": "0.1.2-themes6",'
version=$(grep -Po '"version":.*?[^\\]",' /var/www/Qwaekactyl/settings.json)
if [ "$latest" = "$version" ]; then
echo "======================================================"
echo "You're running the latest version of Qwaekactyl."
echo "======================================================"
else
echo "======================================================"
echo "You're running an outdated version of Qwaekactyl."
echo "======================================================"
echo "Would you like to update to the latest version? [Y/N]"
echo "Bu updating your files will be backed up in /var/www/Qwaekactyl-backup/"
read UPDATE_OPTION
echo "-------------------------------------------------------"
if [ "$UPDATE_OPTION" = "Y" ]; then
var=`date +"%FORMAT_STRING"`
now=`date +"%m_%d_%Y"`
now=`date +"%Y-%m-%d"`
if [[ ! -e /var/www/Qwaekactyl-backup/ ]]; then
mkdir /var/www/Qwaekactyl-backup/
finish_update
elif [[ ! -d $dir ]]; then
finish_update
fi
else
echo "Update Aborted"
echo "Restart the script if this was a mistake."
echo "-------------------------------------------------------"
fi
fi
}
finish_update() {
tar -czvf "${now}.tar.gz" /var/www/Qwaekactyl/
mv "${now}.tar.gz" /var/www/Qwaekactyl-backup
rm -R /var/www/Qwaekactyl/
file_install
}
install_options