Skip to content

Commit 8ba6ed8

Browse files
author
Kristan Kenney
committed
Merge branch 'develop' into webui-refresh-winterfell
2 parents ea6c9ac + ef9ad19 commit 8ba6ed8

12 files changed

+179
-77
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
*.gzip
44
*.gz
55
*.bz2
6+
*.deb
7+
68
.vscode
79
.DS_Store

bin/v-add-letsencrypt-domain

Lines changed: 79 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ query_le_v2() {
4949
curl -s -i -d "$post_data" "$1" -H "$content"
5050
}
5151

52-
52+
# Set DNS CAA record retrieval commands
53+
if [ ! -z "$DNS_SYSTEM" ]; then
54+
dns_domain=$($BIN/v-list-dns-domains $user | grep $domain | cut -d' ' -f1)
55+
caa_record=$($BIN/v-list-dns-records $user $domain | grep -i "CAA" | cut -d' ' -f1)
56+
fi
5357

5458
#----------------------------------------------------------#
5559
# Verifications #
@@ -122,11 +126,33 @@ if [ "$proto" = "http-01" ]; then
122126
done
123127
fi
124128

129+
# Ensure DNS CAA record exists for Let's Encrypt before requesting certificate
130+
if [ ! -z "$DNS_SYSTEM" ]; then
131+
# Check for DNS zone
132+
if [ "$dns_domain" = "$domain" ]; then
133+
# Replace DNS domain CAA records with Let's Encrypt values
134+
if [ -z "$caa_record" ]; then
135+
$BIN/v-add-dns-record $user $domain '@' 'CAA' 'issue 0 "letsencrypt.org"'
136+
else
137+
$BIN/v-delete-dns-record $user $domain $caa_record
138+
$BIN/v-add-dns-record $user $domain '@' 'CAA' 'issue 0 "letsencrypt.org"'
139+
fi
140+
fi
141+
fi
142+
125143
# Requesting nonce / STEP 1
126144
answer=$(curl -s -I "$LE_API/directory")
127145
nonce=$(echo "$answer" |grep Nonce |cut -f2 -d \ |tr -d '\r\n')
128146
status=$(echo "$answer"|grep HTTP/1.1 |tail -n1 |cut -f 2 -d ' ')
129147
if [[ "$status" -ne 200 ]]; then
148+
# Delete DNS CAA record
149+
if [ ! -z "$DNS_SYSTEM" ]; then
150+
if [ "$dns_domain" = "$domain" ]; then
151+
if [ ! -z "$caa_record" ]; then
152+
$BIN/v-delete-dns-record $user $domain $caa_record
153+
fi
154+
fi
155+
fi
130156
check_result $E_CONNECT "Let's Encrypt nonce request status $status"
131157
fi
132158

@@ -147,6 +173,14 @@ authz=$(echo "$answer" |grep "acme/authz" |cut -f2 -d '"')
147173
finalize=$(echo "$answer" |grep 'finalize":' |cut -f4 -d '"')
148174
status=$(echo "$answer" |grep HTTP/1.1 |tail -n1 |cut -f2 -d ' ')
149175
if [[ "$status" -ne 201 ]]; then
176+
# Delete DNS CAA record
177+
if [ ! -z "$DNS_SYSTEM" ]; then
178+
if [ "$dns_domain" = "$domain" ]; then
179+
if [ ! -z "$caa_record" ]; then
180+
$BIN/v-delete-dns-record $user $domain $caa_record
181+
fi
182+
fi
183+
fi
150184
check_result $E_CONNECT "Let's Encrypt new auth status $status"
151185
fi
152186

