From 189f85aa71efca755a65a9a53dd6279b7ece57f4 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 18 Jan 2015 14:18:50 +0000 Subject: [PATCH] Loop until something happens --- src/freedombone | 300 +++++++++++++++++++++++------------------------- 1 file changed, 144 insertions(+), 156 deletions(-) diff --git a/src/freedombone b/src/freedombone index 57df92cd..be6a84a0 100755 --- a/src/freedombone +++ b/src/freedombone @@ -666,53 +666,40 @@ function interactive_configuration { 255) exit 0;; esac - if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 - dialog --backtitle "Freedombone Configuration" \ - --inputbox "Wiki Title" 10 30 2> $data - sel=$? - case $sel in - 0) WIKI_TITLE=$(cat $data);; - 1) exit 0;; - 255) exit 0;; - esac - if [ ! $WIKI_TITLE ]; then - exit 5638 - fi - - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 - dialog --backtitle "Freedombone Configuration" \ - --inputbox "Wiki domain name" 10 30 2> $data - sel=$? - case $sel in - 0) WIKI_DOMAIN_NAME=$(cat $data);; - 1) exit 0;; - 255) exit 0;; - esac - if [ ! $WIKI_DOMAIN_NAME ]; then - exit 9236 - fi - if [ ! $DOMAIN_NAME ]; then - DOMAIN_NAME=$WIKI_DOMAIN_NAME - fi - - if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then + while [ ! $WIKI_DOMAIN_NAME ] + do data=$(tempfile 2>/dev/null) trap "rm -f $data" 0 1 2 5 15 - dialog --backtitle "Freedombone Configuration" \ - --inputbox "Wiki FreeDNS subdomain code" 10 30 2> $data + 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 "My Wiki" 1 16 16 15 \ + "Domain:" 2 1 "" 2 16 16 15 \ + "FreeDNS code:" 3 1 "" 3 16 16 15 \ + 2> $data + else + dialog --backtitle "Freedombone Configuration" \ + --title "Wiki Configuration" \ + --form "\nPlease enter your wiki details:" 11 55 3 \ + "Title:" 1 1 "My Wiki" 1 16 16 15 \ + "Domain:" 2 1 "" 2 16 16 15 \ + 2> $data + fi sel=$? case $sel in - 0) WIKI_FREEDNS_SUBDOMAIN_CODE=$(cat $data);; 1) exit 0;; 255) exit 0;; esac - if [ ! $WIKI_FREEDNS_SUBDOMAIN_CODE ]; then - exit 5277 - fi + WIKI_TITLE=$(cat $data | sed -n 1p) + WIKI_DOMAIN_NAME=$(cat $data | sed -n 2p) + done + if [ ! $DOMAIN_NAME ]; then + DOMAIN_NAME=$WIKI_DOMAIN_NAME + fi + if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then + WIKI_FREEDNS_SUBDOMAIN_CODE=$(cat $data | sed -n 3p) if [[ $DOMAIN_NAME == "$WIKI_DOMAIN_NAME" ]]; then FREEDNS_SUBDOMAIN_CODE=$WIKI_FREEDNS_SUBDOMAIN_CODE fi @@ -720,151 +707,152 @@ function interactive_configuration { fi if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 - dialog --backtitle "Freedombone Configuration" \ - --inputbox "Blog Title" 10 30 2> $data - sel=$? - case $sel in - 0) MY_BLOG_TITLE=$(cat $data);; - 1) exit 0;; - 255) exit 0;; - esac - - if [ $MY_BLOG_TITLE ]; then + while [ ! $FULLBLOG_DOMAIN_NAME ] + do data=$(tempfile 2>/dev/null) trap "rm -f $data" 0 1 2 5 15 - dialog --backtitle "Freedombone Configuration" \ - --inputbox "Blog domain name" 10 30 2> $data + 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 "My Blog" 1 16 16 15 \ + "Domain:" 2 1 "" 2 16 16 15 \ + "FreeDNS code:" 3 1 "" 3 16 16 15 \ + 2> $data + else + dialog --backtitle "Freedombone Configuration" \ + --title "Blog Configuration" \ + --form "\nPlease enter your blog details:" 11 55 3 \ + "Title:" 1 1 "My Blog" 1 16 16 15 \ + "Domain:" 2 1 "" 2 16 16 15 \ + 2> $data + fi sel=$? case $sel in - 0) FULLBLOG_DOMAIN_NAME=$(cat $data);; 1) exit 0;; 255) exit 0;; esac - if [ ! $FULLBLOG_DOMAIN_NAME ]; then - exit 7648 - fi - - if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 - dialog --backtitle "Freedombone Configuration" \ - --inputbox "Blog FreeDNS subdomain code" 10 30 2> $data - sel=$? - case $sel in - 0) FULLBLOG_FREEDNS_SUBDOMAIN_CODE=$(cat $data);; - 1) exit 0;; - 255) exit 0;; - esac - if [ ! $FULLBLOG_FREEDNS_SUBDOMAIN_CODE ]; then - exit 9875 - fi + MY_BLOG_TITLE=$(cat $data | sed -n 1p) + FULLBLOG_DOMAIN_NAME=$(cat $data | sed -n 2p) + done + if [ ! $DOMAIN_NAME ]; then + DOMAIN_NAME=$FULLBLOG_DOMAIN_NAME + fi + if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then + FULLBLOG_FREEDNS_SUBDOMAIN_CODE=$(cat $data | sed -n 3p) + if [[ $DOMAIN_NAME == "$FULLBLOG_DOMAIN_NAME" ]]; then + FREEDNS_SUBDOMAIN_CODE=$FULLBLOG_FREEDNS_SUBDOMAIN_CODE fi fi fi if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 - dialog --backtitle "Freedombone Configuration" \ - --inputbox "Owncloud domain name" 10 30 2> $data - sel=$? - case $sel in - 0) OWNCLOUD_DOMAIN_NAME=$(cat $data);; - 1) exit 0;; - 255) exit 0;; - esac - - if [ $OWNCLOUD_DOMAIN_NAME ]; then - if [ ! $DOMAIN_NAME ]; then - DOMAIN_NAME=$OWNCLOUD_DOMAIN_NAME - fi + while [ ! $OWNCLOUD_DOMAIN_NAME ] + do + data=$(tempfile 2>/dev/null) + trap "rm -f $data" 0 1 2 5 15 if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 dialog --backtitle "Freedombone Configuration" \ - --inputbox "Owncloud FreeDNS subdomain code" 10 30 2> $data - sel=$? - case $sel in - 0) OWNCLOUD_FREEDNS_SUBDOMAIN_CODE=$(cat $data);; - 1) exit 0;; - 255) exit 0;; - esac - if [ ! $OWNCLOUD_FREEDNS_SUBDOMAIN_CODE ]; then - exit 2583 - fi - if [[ $DOMAIN_NAME == "$OWNCLOUD_DOMAIN_NAME" ]]; then - FREEDNS_SUBDOMAIN_CODE=$OWNCLOUD_FREEDNS_SUBDOMAIN_CODE - fi + --title "Owncloud Configuration" \ + --form "\nPlease enter your Owncloud details:" 11 55 3 \ + "Domain:" 1 1 "" 1 16 16 15 \ + "FreeDNS code:" 2 1 "" 2 16 16 15 \ + 2> $data + else + dialog --backtitle "Freedombone Configuration" \ + --title "Owncloud Configuration" \ + --form "\nPlease enter your Owncloud details:" 11 55 3 \ + "Domain:" 1 1 "" 1 16 16 15 \ + 2> $data + fi + sel=$? + case $sel in + 1) exit 0;; + 255) exit 0;; + esac + OWNCLOUD_DOMAIN_NAME=$(cat $data | sed -n 1p) + done + if [ ! $DOMAIN_NAME ]; then + DOMAIN_NAME=$OWNCLOUD_DOMAIN_NAME + fi + if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then + OWNCLOUD_FREEDNS_SUBDOMAIN_CODE=$(cat $data | sed -n 2p) + if [[ $DOMAIN_NAME == "$OWNCLOUD_DOMAIN_NAME" ]]; then + FREEDNS_SUBDOMAIN_CODE=$OWNCLOUD_FREEDNS_SUBDOMAIN_CODE fi fi fi if [[ $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 - dialog --backtitle "Freedombone Configuration" \ - --inputbox "RedMatrix domain name" 10 30 2> $data - sel=$? - case $sel in - 0) REDMATRIX_DOMAIN_NAME=$(cat $data);; - 1) exit 0;; - 255) exit 0;; - esac - - if [ $REDMATRIX_DOMAIN_NAME ]; then - if [ ! $DOMAIN_NAME ]; then - DOMAIN_NAME=$REDMATRIX_DOMAIN_NAME - fi + while [ ! $REDMATRIX_DOMAIN_NAME ] + do + data=$(tempfile 2>/dev/null) + trap "rm -f $data" 0 1 2 5 15 if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 dialog --backtitle "Freedombone Configuration" \ - --inputbox "RedMatrix FreeDNS subdomain code" 10 30 2> $data - sel=$? - case $sel in - 0) REDMATRIX_FREEDNS_SUBDOMAIN_CODE=$(cat $data);; - 1) exit 0;; - 255) exit 0;; - esac - if [ ! $REDMATRIX_FREEDNS_SUBDOMAIN_CODE ]; then - exit 9654 - fi - if [[ $DOMAIN_NAME == "$REDMATRIX_DOMAIN_NAME" ]]; then - FREEDNS_SUBDOMAIN_CODE=$REDMATRIX_FREEDNS_SUBDOMAIN_CODE - fi + --title "RedMatrix Configuration" \ + --form "\nPlease enter your RedMatrix details:" 11 55 3 \ + "Domain:" 1 1 "" 1 16 16 15 \ + "FreeDNS code:" 2 1 "" 2 16 16 15 \ + 2> $data + else + dialog --backtitle "Freedombone Configuration" \ + --title "RedMatrix Configuration" \ + --form "\nPlease enter your RedMatrix details:" 11 55 3 \ + "Domain:" 1 1 "" 1 16 16 15 \ + 2> $data + fi + sel=$? + case $sel in + 1) exit 0;; + 255) exit 0;; + esac + REDMATRIX_DOMAIN_NAME=$(cat $data | sed -n 1p) + done + if [ ! $DOMAIN_NAME ]; then + DOMAIN_NAME=$REDMATRIX_DOMAIN_NAME + fi + if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then + REDMATRIX_FREEDNS_SUBDOMAIN_CODE=$(cat $data | sed -n 2p) + if [[ $DOMAIN_NAME == "$REDMATRIX_DOMAIN_NAME" ]]; then + FREEDNS_SUBDOMAIN_CODE=$REDMATRIX_FREEDNS_SUBDOMAIN_CODE fi fi fi if [[ $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 - dialog --backtitle "Freedombone Configuration" \ - --inputbox "Microblog domain name" 10 30 2> $data - sel=$? - case $sel in - 0) MICROBLOG_DOMAIN_NAME=$(cat $data);; - 1) exit 0;; - 255) exit 0;; - esac - - if [ $MICROBLOG_DOMAIN_NAME ]; then + while [ ! $MICROBLOG_DOMAIN_NAME ] + do + data=$(tempfile 2>/dev/null) + trap "rm -f $data" 0 1 2 5 15 if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 dialog --backtitle "Freedombone Configuration" \ - --inputbox "Microblog FreeDNS subdomain code" 10 30 2> $data - sel=$? - case $sel in - 0) MICROBLOG_FREEDNS_SUBDOMAIN_CODE=$(cat $data);; - 1) exit 0;; - 255) exit 0;; - esac - if [ ! $MICROBLOG_FREEDNS_SUBDOMAIN_CODE ]; then - exit 9508 - fi + --title "Microblog Configuration" \ + --form "\nPlease enter your Microblog details:" 11 55 3 \ + "Domain:" 1 1 "" 1 16 16 15 \ + "FreeDNS code:" 2 1 "" 2 16 16 15 \ + 2> $data + else + dialog --backtitle "Freedombone Configuration" \ + --title "Microblog Configuration" \ + --form "\nPlease enter your Microblog details:" 11 55 3 \ + "Domain:" 1 1 "" 1 16 16 15 \ + 2> $data + fi + sel=$? + case $sel in + 1) exit 0;; + 255) exit 0;; + esac + MICROBLOG_DOMAIN_NAME=$(cat $data | sed -n 1p) + done + if [ ! $DOMAIN_NAME ]; then + DOMAIN_NAME=$MICROBLOG_DOMAIN_NAME + fi + if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then + MICROBLOG_FREEDNS_SUBDOMAIN_CODE=$(cat $data | sed -n 2p) + if [[ $DOMAIN_NAME == "$MICROBLOG_DOMAIN_NAME" ]]; then + FREEDNS_SUBDOMAIN_CODE=$MICROBLOG_FREEDNS_SUBDOMAIN_CODE fi fi fi