Fix site details with title

This commit is contained in:
Bob Mottram 2016-10-15 22:01:59 +01:00
parent 393022a97e
commit 3263fb3fe6
1 changed files with 22 additions and 18 deletions

View File

@ -174,9 +174,11 @@ function interactive_site_details_with_title {
SITE_BACKTITLE=$"Freedombone Configuration"
SITE_CONFIG_TITLE=$"${site_name^} Configuration"
SITE_FORM_TEXT=$"\nPlease enter your ${site_name^} details.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:"
SITE_TITLE=$2
SITE_DOMAIN_NAME=$3
SITE_CODE=$4
SITE_TITLE=
SITE_DOMAIN_NAME=
SITE_CODE=
SITE_DETAILS_COMPLETE=
while [ ! $SITE_DETAILS_COMPLETE ]
do
@ -203,37 +205,39 @@ function interactive_site_details_with_title {
1) exit 1;;
255) exit 1;;
esac
${!SITE_TITLE}=$(cat $data | sed -n 1p)
${!SITE_DOMAIN_NAME}=$(cat $data | sed -n 2p)
if [ ${!SITE_DOMAIN_NAME} ]; then
TEST_DOMAIN_NAME=${!SITE_DOMAIN_NAME}
SITE_TITLE=$(cat $data | sed -n 1p)
SITE_DOMAIN_NAME=$(cat $data | sed -n 2p)
site_domain_name_str="$SITE_DOMAIN_NAME"
if [ ${#site_domain_name_str} -gt 1 ]; then
TEST_DOMAIN_NAME="$SITE_DOMAIN_NAME"
validate_domain_name
if [[ $TEST_DOMAIN_NAME != ${!SITE_DOMAIN_NAME} ]]; then
${!SITE_DOMAIN_NAME}=
if [[ "$TEST_DOMAIN_NAME" != "${SITE_DOMAIN_NAME}" ]]; then
SITE_DOMAIN_NAME=
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
else
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
${!SITE_CODE}=$(cat $data | sed -n 3p)
validate_freedns_code "${!SITE_CODE}"
SITE_CODE=$(cat $data | sed -n 3p)
validate_freedns_code "${SITE_CODE}"
if [ ! $VALID_CODE ]; then
${!SITE_DOMAIN_NAME}=
SITE_DOMAIN_NAME=
fi
fi
fi
fi
site_title_str="${!SITE_TITLE}"
site_title_str="$SITE_TITLE"
if [ ${#site_title_str} -gt 0 ]; then
if [ ${!SITE_DOMAIN_NAME} ]; then
if [ ${SITE_DOMAIN_NAME} ]; then
SITE_DETAILS_COMPLETE="yes"
fi
fi
done
# save the results in the config file
write_config_param "$SITE_TITLE" "${!SITE_TITLE}"
write_config_param "$SITE_DOMAIN_NAME" "${!SITE_DOMAIN_NAME}"
if [ ${!SITE_CODE} ]; then
write_config_param "$SITE_CODE" "${!SITE_CODE}"
write_config_param "$2" "${!SITE_TITLE}"
write_config_param "$3" "${!SITE_DOMAIN_NAME}"
site_code_str="$SITE_CODE"
if [ ${#site_code_str} -gt 1 ]; then
write_config_param "$4" "${!SITE_CODE}"
fi
}