@@ -159,6 +193,17 @@ for auth in $authz; do
159193
nonce=$(echo "$answer" |grep Nonce |cut -f2 -d \ |tr -d '\r\n')
160194
status=$(echo "$answer"|grep HTTP/1.1 |tail -n1 |cut -f 2 -d ' ')
161195
if [[ "$status" -ne 200 ]]; then
196+
# Delete DNS CAA record
197+
if [ ! -z "$DNS_SYSTEM" ]; then
198+
dns_domain=$($BIN/v-list-dns-domains $user | grep $domain | cut -d' ' -f1)
199+
caa_record=$($BIN/v-list-dns-records $user $domain | grep -i "letsencrypt" | cut -d' ' -f1)
200+
201+
if [ "$dns_domain" = "$domain" ]; then
202+
if [ ! -z "$caa_record" ]; then
203+
$BIN/v-delete-dns-record $user $domain $caa_record
204+
fi
205+
fi
206+
fi
162207
check_result $E_CONNECT "Let's Encrypt acme/authz bad status $status"
163208
fi
164209

@@ -232,16 +277,49 @@ for auth in $authz; do
232277
nonce=$(echo "$answer" |grep Nonce |cut -f2 -d \ |tr -d '\r\n')
233278
status=$(echo "$answer"|grep HTTP/1.1 |tail -n1 |cut -f 2 -d ' ')
234279
if [[ "$status" -ne 200 ]]; then
280+
# Delete DNS CAA record
281+
if [ ! -z "$DNS_SYSTEM" ]; then
282+
dns_domain=$($BIN/v-list-dns-domains $user | grep $domain | cut -d' ' -f1)
283+
caa_record=$($BIN/v-list-dns-records $user $domain | grep -i "letsencrypt" | cut -d' ' -f1)
284+
285+
if [ "$dns_domain" = "$domain" ]; then
286+
if [ ! -z "$caa_record" ]; then
287+
$BIN/v-delete-dns-record $user $domain $caa_record
288+
fi
289+
fi
290+
fi
235291
check_result $E_CONNECT "Let's Encrypt validation status $status"
236292
fi
237293

238294
i=$((i + 1))
239295
if [ "$i" -gt 10 ]; then
296+
# Delete DNS CAA record
297+
if [ ! -z "$DNS_SYSTEM" ]; then
298+
dns_domain=$($BIN/v-list-dns-domains $user | grep $domain | cut -d' ' -f1)
299+
caa_record=$($BIN/v-list-dns-records $user $domain | grep -i "letsencrypt" | cut -d' ' -f1)
300+
301+
if [ "$dns_domain" = "$domain" ]; then
302+
if [ ! -z "$caa_record" ]; then
303+
$BIN/v-delete-dns-record $user $domain $caa_record
304+
fi
305+
fi
306+
fi
240307
check_result $E_CONNECT "Let's Encrypt domain validation timeout"
241308
fi
242309
sleep 1
243310
done
244311
if [ "$validation" = 'invalid' ]; then
312+
# Delete DNS CAA record
313+
if [ ! -z "$DNS_SYSTEM" ]; then
314+
dns_domain=$($BIN/v-list-dns-domains $user | grep $domain | cut -d' ' -f1)
315+
caa_record=$($BIN/v-list-dns-records $user $domain | grep -i "letsencrypt" | cut -d' ' -f1)
316+
317+
if [ "$dns_domain" = "$domain" ]; then
318+
if [ ! -z "$caa_record" ]; then
319+
$BIN/v-delete-dns-record $user $domain $caa_record
320+
fi
321+
fi
322+
fi
245323
check_result $E_CONNECT "Let's Encrypt domain verification failed"
246324
fi
247325
done

bin/v-delete-letsencrypt-domain

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,18 @@ fi
4646
# Action #
4747
#----------------------------------------------------------#
4848

