diff --git a/src/freedombone-app-blog b/src/freedombone-app-blog index 139b9e67..6ea7d75b 100755 --- a/src/freedombone-app-blog +++ b/src/freedombone-app-blog @@ -112,63 +112,12 @@ function install_interactive_blog { if [[ $ONION_ONLY != "no" ]]; then MY_BLOG_TITLE='My Blog' FULLBLOG_DOMAIN_NAME='blog.local' + write_config_param "MY_BLOG_TITLE" "$MY_BLOG_TITLE" + write_config_param "FULLBLOG_DOMAIN_NAME" "$FULLBLOG_DOMAIN_NAME" else - FULLBLOG_DETAILS_COMPLETE= - while [ ! $FULLBLOG_DETAILS_COMPLETE ] - do - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 - if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then - dialog --backtitle $"Freedombone Configuration" \ - --title $"Blog Configuration" \ - --form $"\nPlease enter your blog details:" 11 55 4 \ - $"Title:" 1 1 "$(grep 'MY_BLOG_TITLE' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \ - $"Domain:" 2 1 "$(grep 'FULLBLOG_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 2 16 33 40 \ - $"Code:" 3 1 "$(grep 'FULLBLOG_CODE' temp.cfg | awk -F '=' '{print $2}')" 3 16 33 255 \ - 2> $data - else - dialog --backtitle $"Freedombone Configuration" \ - --title $"Blog Configuration" \ - --form $"\nPlease enter your blog details:" 11 55 3 \ - $"Title:" 1 1 "$(grep 'MY_BLOG_TITLE' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \ - $"Domain:" 2 1 "$(grep 'FULLBLOG_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 2 16 33 40 \ - 2> $data - fi - sel=$? - case $sel in - 1) exit 1;; - 255) exit 1;; - esac - MY_BLOG_TITLE=$(cat $data | sed -n 1p) - FULLBLOG_DOMAIN_NAME=$(cat $data | sed -n 2p) - if [ $FULLBLOG_DOMAIN_NAME ]; then - if [[ $FULLBLOG_DOMAIN_NAME == "$WIKI_DOMAIN_NAME" ]]; then - FULLBLOG_DOMAIN_NAME="" - fi - TEST_DOMAIN_NAME=$FULLBLOG_DOMAIN_NAME - validate_domain_name - if [[ $TEST_DOMAIN_NAME != $FULLBLOG_DOMAIN_NAME ]]; then - FULLBLOG_DOMAIN_NAME= - dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50 - else - if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then - FULLBLOG_CODE=$(cat $data | sed -n 3p) - validate_freedns_code "$FULLBLOG_CODE" - if [ ! $VALID_CODE ]; then - FULLBLOG_DOMAIN_NAME= - fi - fi - fi - fi - if [ $FULLBLOG_DOMAIN_NAME ]; then - FULLBLOG_DETAILS_COMPLETE="yes" - fi - done - - write_config_param "FULLBLOG_CODE" "$FULLBLOG_CODE" + function_check interactive_site_details_with_title + interactive_site_details_with_title "blog" "MY_BLOG_TITLE" "FULLBLOG_DOMAIN_NAME" "FULLBLOG_CODE" fi - write_config_param "MY_BLOG_TITLE" "$MY_BLOG_TITLE" - write_config_param "FULLBLOG_DOMAIN_NAME" "$FULLBLOG_DOMAIN_NAME" APP_INSTALLED=1 } diff --git a/src/freedombone-app-wiki b/src/freedombone-app-wiki index 55441cde..67ed498a 100755 --- a/src/freedombone-app-wiki +++ b/src/freedombone-app-wiki @@ -47,62 +47,12 @@ function install_interactive_wiki { if [[ $ONION_ONLY != "no" ]]; then WIKI_TITLE=$'My Wiki' WIKI_DOMAIN_NAME='wiki.local' + write_config_param "WIKI_TITLE" "$WIKI_TITLE" + write_config_param "WIKI_DOMAIN_NAME" "$WIKI_DOMAIN_NAME" else - WIKI_DETAILS_COMPLETE= - while [ ! $WIKI_DETAILS_COMPLETE ] - do - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 - - if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then - dialog --backtitle $"Freedombone Configuration" \ - --title $"Wiki Configuration" \ - --form $"\nPlease enter your wiki details:" 11 55 4 \ - $"Title:" 1 1 "$(grep 'WIKI_TITLE' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \ - $"Domain:" 2 1 "$(grep 'WIKI_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 2 16 33 40 \ - $"Code:" 3 1 "$(grep 'WIKI_CODE' temp.cfg | awk -F '=' '{print $2}')" 3 16 33 255 \ - 2> $data - else - dialog --backtitle $"Freedombone Configuration" \ - --title $"Wiki Configuration" \ - --form $"\nPlease enter your wiki details:" 11 55 3 \ - $"Title:" 1 1 "$(grep 'WIKI_TITLE' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \ - $"Domain:" 2 1 "$(grep 'WIKI_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 2 16 33 40 \ - 2> $data - fi - sel=$? - case $sel in - 1) exit 1;; - 255) exit 1;; - esac - WIKI_TITLE=$(cat $data | sed -n 1p) - WIKI_DOMAIN_NAME=$(cat $data | sed -n 2p) - if [ $WIKI_DOMAIN_NAME ]; then - TEST_DOMAIN_NAME=$WIKI_DOMAIN_NAME - validate_domain_name - if [[ $TEST_DOMAIN_NAME != $WIKI_DOMAIN_NAME ]]; then - WIKI_DOMAIN_NAME= - dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50 - else - if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then - WIKI_CODE=$(cat $data | sed -n 3p) - validate_freedns_code "$WIKI_CODE" - if [ ! $VALID_CODE ]; then - WIKI_DOMAIN_NAME= - fi - fi - fi - fi - if [ $WIKI_DOMAIN_NAME ]; then - WIKI_DETAILS_COMPLETE="yes" - fi - done - - # save the results in the config file - write_config_param "WIKI_CODE" "$WIKI_CODE" + function_check interactive_site_details_with_title + interactive_site_details_with_title "wiki" "WIKI_TITLE" "WIKI_DOMAIN_NAME" "WIKI_CODE" fi - write_config_param "WIKI_TITLE" "$WIKI_TITLE" - write_config_param "WIKI_DOMAIN_NAME" "$WIKI_DOMAIN_NAME" APP_INSTALLED=1 } diff --git a/src/freedombone-utils-interactive b/src/freedombone-utils-interactive index c951398a..203b4b7e 100755 --- a/src/freedombone-utils-interactive +++ b/src/freedombone-utils-interactive @@ -111,8 +111,8 @@ function interactive_site_details { site_name_upper=${site_name^^} 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_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_DOMAIN_NAME= SITE_CODE= SITE_DETAILS_COMPLETE= @@ -168,4 +168,72 @@ function interactive_site_details { fi } +function interactive_site_details_with_title { + site_name="${1}" + + 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_DETAILS_COMPLETE= + while [ ! $SITE_DETAILS_COMPLETE ] + do + data=$(tempfile 2>/dev/null) + trap "rm -f $data" 0 1 2 5 15 + if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then + dialog --backtitle $"Freedombone Configuration" \ + --title "$SITE_BACKTITLE" \ + --form "$SITE_FORM_TEXT" 14 55 4 \ + $"Title:" 1 1 "$(grep '$SITE_TITLE' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \ + $"Domain:" 2 1 "$(grep '$SITE_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 2 16 33 40 \ + $"Code:" 3 1 "$(grep '$SITE_CODE' temp.cfg | awk -F '=' '{print $2}')" 3 16 33 255 \ + 2> $data + else + dialog --backtitle "$SITE_BACKTITLE" \ + --title "$SITE_CONFIG_TITLE" \ + --form "$SITE_FORM_TEXT" 11 55 3 \ + $"Title:" 1 1 "$(grep '$SITE_TITLE' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \ + $"Domain:" 2 1 "$(grep '$SITE_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 2 16 33 40 \ + 2> $data + fi + sel=$? + case $sel in + 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} + validate_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}" + if [ ! $VALID_CODE ]; then + ${!SITE_DOMAIN_NAME}= + fi + fi + fi + fi + if [ ${!SITE_TITLE} ]; 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}" + fi +} + # NOTE: deliberately no exit 0