Skip to content

Commit 46d8c2f

Browse files
Validate email/hostname non interactive install (hestiacp#2532)
* Validate email/hostname non interactive install + Move FM / PHPMailer to a earlier step to prevent mail system failure when nginx / apache2 doesn't restart * Update spacing. * Update spacing. Co-authored-by: Raphael <rs@scit.ch>
1 parent 82eadf3 commit 46d8c2f

File tree

2 files changed

+91
-87
lines changed

2 files changed

+91
-87
lines changed

install/hst-install-debian.sh

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -603,41 +603,42 @@ if [ "$interactive" = 'yes' ]; then
603603
echo 'Goodbye'
604604
exit 1
605605
fi
606+
fi
606607

607-
# Asking for contact email
608-
if [ -z "$email" ]; then
609-
while validate_email; do
608+
# Validate Email / Hostname even when interactive = no
609+
# Asking for contact email
610+
if [ -z "$email" ]; then
611+
while validate_email; do
610612
echo -e "\nPlease use a valid emailadress (ex. info@domain.tld)."
611613
read -p 'Please enter admin email address: ' email
612-
done
613-
else
614-
if validate_email; then
615-
echo "Please use a valid emailadress (ex. info@domain.tld)."
616-
exit 1
617-
fi
614+
done
615+
else
616+
if validate_email; then
617+
echo "Please use a valid emailadress (ex. info@domain.tld)."
618+
exit 1
618619
fi
620+
fi
619621

620-
# Asking to set FQDN hostname
621-
if [ -z "$servername" ]; then
622-
# Ask and validate FQDN hostname.
623-
read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
622+
# Asking to set FQDN hostname
623+
if [ -z "$servername" ]; then
624+
# Ask and validate FQDN hostname.
625+
read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
624626

625-
# Set hostname if it wasn't set
626-
if [ -z "$servername" ]; then
627-
servername=$(hostname -f)
628-
fi
627+
# Set hostname if it wasn't set
628+
if [ -z "$servername" ]; then
629+
servername=$(hostname -f)
630+
fi
629631

630-
# Validate Hostname, go to loop if the validation fails.
631-
while validate_hostname; do
632-
echo -e "\nPlease use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
633-
read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
634-
done
635-
else
636-
# Validate FQDN hostname if it is preset
637-
if validate_hostname; then
638-
echo "Please use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
639-
exit 1
640-
fi
632+
# Validate Hostname, go to loop if the validation fails.
633+
while validate_hostname; do
634+
echo -e "\nPlease use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
635+
read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
636+
done
637+
else
638+
# Validate FQDN hostname if it is preset
639+
if validate_hostname; then
640+
echo "Please use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
641+
exit 1
641642
fi
642643
fi
643644

@@ -1886,6 +1887,20 @@ if [ "$sieve" = 'yes' ]; then
18861887
systemctl restart exim4 > /dev/null 2>&1
18871888
fi
18881889

1890+
#----------------------------------------------------------#
1891+
# Configure File Manager #
1892+
#----------------------------------------------------------#
1893+
1894+
echo "[ * ] Configuring File Manager..."
1895+
$HESTIA/bin/v-add-sys-filemanager quiet
1896+
1897+
#----------------------------------------------------------#
1898+
# Configure PHPMailer #
1899+
#----------------------------------------------------------#
1900+
1901+
echo "[ * ] Configuring PHPMailer..."
1902+
$HESTIA/bin/v-add-sys-phpmailer quiet
1903+
18891904
#----------------------------------------------------------#
18901905
# Configure API #
18911906
#----------------------------------------------------------#
@@ -2022,12 +2037,6 @@ chmod 755 /backup/
20222037
# create cronjob to generate ssl
20232038
echo "@reboot root sleep 10 && rm /etc/cron.d/hestia-ssl && PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:' && /usr/local/hestia/bin/v-add-letsencrypt-host" > /etc/cron.d/hestia-ssl
20242039

2025-
#----------------------------------------------------------#
2026-
# Configure File Manager #
2027-
#----------------------------------------------------------#
2028-
2029-
echo "[ * ] Configuring File Manager..."
2030-
$HESTIA/bin/v-add-sys-filemanager quiet
20312040

20322041
#----------------------------------------------------------#
20332042
# Set hestia.conf default values #
@@ -2058,12 +2067,6 @@ write_config_value "SERVER_SMTP_PASSWD" ""
20582067
write_config_value "SERVER_SMTP_ADDR" ""
20592068
write_config_value "POLICY_CSRF_STRICTNESS" "1"
20602069

2061-
#----------------------------------------------------------#
2062-
# Configure PHPMailer #
2063-
#----------------------------------------------------------#
2064-
2065-
echo "[ * ] Configuring PHPMailer..."
2066-
$HESTIA/bin/v-add-sys-phpmailer quiet
20672070

20682071
#----------------------------------------------------------#
20692072
# Hestia Access Info #

install/hst-install-ubuntu.sh

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -575,44 +575,45 @@ if [ "$interactive" = 'yes' ]; then
575575
echo 'Goodbye'
576576
exit 1
577577
fi
578+
fi
578579

579-
# Asking for contact email
580-
if [ -z "$email" ]; then
581-
while validate_email; do
582-
echo -e "\nPlease use a valid emailadress (ex. info@domain.tld)."
583-
read -p 'Please enter admin email address: ' email
584-
done
585-
else
580+
# Validate Email / Hostname even when interactive = no
581+
# Asking for contact email
582+
if [ -z "$email" ]; then
583+
while validate_email; do
584+
echo -e "\nPlease use a valid emailadress (ex. info@domain.tld)."
585+
read -p 'Please enter admin email address: ' email
586+
done
587+
else
586588
if validate_email; then
587-
echo "Please use a valid emailadress (ex. info@domain.tld)."
588-
exit 1
589-
fi
590-
fi
591-
592-
# Asking to set FQDN hostname
593-
if [ -z "$servername" ]; then
594-
# Ask and validate FQDN hostname.
595-
read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
596-
597-
# Set hostname if it wasn't set
598-
if [ -z "$servername" ]; then
599-
servername=$(hostname -f)
600-
fi
601-
602-
# Validate Hostname, go to loop if the validation fails.
603-
while validate_hostname; do
604-
echo -e "\nPlease use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
605-
read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
606-
done
607-
else
608-
# Validate FQDN hostname if it is preset
609-
if validate_hostname; then
610-
echo "Please use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
611-
exit 1
612-
fi
589+
echo "Please use a valid emailadress (ex. info@domain.tld)."
590+
exit 1
613591
fi
614592
fi
615593

594+
# Asking to set FQDN hostname
595+
if [ -z "$servername" ]; then
596+
# Ask and validate FQDN hostname.
597+
read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
598+
599+
# Set hostname if it wasn't set
600+
if [ -z "$servername" ]; then
601+
servername=$(hostname -f)
602+
fi
603+
604+
# Validate Hostname, go to loop if the validation fails.
605+
while validate_hostname; do
606+
echo -e "\nPlease use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
607+
read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
608+
done
609+
else
610+
# Validate FQDN hostname if it is preset
611+
if validate_hostname; then
612+
echo "Please use a valid hostname according to RFC1178 (ex. hostname.domain.tld)."
613+
exit 1
614+
fi
615+
fi
616+
616617
# Generating admin password if it wasn't set
617618
if [ -z "$vpass" ]; then
618619
vpass=$(gen_pass)
@@ -1910,6 +1911,20 @@ else
19101911
$HESTIA/bin/v-change-sys-api disable
19111912
fi
19121913

1914+
#----------------------------------------------------------#
1915+
# Configure File Manager #
1916+
#----------------------------------------------------------#
1917+
1918+
echo "[ * ] Configuring File Manager..."
1919+
$HESTIA/bin/v-add-sys-filemanager quiet
1920+
1921+
#----------------------------------------------------------#
1922+
# Configure PHPMailer #
1923+
#----------------------------------------------------------#
1924+
1925+
echo "[ * ] Configuring PHPMailer..."
1926+
$HESTIA/bin/v-add-sys-phpmailer quiet
1927+
19131928

19141929
#----------------------------------------------------------#
19151930
# Configure IP #
@@ -2048,13 +2063,6 @@ chmod 755 /backup/
20482063
# create cronjob to generate ssl
20492064
echo "@reboot root sleep 10 && rm /etc/cron.d/hestia-ssl && PATH='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:' && /usr/local/hestia/bin/v-add-letsencrypt-host" > /etc/cron.d/hestia-ssl
20502065

2051-
#----------------------------------------------------------#
2052-
# Configure File Manager #
2053-
#----------------------------------------------------------#
2054-
2055-
echo "[ * ] Configuring File Manager..."
2056-
$HESTIA/bin/v-add-sys-filemanager quiet
2057-
20582066
#----------------------------------------------------------#
20592067
# Set hestia.conf default values #
20602068
#----------------------------------------------------------#
@@ -2084,13 +2092,6 @@ write_config_value "SERVER_SMTP_PASSWD" ""
20842092
write_config_value "SERVER_SMTP_ADDR" ""
20852093
write_config_value "POLICY_CSRF_STRICTNESS" "1"
20862094

2087-
#----------------------------------------------------------#
2088-
# Configure PHPMailer #
2089-
#----------------------------------------------------------#
2090-
2091-
echo "[ * ] Configuring PHPMailer..."
2092-
$HESTIA/bin/v-add-sys-phpmailer quiet
2093-
20942095
#----------------------------------------------------------#
20952096
# Hestia Access Info #
20962097
#----------------------------------------------------------#

0 commit comments

Comments
 (0)