49+
# Delete DNS CAA record
50+
if [ ! -z "$DNS_SYSTEM" ]; then
51+
dns_domain=$($BIN/v-list-dns-domains $user | grep $domain | cut -d' ' -f1)
52+
caa_record=$($BIN/v-list-dns-records $user $domain | grep -i "letsencrypt" | cut -d' ' -f1)
53+
54+
if [ "$dns_domain" = "$domain" ]; then
55+
if [ ! -z "$caa_record" ]; then
56+
$BIN/v-delete-dns-record $user $domain $caa_record
57+
fi
58+
fi
59+
fi
60+
4961
# Delete SSL
5062
if [ -z "$mail" ]; then
5163
$BIN/v-delete-web-domain-ssl $user $domain $restart >/dev/null 2>&1

bin/v-rebuild-mail-domains

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ U_MAIL_SSL=0
4545
SUSPENDED_MAIL=0
4646
U_DISK_MAIL=0
4747

48-
# Update mail templates
49-
$BIN/v-update-mail-templates
50-
5148
# Checking mail folder
5249
if [ ! -d "$USER_DATA/mail" ]; then
5350
rm -f $USER_DATA/mail

bin/v-update-mail-templates

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ fi
4040
# Update templates
4141
cp -rf $HESTIA/install/$type/templates/mail $HESTIA/data/templates/
4242

43+
# Rebuilding mail domains
44+
for user in $($BIN/v-list-sys-users plain); do
45+
$BIN/v-rebuild-mail-domains $user no
46+
done
47+
4348
#----------------------------------------------------------#
4449
# Hestia #
4550
#----------------------------------------------------------#

bin/v-update-web-templates

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,23 +41,21 @@ fi
4141
cp -rf $HESTIA/install/$type/templates/web $HESTIA/data/templates/
4242

