-
-
Notifications
You must be signed in to change notification settings - Fork 96
Expand file tree
/
Copy pathweby
More file actions
291 lines (253 loc) · 11.1 KB
/
weby
File metadata and controls
291 lines (253 loc) · 11.1 KB
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
#!/bin/bash
# Webinoly Installation Script.
readonly os_supported_latest=("noble" "24.04" "1.18.0") # Newest Ubuntu supported, including first Webinoly version with full support.
readonly os_supported_stable=("jammy" "22.04") # Supported in all versions available of Webinoly.
readonly os_supported_legacy=("focal" "20.04" "1.19.1") # Oldest Ubuntu. Partially supported. No new installations, updates only! Webinoly version when support was removed.
# 24.04 noble - 1.18.0
# 22.04 jammy - 1.16.6
# 20.04 focal - 1.12.0
# 18.04 bionic - 1.4.2
# 16.04 xenial - 1.0.0
# Check OS support
distr=$(awk -F= '/^ID=/{print $2}' /etc/os-release)
osver=$(awk -F= '/^VERSION_CODENAME=/{print $2}' /etc/os-release)
# Check for custom version
if [[ $2 == "-ver="* ]]; then
ver=$(echo "$2" | cut -d'=' -f 2 -s)
[[ $(echo ${ver//'*'} | sed 's/\.//g') =~ ^[0-9]+$ ]] && ver_int=$(echo ${ver//'*'} | sed 's/\.//g')
# 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
# Check for supported OS
if [[ $distr != "ubuntu" ]] || ! [[ $osver =~ ^(${os_supported_legacy[0]}|${os_supported_stable[0]}|${os_supported_latest[0]})$ ]]; then
echo "$(tput setaf 1)"
echo "[ERROR] Operating system not supported! $(tput dim)(${distr} '${osver}')"
echo "$(tput sgr0)"
sudo rm weby
exit 1
# Block new installs for oldest legacy Ubuntu supported, only updates are allowed...
elif [[ $osver == ${os_supported_legacy[0]} && $1 != "upd" ]]; then
# Old Webinoly versions are allowed...
if [[ -n $ver_int && $ver_int -gt $(echo ${os_supported_legacy[2]} | sed 's/\.//g') ]]; then
echo "$(tput setaf 1)"
echo "[ERROR] Sorry, Ubuntu '${os_supported_legacy[1]}' is no longer supported for new installs."
echo "$(tput dim)Webinoly ${os_supported_legacy[2]} was the last version with full support."
echo "$(tput dim)Use only if absolutely needed — at your own risk."
echo "$(tput sgr0)"
sudo rm weby
exit 1
elif [[ -n $ver_int && $ver_int -le $(echo ${os_supported_legacy[2]} | sed 's/\.//g') ]]; then
echo "$(tput setaf 1)"
echo "[WARNING] Legacy mode. Use Ubuntu ${os_supported_stable[1]} or newer!"
echo "$(tput dim)Use only if absolutely needed — at your own risk."
echo "$(tput sgr0)"
else
# No new installations with the latest Webinoly...
echo "$(tput setaf 1)"
echo "[ERROR] Sorry, Ubuntu '${os_supported_legacy[1]}' is no longer supported for new installs."
echo "$(tput dim)Please use Ubuntu ${os_supported_stable[1]} or newer!"
echo "$(tput sgr0)"
sudo rm weby
exit 1
fi
# Newest Ubuntu supported only after this version...
elif [[ $osver == ${os_supported_latest[0]} && -n $ver_int && $ver_int -lt $(echo ${os_supported_latest[2]} | sed 's/\.//g') ]]; then
echo "$(tput setaf 1)"
echo "[ERROR] This Webinoly version does not support Ubuntu ${os_supported_latest[1]}."
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’ve selected option ‘0’, giving you full control to customize the configuration before building your stack."
echo "Build your stack anytime with:${end}${dim} 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
echo "${gre}Webinoly v${webyversion} installed successfully!${end}"
[[ $setup == 0 ]] && echo "${blu}${dim}Clean installation, no packages installed. ${end}"
[[ $setup == 1 ]] && echo "${blu}${dim}Nginx have been installed successfully! ${end}"
[[ $setup == 2 ]] && echo "${blu}${dim}Nginx and PHP installed successfully! ${end}"
[[ $setup == 3 ]] && echo "${blu}${dim}Full LEMP Stack 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 ""
echo "${bol}+ Give Webinoly a GitHub star!${dim} https://github.com/QROkes/webinoly"
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