-
-
Notifications
You must be signed in to change notification settings - Fork 88
/
weby
275 lines (238 loc) · 10.3 KB
/
weby
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
#!/bin/bash
# Webinoly Installation Script.
# Check OS support
distr=`echo $(lsb_release -i | cut -d':' -f 2)`
osver=`echo $(lsb_release -c | cut -d':' -f 2)`
# Check for custom version
if [[ $2 == "-ver="* ]]; then
ver=$(echo "$2" | cut -d'=' -f 2 -s)
# Skip stadistics counters for dev and testing (custom version stats).
if [[ $(echo $ver | rev | cut -c-1) == "*" || $ver == "alpha" ]]; then
ver=${ver//'*'}
statskip="true"
fi
fi
# Supported: 22.04 Jammy and 24.04 Noble
if [[ $distr != "Ubuntu" ]] || ! [[ $osver =~ ^(focal|jammy|noble)$ ]]; then
echo "$(tput setaf 1)"
echo "[ERROR] This OS is not supported by Webinoly and could not work properly. $(tput dim)(${distr} '${osver}')"
echo "$(tput sgr0)"
sudo rm weby
exit 1
# Block new installs for: 20.04 Focal (can be installed before 1.xx.0) (April 2025 EOL)
#elif [[ $osver == "focal" && $1 != "upd" && -n $ver && $(echo ${ver//'*'} | sed 's/\.//g') =~ ^[0-9]+$ && $(echo ${ver//'*'} | sed 's/\.//g') -ge 1170 ]]; then
# echo "$(tput setaf 1)"
# echo "[ERROR] Ubuntu 20.04 is not supported on this version of Webinoly!"
# echo "$(tput sgr0)"
# sudo rm weby
# exit 1
#elif [[ $osver == "focal" && $1 != "upd" && -n $ver && $(echo ${ver//'*'} | sed 's/\.//g') =~ ^[0-9]+$ && $(echo ${ver//'*'} | sed 's/\.//g') -lt 1170 ]]; then
# echo "$(tput setaf 1)"
# echo "[WARNING] You should consider a newer Ubuntu version! $(tput dim)(24.04 or 22.04 are recommended instead)"
# echo "$(tput sgr0)"
# 20.04 Focal just for updates, no new installations after 1.xx.0
#elif [[ $osver == "focal" && $1 != "upd" ]]; then
# echo "$(tput setaf 1)"
# echo "[ERROR] Ubuntu 20.04 is not supported for new installations! $(tput dim)(24.04 or 22.04 are recommended instead)"
# echo "$(tput sgr0)"
# sudo rm weby
# exit 1
# 24.04 Noble is supported only after 1.18.0
elif [[ $osver == "noble" && -n $ver && $(echo ${ver//'*'} | sed 's/\.//g') =~ ^[0-9]+$ && $(echo ${ver//'*'} | sed 's/\.//g') -lt 1180 ]]; then
#noble - 1.18.0
#jammy - 1.16.6
#focal - 1.12.0
#bionic - 1.4.2
echo "$(tput setaf 1)"
echo "[ERROR] Ubuntu 24.04 (Noble) is not supported by this version of Webinoly!"
echo "$(tput sgr0)"
sudo rm weby
exit 1
fi
# Check for sudo/root privileges
if [[ $(whoami) != "root" ]]; then
echo "$(tput setaf 1)Please run this script as root or using sudo.$(tput sgr0)"
sudo rm weby
exit 1
fi
# Prevent "compulsive" re-installation, force the use of the 'update' command.
if [[ -f /opt/webinoly/webinoly.conf && $1 != "upd" && $2 != "-ver=alpha" ]]; then
echo "$(tput setaf 2)Webinoly is already installed on your server!"
echo "$(tput setaf 6)To update use the proper command:$(tput dim) sudo webinoly -update $(tput sgr0)"
sudo rm weby
exit 0
elif [[ ! -f /opt/webinoly/webinoly.conf && $1 == "upd" ]]; then
echo "$(tput setaf 1)Webinoly cannot be updated because it's not installed or not found.$(tput sgr0)"
sudo rm weby
exit 0
fi
# Diplay menu to select type of server
if [[ $1 == "upd" ]]; then
setup=0
update="&update=true"
elif [[ $1 == "-clean" ]]; then
setup=0
elif [[ $1 == "-nginx" ]]; then
setup=1
elif [[ $1 == "-php" ]]; then
setup=2
elif [[ $1 == "-lemp" ]]; then
setup=3
elif [[ -z $1 ]]; then
setup=3
elif ! [[ $1 -ge 0 && $1 -le 3 && $1 =~ ^[0-9]+$ ]]; then
echo "$(tput setaf 6)"
echo " 1 - HTML Server"
echo " 2 - PHP Server"
echo " 3 - LEMP Server (Default)"
echo " 0 - Clean (Only app)"
echo ""
read -p "$(tput setaf 2)Select the desired option to configure your server: $(tput sgr0)" setup
echo ""
setup=${setup:-3}
[[ $setup -ge 0 && $setup -le 3 && $setup =~ ^[0-9]+$ ]] || setup=0
else
setup=$1
fi
# Download and install Webinoly
if [[ -n $ver ]]; then
# Be sure we have a valid server response for the requested version
code=$(wget --server-response --spider https://qrok.es/webinoly?version=$ver 2>&1 | awk '/^ HTTP/{print $2}')
code="${code##*$'\n'}" # Get the last code (redirections)
if [[ $code == 200 ]]; then
sudo wget --timeout=15 -t 1 -qrO $HOME/webinoly.tar https://qrok.es/webinoly?version=$ver
[[ $ver == "beta" ]] && echo "$(tput setaf 1)[WARNING] You are installing a BETA version of Webinoly and it's not recommended for production enviroments.$(tput sgr0)"
type="Custom"
else
echo "$(tput setaf 1)[ERROR] Version not found or not available! ($code) $(tput sgr0)"
sudo rm weby
exit 1
fi
else
sudo wget --timeout=15 -t 1 --referer="https://webinoly.com/?option=${setup}${update}" -qrO $HOME/webinoly.tar https://qrok.es/wytar
fi
if [[ ! -s $HOME/webinoly.tar ]]; then
echo "$(tput setaf 1)[ERROR] Downloading Webinoly failed!$(tput sgr0)"
sudo rm weby
exit 1
else
echo "$(tput dim)Downloading... Successful!"
echo "$(tput sgr0)"
fi
sudo mkdir -p /opt/webinoly
sudo tar -xf $HOME/webinoly.tar -C /opt/webinoly
sudo mkdir -p /opt/webinoly/templates/source
sudo find /opt/webinoly -type d -exec chmod 755 {} \;
sudo find /opt/webinoly -type f -exec chmod 644 {} \;
sudo chmod -f 744 /opt/webinoly/lib/ex-*
sudo chmod 755 /opt/webinoly/usr/*
sudo mv /opt/webinoly/usr/* /usr/bin/
source /opt/webinoly/lib/general
# Check for uninstalled Webinoly conf file
if [[ -f $HOME/.webinoly-conf-restore_dont-remove ]]; then
echo "${gre}Seems like Webinoly was installed previously, we will try to recover your old configuration!${end}"
sudo tar -Pxf $HOME/.webinoly-conf-restore_dont-remove -C /
sudo rm -rf $HOME/.webinoly-conf-restore_dont-remove
sudo webinoly -verify=critical
fi
# Check if new installation
if [[ -f /opt/webinoly/webinoly.conf ]]; then
oldapp=$(conf_read app-version)
oldver=$(conf_read server-version)
newver=$svr_version
echo "${gre}${dim}Webinoly Configuration file was found, so we will use it!${end}"
# Reinstall after uninstalled! (Can be considered new)
if [[ -z $update ]] && ! [[ $ver =~ ^(alpha|beta)$ ]]; then
new_install="true"
echo "${blu}${dim}It seems like you're reinstalling Webinoly! (Upgrading from: ${oldapp})${end} ${blu}${bol}Welcome back!!!${end}"
# Downgrade!
elif [[ -n $update && $type == "Custom" ]]; then
echo "${blu}Updating to the latest version is always recommended! ${dim}(Downgrade to: ${ver})${end}"
fi
elif [[ $type == "Custom" ]]; then
echo "${blu}Custom version installed: ${ver}${end}"
else
new_install="true"
fi
# Write app version
webyversion=$app_version
conf_write app-version $webyversion
if [[ $ver =~ ^(alpha|beta)$ ]]; then
conf_write branch $ver
echo "${blu}${bol}This is a testing version, please don't use it in production!${end}"
fi
# Ping to Webinoly Stats
if [[ $statskip != "true" ]]; then
opt=$setup
branch="Public"
if [[ $new_install == "true" ]]; then
type="New"
elif [[ $ver == "beta" ]]; then
type="Beta"
elif [[ -n $update && $type == "Custom" ]]; then
type="Downgrade"
webyversion=$(wget --timeout=10 -t 1 -qO- https://api.webinoly.com/check?text=true)
opt=$ver
elif [[ -n $update && -n $oldapp ]]; then
type="Updates"
opt=$oldapp
elif [[ $type == "Custom" ]]; then
webyversion=$(wget --timeout=10 -t 1 -qO- https://api.webinoly.com/check?text=true)
opt=$ver
else
type="Error"
conf_write init-error-flag true
echo "${red}[ERROR] Installation method not recognized!${end}"
fi
wget https://api.webinoly.com/stats/?install=${branch}:${webyversion}:${type}:${opt} --referer="Webinoly-Internal-Verified-Stats" --spider --timeout=15 -t 1 -q
fi
# Update stack!
[[ -n $oldver && $(version $newver) -gt $(version $oldver) ]] && source /opt/webinoly/lib/update
[[ -f /usr/bin/duply && -f /opt/webinoly/templates/general/duply ]] && sudo cp /opt/webinoly/templates/general/duply /usr/bin/ && sudo chmod 755 /usr/bin/duply
# Stack installation
[[ $setup == 1 ]] && stack -nginx
[[ $setup == 2 ]] && stack -php=nginx
[[ $setup == 3 ]] && stack -lemp
# Verify installation!
if [[ $setup != [123] && -n $update && -n $oldapp ]]; then
sudo webinoly -verify=critical -check-for-updates
elif [[ $setup != [123] ]]; then
sudo webinoly -verify=critical
fi
# Message Center
if [[ -z $(conf_read stack-build-error-flag) && $type != "Error" ]]; then # We use $type instead of dynvar to not make it persistant!
if [[ $new_install == "true" && $setup == 0 ]]; then
echo "${blu}You have chosen the option '0', it means that you have to manually build your own stack."
echo "But, don't worry! With Webinoly this is an easy task, just use the stack command, i.e. 'sudo stack -lemp' ${end}"
fi
if [[ -z $update ]]; then
echo ""
echo "${blu}${bol}Don't like our defaults? Every part of Webinoly is overridable!${end}"
echo "${blu}- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "
echo "${blu}Please, read the documentation:${end}${dim} https://webinoly.com/documentation/${end}"
echo "${blu}Be sure your firewall ports are correctly set:${end}${dim} https://webinoly.com/install/${end}"
echo "${blu}Configuration file is here:${end}${dim} /opt/webinoly/webinoly.conf${end}"
echo ""
fi
[[ $setup == 0 ]] && echo "${gre}${dim}Webinoly has been successfully installed!!!${end}"
[[ $setup == 1 ]] && echo "${gre}${dim}Nginx and some other useful tools have been installed successfully! ${end}"
[[ $setup == 2 ]] && echo "${gre}${dim}Nginx, PHP and some other useful tools have been installed successfully! ${end}"
[[ $setup == 3 ]] && echo "${gre}${dim}Nginx, PHP, MySQL (MariaDB) and some other useful tools have been installed successfully! ${end}"
echo "${blu}"
echo "****************************************************************************"
echo "************************* WEBINOLY PREMIUM *************************"
echo "***** ${bol}Become a Sponsor now and be part of our Premium Community!${end}${blu} *****"
echo "****************************************************************************"
echo "************* Bitcoin: ${end}${dim}1E3Ybo5UcvaAr1MoK4nBnMRFFY9aEMiku3 ${end}${blu}**********"
echo "******* GitHub Sponsors:${end}${dim} https://github.com/sponsors/QROkes ${end}${blu}**********"
echo "*************** PayPal:${end}${dim} https://www.paypal.me/qrokes ${end}${blu}****************"
echo "****************************************************************************"
echo "********** ${end}${dim}Help me keep this project moving forward.${end}${blu} ***********"
echo "****************************************************************************"
echo "${end}"
else
echo "${red}[ERROR] Sorry, unexpected error during installation and building stack process!${end}"
fi
# Remove Installation File
sudo rm weby
app_purge