4343
# Update Multi-PHP templates
44-
if [ -d "/etc/php/*/fpm" ]; then
45-
php_versions=$(ls /etc/php/*/fpm -d | wc -l)
46-
if [ "$php_versions" -gt 1 ]; then
47-
if [ "$WEB_SYSTEM" = "nginx" ]; then
48-
for tplname in $(ls $HESTIA/data/templates/web/$WEB_SYSTEM/ | grep -v 'default'); do
49-
rm -fr $HESTIA/data/templates/web/$WEB_SYSTEM/$tplname
50-
done
51-
fi
52-
for v in $(ls /etc/php/); do
53-
if [ ! -d "/etc/php/$v/fpm/pool.d/" ]; then
54-
continue
55-
fi
56-
v_tpl=$(echo "$v" | sed -e 's/[.]//')
57-
cp -f $HESTIA/install/$type/multiphp/$WEB_SYSTEM/PHP-$v_tpl.* $HESTIA/data/templates/web/$WEB_SYSTEM/
44+
php_versions=$(ls /etc/php/*/fpm -d 2>/dev/null | wc -l)
45+
if [ "$php_versions" -gt 1 ]; then
46+
if [ "$WEB_SYSTEM" = "nginx" ]; then
47+
for tplname in $(ls $HESTIA/data/templates/web/$WEB_SYSTEM/ | grep -v 'default'); do
48+
rm -fr $HESTIA/data/templates/web/$WEB_SYSTEM/$tplname
5849
done
59-
chmod a+x $HESTIA/data/templates/web/$WEB_SYSTEM/*.sh
6050
fi
51+
for v in $(ls /etc/php/); do
52+
if [ ! -d "/etc/php/$v/fpm/pool.d/" ]; then
53+
continue
54+
fi
55+
v_tpl=$(echo "$v" | sed -e 's/[.]//')
56+
cp -f $HESTIA/install/$type/multiphp/$WEB_SYSTEM/PHP-$v_tpl.* $HESTIA/data/templates/web/$WEB_SYSTEM/
57+
done
58+
chmod a+x $HESTIA/data/templates/web/$WEB_SYSTEM/*.sh
6159
fi
6260

6361
# Rebuilding web domains

install/hst-install-debian.sh

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ help() {
7979
-s, --hostname Set hostname
8080
-e, --email Set admin email
8181
-p, --password Set admin password
82+
-D, --with-debs Path to Hestia debs
8283
-f, --force Force installation
8384
-h, --help Print this help
8485
@@ -179,6 +180,7 @@ for arg; do
179180
--email) args="${args}-e " ;;
180181
--password) args="${args}-p " ;;
181182
--force) args="${args}-f " ;;
183+
--with-debs) args="${args}-D " ;;
182184
--help) args="${args}-h " ;;
183185
*) [[ "${arg:0:1}" == "-" ]] || delim="\""
184186
args="${args}${delim}${arg}${delim} ";;
@@ -187,7 +189,7 @@ done
187189
eval set -- "$args"
188190

189191
# Parsing arguments
190-
while getopts "a:n:w:v:j:k:m:g:d:x:z:c:t:i:b:r:o:q:l:y:s:e:p:fh" Option; do
192+
while getopts "a:n:w:v:j:k:m:g:d:x:z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
191193
case $Option in
192194
a) apache=$OPTARG ;; # Apache
193195
n) nginx=$OPTARG ;; # Nginx
@@ -212,6 +214,7 @@ while getopts "a:n:w:v:j:k:m:g:d:x:z:c:t:i:b:r:o:q:l:y:s:e:p:fh" Option; do
212214
s) servername=$OPTARG ;; # Hostname
213215
e) email=$OPTARG ;; # Admin email
214216
p) vpass=$OPTARG ;; # Admin password
217+
D) withdebs=$OPTARG ;; # Hestia debs path
215218
f) force='yes' ;; # Force install
216219
h) help ;; # Help
217220
*) help ;; # Print help (default)
@@ -281,6 +284,11 @@ fi
281284
# Clear the screen once launch permissions have been verified
282285
clear
283286

287+
# Configure apt to retry downloading on error
288+
if [ ! -f /etc/apt/apt.conf.d/80-retries ]; then
289+
echo "APT::Acquire::Retries \"3\";" > /etc/apt/apt.conf.d/80-retries
290+
fi
291+
284292
# Update apt repository
285293
echo "Please wait a moment while we update your systems APT repositories..."
286294
apt-get -qq update
@@ -819,6 +827,11 @@ if [ "$multiphp" = 'yes' ]; then
819827
software=$(echo "$software" | sed -e 's/php-phpseclib//')
820828
software=$(echo "$software" | sed -e 's/php-pgsql//')
821829
fi
830+
if [ -d "$withdebs" ]; then
831+
software=$(echo "$software" | sed -e 's/hestia-nginx//')
832+
software=$(echo "$software" | sed -e 's/hestia-php//')
833+
software=$(echo "$software" | sed -e 's/hestia//')
834+
fi
822835

823836
#----------------------------------------------------------#
824837
# Install packages #
@@ -850,6 +863,13 @@ echo
850863
# Check Installation result
851864
check_result $? "apt-get install failed"
852865

866+
# Install Hestia packages from local folder
867+
if [ ! -z "$withdebs" ] && [ -d "$withdebs" ]; then
868+
dpkg -i $withdebs/hestia_*.deb
869+
dpkg -i $withdebs/hestia-php_*.deb
870+
dpkg -i $withdebs/hestia-nginx_*.deb
871+
fi
872+
853873
# Restoring autostart policy
854874
rm -f /usr/sbin/policy-rc.d
855875

@@ -1776,7 +1796,7 @@ echo "(!) IMPORTANT: You must logout or restart the server before continuing."
17761796
echo -n " Do you want to logout now? [Y/N] "
17771797
read resetshell
17781798

1779-
if [ $resetshell = "Y" ] || [ $resetshell = "y" ]; then
1799+
if [ "$resetshell" = "Y" ] || [ "$resetshell" = "y" ]; then
17801800
logout
17811801
fi
17821802

install/hst-install-ubuntu.sh

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ help() {
6464
-s, --hostname Set hostname
6565
-e, --email Set admin email
6666
-p, --password Set admin password
67+
-D, --with-debs Path to Hestia debs
6768
-f, --force Force installation
6869
-h, --help Print this help
6970
@@ -164,6 +165,7 @@ for arg; do
164165
--email) args="${args}-e " ;;
165166
--password) args="${args}-p " ;;
166167
--force) args="${args}-f " ;;
168+
--with-debs) args="${args}-D " ;;
167169
--help) args="${args}-h " ;;
168170
*) [[ "${arg:0:1}" == "-" ]] || delim="\""
169171
args="${args}${delim}${arg}${delim} ";;
@@ -172,7 +174,7 @@ done
172174
eval set -- "$args"
173175

174176
# Parsing arguments
175-
while getopts "a:n:w:v:j:k:m:g:d:x:z:c:t:i:b:r:o:q:l:y:s:e:p:fh" Option; do
177+
while getopts "a:n:w:v:j:k:m:g:d:x:z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
176178
case $Option in
177179
a) apache=$OPTARG ;; # Apache
178180
n) nginx=$OPTARG ;; # Nginx
@@ -197,6 +199,7 @@ while getopts "a:n:w:v:j:k:m:g:d:x:z:c:t:i:b:r:o:q:l:y:s:e:p:fh" Option; do
197199
s) servername=$OPTARG ;; # Hostname
198200
e) email=$OPTARG ;; # Admin email
199201
p) vpass=$OPTARG ;; # Admin password
202+
D) withdebs=$OPTARG ;; # Hestia debs path
200203
f) force='yes' ;; # Force install
201204
h) help ;; # Help
202205
*) help ;; # Print help (default)
@@ -266,6 +269,11 @@ fi
266269
# Clear the screen once launch permissions have been verified
267270
clear
268271

272+
# Configure apt to retry downloading on error
273+
if [ ! -f /etc/apt/apt.conf.d/80-retries ]; then
274+
echo "APT::Acquire::Retries \"3\";" > /etc/apt/apt.conf.d/80-retries
275+
fi
276+
269277
# Update apt repository
270278
echo "Please wait a moment while we update your systems APT repositories..."
271279
apt-get -qq update
@@ -781,6 +789,11 @@ if [ "$multiphp" = 'yes' ]; then
781789
software=$(echo "$software" | sed -e 's/php-phpseclib//')
782790
software=$(echo "$software" | sed -e 's/php-pgsql//')
783791
fi
792+
if [ -d "$withdebs" ]; then
793+
software=$(echo "$software" | sed -e 's/hestia-nginx//')
794+
software=$(echo "$software" | sed -e 's/hestia-php//')
795+
software=$(echo "$software" | sed -e 's/hestia//')
796+
fi
784797

785798
#----------------------------------------------------------#
786799
# Disable Apparmor on LXC #
@@ -824,6 +837,13 @@ echo
824837
# Check Installation result
825838
check_result $? "apt-get install failed"
826839

840+
# Install Hestia packages from local folder
841+
if [ ! -z "$withdebs" ] && [ -d "$withdebs" ]; then
842+
dpkg -i $withdebs/hestia_*.deb
843+
dpkg -i $withdebs/hestia-php_*.deb
844+
dpkg -i $withdebs/hestia-nginx_*.deb
845+
fi
846+
827847
# Restoring autostart policy
828848
rm -f /usr/sbin/policy-rc.d
829849

@@ -1682,7 +1702,7 @@ echo "(!) IMPORTANT: You must logout or restart the server before continuing."
16821702
echo -n " Do you want to logout now? [Y/N] "
16831703
read resetshell
16841704

1685-
if [ $resetshell = "Y" ] || [ $resetshell = "y" ]; then
1705+
if [ "$resetshell" = "Y" ] || [ "$resetshell" = "y" ]; then
16861706
logout
16871707
fi
16881708

0 commit comments

Comments
 (0)