get certbot domain to construct path later for subst

This commit is contained in:
Asif Bacchus 2019-01-04 22:26:47 -07:00
parent 1d7aac147e
commit f5412da2fa
1 changed files with 57 additions and 0 deletions

View File

@ -18,6 +18,7 @@ norm="\e[0m"
# set variables
detectedIP=$(ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\1/p')
regexIP4="(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"
regexHostname="(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])"
# quick intro for the user
@ -54,4 +55,60 @@ while true; do
esac
done
### SSL related options
# using certbot?
while true; do
read -p "Are you using Certbot to handle your SSL certificates? (default: NO) " yn
case $yn in
[Yy]*)
useCertbot=1
break
;;
[Nn]|'')
useCertbot=0
unset CertbotDomain
break
;;
[Xx]*)
echo -e "\n${cyan}---exiting---\n${norm}"
exit 1
;;
*)
echo -e "\n${err}Please answer (Y)es, (N)o, e(X)it or accept default${norm}"
;;
esac
done
# using Certbot: get primary domain name since that how Certbot determines paths
if [ "${useCertbot}" -eq 1 ]; then
while true; do
read -p "What is the primary domain for your Certbot Certificates? " inputCertbotDomain
case $inputCertbotDomain in
'')
echo -e "\n${err}You cannot have an empty domain name${norm}"
;;
[Xx]*)
echo -e "\n${cyan}---exiting---\n${norm}"
exit 1
;;
*)
# check hostname for validity
if [[ "${inputCertbotDomain}" =~ ^${regexHostname}$ ]]; then
CertbotDomain="${inputCertbotDomain}"
break
else
echo -e "\n${err}Invalid hostname${norm}"
fi
;;
esac
done
fi
# debug section
echo "Local IP4: $IP4"
echo "Using Certbot: $useCertbot"
echo "CertbotDomain: $CertbotDomain"
exit 0