Fixing interactive installer

This commit is contained in:
Bob Mottram 2015-07-03 19:46:43 +01:00
parent 5e862cdc35
commit 2fec0b17ff
2 changed files with 65 additions and 63 deletions

View File

@ -245,30 +245,27 @@ function interactive_gpg_from_remote {
REMOTE_SERVERS_LIST=/home/$MY_USERNAME/keyshareservers.txt REMOTE_SERVERS_LIST=/home/$MY_USERNAME/keyshareservers.txt
# get a list of remote servers # get a list of remote servers
freedombone-remote -u $MY_USERNAME -l $REMOTE_SERVERS_LIST freedombone-remote -u $MY_USERNAME -l $REMOTE_SERVERS_LIST -t "Remote server"
if [ ! "$?" = "0" ]; then
if [ ! -f $REMOTE_SERVERS_LIST ]; then
dialog --title "Encryption keys" --msgbox 'Error obtaining server list' 6 70
echo "1" echo "1"
return return
fi fi
if [ ! -f $REMOTE_SERVERS_LIST ]; then
echo "2"
return
fi
# check the number of entries in the file # check the number of entries in the file
no_of_servers=$(cat $REMOTE_SERVERS_LIST | wc -l) no_of_servers=$(cat $REMOTE_SERVERS_LIST | wc -l)
if [[ ${no_of_servers} < 3 ]]; then if [[ ${no_of_servers} < 3 ]]; then
dialog --title "Encryption keys" --msgbox 'There must be at least three servers to recover the key' 6 70 dialog --title "Encryption keys" --msgbox 'There must be at least three servers to recover the key' 6 70
echo "3" echo "2"
return return
fi fi
# try to recover the key from the servers # try to recover the key from the servers
freedombone-recoverkey -u $MY_USERNAME -l $REMOTE_SERVERS_LIST freedombone-recoverkey -u $MY_USERNAME -l $REMOTE_SERVERS_LIST
if [ ! "$?" = "0" ]; then if [ ! "$?" = "0" ]; then
dialog --title "Encryption keys" --msgbox 'Your key could not be recovered' 6 70 dialog --title "Encryption keys" --msgbox 'Your key could not be recovered' 6 70
echo "4" echo "3"
return return
fi fi
@ -346,21 +343,21 @@ function interactive_gpg {
data=$(tempfile 2>/dev/null) data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15 trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \ dialog --backtitle "Freedombone Configuration" \
--radiolist "GPG/PGP keys for your system:" 17 40 3 \ --radiolist "GPG/PGP keys for your system:" 13 70 3 \
1 "Generate new keys (new user)" on \ 1 "Generate new keys (new user)" on \
2 "Import keys from a USB drive" off \ 2 "Import keys from a USB drive" off \
3 "Retrieve keys from friends servers" off 2> $data 3 "Retrieve keys from friends servers" off 2> $data
sel=$? sel=$?
case $sel in case $sel in
1) exit 0;; 1) exit 123;;
255) exit 0;; 255) exit 234;;
esac esac
case $(cat $data) in case $(cat $data) in
1) return;; 1) return;;
2) interactive_gpg_from_usb 2) interactive_gpg_from_usb
return;; return;;
3) retval=interactive_gpg_from_remote 3) interactive_gpg_from_remote
if [[ retval != '0' ]]; then if [ ! "$?" = "0" ]; then
GPG_CONFIGURED="no" GPG_CONFIGURED="no"
fi;; fi;;
esac esac
@ -393,8 +390,8 @@ function interactive_configuration {
9 Developer off 2> $data 9 Developer off 2> $data
sel=$? sel=$?
case $sel in case $sel in
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
case $(cat $data) in case $(cat $data) in
1) SYSTEM_TYPE=$VARIANT_FULL;; 1) SYSTEM_TYPE=$VARIANT_FULL;;
@ -417,8 +414,8 @@ function interactive_configuration {
sel=$? sel=$?
case $sel in case $sel in
0) MY_USERNAME=$(cat $data | awk -F '/' '{print $3}');; 0) MY_USERNAME=$(cat $data | awk -F '/' '{print $3}');;
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
if [ ! $MY_USERNAME ]; then if [ ! $MY_USERNAME ]; then
echo 'No user account was selected' echo 'No user account was selected'
@ -452,7 +449,7 @@ function interactive_configuration {
case $sel in case $sel in
0) INSTALLING_ON_BBB="yes";; 0) INSTALLING_ON_BBB="yes";;
1) INSTALLING_ON_BBB="no";; 1) INSTALLING_ON_BBB="no";;
255) exit 0;; 255) exit 1;;
esac esac
if [[ $INSTALLING_ON_BBB == "yes" ]]; then if [[ $INSTALLING_ON_BBB == "yes" ]]; then
USB_DRIVE=/dev/sda1 USB_DRIVE=/dev/sda1
@ -478,13 +475,13 @@ function interactive_configuration {
fi fi
sel=$? sel=$?
case $sel in case $sel in
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
case $(cat $data) in case $(cat $data) in
2) HWRNG_TYPE="beaglebone";; 2) HWRNG_TYPE="beaglebone";;
3) HWRNG_TYPE="onerng";; 3) HWRNG_TYPE="onerng";;
255) exit 0;; 255) exit 1;;
esac esac
save_configuration_file save_configuration_file
@ -543,8 +540,8 @@ function interactive_configuration {
49 "United States" on 2> $data 49 "United States" on 2> $data
sel=$? sel=$?
case $sel in case $sel in
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
case $(cat $data) in case $(cat $data) in
1) DEBIAN_REPO='ftp.au.debian.org';; 1) DEBIAN_REPO='ftp.au.debian.org';;
@ -596,7 +593,7 @@ function interactive_configuration {
47) DEBIAN_REPO='ftp.ua.debian.org';; 47) DEBIAN_REPO='ftp.ua.debian.org';;
48) DEBIAN_REPO='ftp.uk.debian.org';; 48) DEBIAN_REPO='ftp.uk.debian.org';;
49) DEBIAN_REPO='ftp.us.debian.org';; 49) DEBIAN_REPO='ftp.us.debian.org';;
255) exit 0;; 255) exit 1;;
esac esac
save_configuration_file save_configuration_file
@ -622,8 +619,8 @@ function interactive_configuration {
16 "Google" off 2> $data 16 "Google" off 2> $data
sel=$? sel=$?
case $sel in case $sel in
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
case $(cat $data) in case $(cat $data) in
1) NAMESERVER1='85.214.73.63' 1) NAMESERVER1='85.214.73.63'
@ -674,7 +671,7 @@ function interactive_configuration {
16) NAMESERVER1='8.8.8.8' 16) NAMESERVER1='8.8.8.8'
NAMESERVER2='4.4.4.4' NAMESERVER2='4.4.4.4'
;; ;;
255) exit 0;; 255) exit 1;;
esac esac
save_configuration_file save_configuration_file
@ -698,8 +695,8 @@ function interactive_configuration {
14 changeip off 2> $data 14 changeip off 2> $data
sel=$? sel=$?
case $sel in case $sel in
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
case $(cat $data) in case $(cat $data) in
1) DDNS_PROVIDER="default@dyndns.org";; 1) DDNS_PROVIDER="default@dyndns.org";;
@ -716,7 +713,7 @@ function interactive_configuration {
12) DDNS_PROVIDER="default@sitelutions.com";; 12) DDNS_PROVIDER="default@sitelutions.com";;
13) DDNS_PROVIDER="default@dnsexit.com";; 13) DDNS_PROVIDER="default@dnsexit.com";;
14) DDNS_PROVIDER="default@changeip.com";; 14) DDNS_PROVIDER="default@changeip.com";;
255) exit 0;; 255) exit 1;;
esac esac
save_configuration_file save_configuration_file
@ -729,8 +726,8 @@ function interactive_configuration {
sel=$? sel=$?
case $sel in case $sel in
0) DDNS_USERNAME=$(cat $data);; 0) DDNS_USERNAME=$(cat $data);;
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
done done
save_configuration_file save_configuration_file
@ -746,8 +743,8 @@ function interactive_configuration {
sel=$? sel=$?
case $sel in case $sel in
0) DDNS_PASSWORD=$(cat $data);; 0) DDNS_PASSWORD=$(cat $data);;
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
if [ ${#DDNS_PASSWORD} -lt $MINIMUM_PASSWORD_LENGTH ]; then if [ ${#DDNS_PASSWORD} -lt $MINIMUM_PASSWORD_LENGTH ]; then
dialog --title "Password quality check" --msgbox "The password given was too short. It must be at least $MINIMUM_PASSWORD_LENGTH characters. You may need to change your password on the dynamic DNS provider's web site." 10 40 dialog --title "Password quality check" --msgbox "The password given was too short. It must be at least $MINIMUM_PASSWORD_LENGTH characters. You may need to change your password on the dynamic DNS provider's web site." 10 40
@ -765,8 +762,8 @@ function interactive_configuration {
sel=$? sel=$?
case $sel in case $sel in
0) MY_NAME=$(cat $data);; 0) MY_NAME=$(cat $data);;
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
done done
save_configuration_file save_configuration_file
@ -793,8 +790,8 @@ function interactive_configuration {
2> $data 2> $data
sel=$? sel=$?
case $sel in case $sel in
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
LOCAL_NETWORK_STATIC_IP_ADDRESS=$(cat $data | sed -n 1p) LOCAL_NETWORK_STATIC_IP_ADDRESS=$(cat $data | sed -n 1p)
ROUTER_IP_ADDRESS=$(cat $data | sed -n 2p) ROUTER_IP_ADDRESS=$(cat $data | sed -n 2p)
@ -825,8 +822,8 @@ function interactive_configuration {
fi fi
sel=$? sel=$?
case $sel in case $sel in
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
WIKI_TITLE=$(cat $data | sed -n 1p) WIKI_TITLE=$(cat $data | sed -n 1p)
WIKI_DOMAIN_NAME=$(cat $data | sed -n 2p) WIKI_DOMAIN_NAME=$(cat $data | sed -n 2p)
@ -877,8 +874,8 @@ function interactive_configuration {
fi fi
sel=$? sel=$?
case $sel in case $sel in
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
MY_BLOG_TITLE=$(cat $data | sed -n 1p) MY_BLOG_TITLE=$(cat $data | sed -n 1p)
FULLBLOG_DOMAIN_NAME=$(cat $data | sed -n 2p) FULLBLOG_DOMAIN_NAME=$(cat $data | sed -n 2p)
@ -930,8 +927,8 @@ function interactive_configuration {
fi fi
sel=$? sel=$?
case $sel in case $sel in
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
OWNCLOUD_DOMAIN_NAME=$(cat $data | sed -n 1p) OWNCLOUD_DOMAIN_NAME=$(cat $data | sed -n 1p)
if [ $OWNCLOUD_DOMAIN_NAME ]; then if [ $OWNCLOUD_DOMAIN_NAME ]; then
@ -979,8 +976,8 @@ function interactive_configuration {
fi fi
sel=$? sel=$?
case $sel in case $sel in
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
REDMATRIX_DOMAIN_NAME=$(cat $data | sed -n 1p) REDMATRIX_DOMAIN_NAME=$(cat $data | sed -n 1p)
if [ $REDMATRIX_DOMAIN_NAME ]; then if [ $REDMATRIX_DOMAIN_NAME ]; then
@ -1028,8 +1025,8 @@ function interactive_configuration {
fi fi
sel=$? sel=$?
case $sel in case $sel in
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
MICROBLOG_DOMAIN_NAME=$(cat $data | sed -n 1p) MICROBLOG_DOMAIN_NAME=$(cat $data | sed -n 1p)
if [ $MICROBLOG_DOMAIN_NAME ]; then if [ $MICROBLOG_DOMAIN_NAME ]; then
@ -1081,8 +1078,8 @@ function interactive_configuration {
fi fi
sel=$? sel=$?
case $sel in case $sel in
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
GIT_DOMAIN_NAME=$(cat $data | sed -n 1p) GIT_DOMAIN_NAME=$(cat $data | sed -n 1p)
if [ $GIT_DOMAIN_NAME ]; then if [ $GIT_DOMAIN_NAME ]; then
@ -1124,8 +1121,8 @@ function interactive_configuration {
2> $data 2> $data
sel=$? sel=$?
case $sel in case $sel in
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
DEFAULT_DOMAIN_NAME=$(cat $data | sed -n 1p) DEFAULT_DOMAIN_NAME=$(cat $data | sed -n 1p)
DEFAULT_DOMAIN_CODE=$(cat $data | sed -n 2p) DEFAULT_DOMAIN_CODE=$(cat $data | sed -n 2p)
@ -1142,8 +1139,8 @@ function interactive_configuration {
sel=$? sel=$?
case $sel in case $sel in
0) DEFAULT_DOMAIN_NAME=$(cat $data);; 0) DEFAULT_DOMAIN_NAME=$(cat $data);;
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
fi fi
if [ $DEFAULT_DOMAIN_NAME ]; then if [ $DEFAULT_DOMAIN_NAME ]; then
@ -1176,8 +1173,8 @@ function interactive_configuration {
sel=$? sel=$?
case $sel in case $sel in
0) MY_EMAIL_ADDRESS=$(cat $data);; 0) MY_EMAIL_ADDRESS=$(cat $data);;
1) exit 0;; 1) exit 1;;
255) exit 0;; 255) exit 1;;
esac esac
done done

View File

@ -42,6 +42,9 @@ MINIMUM_PASSWORD_LENGTH=10
# How many remote locations were specified # How many remote locations were specified
entering_remote_backups_ctr=0 entering_remote_backups_ctr=0
# Title shown
TITLE='Remote Backup'
function show_help { function show_help {
echo '' echo ''
echo 'freedombone-remote -u [username] -l [backup list filename] -m [min password length]' echo 'freedombone-remote -u [username] -l [backup list filename] -m [min password length]'
@ -53,6 +56,7 @@ function show_help {
echo ' -u --username User to create the backups.list file for' echo ' -u --username User to create the backups.list file for'
echo ' -l --list Remote backup list (usually /home/$USER/backup.list)' echo ' -l --list Remote backup list (usually /home/$USER/backup.list)'
echo ' -m --min Minimum password length (characters)' echo ' -m --min Minimum password length (characters)'
echo ' -t --title Title shown'
echo '' echo ''
exit 0 exit 0
} }
@ -82,6 +86,11 @@ case $key in
shift shift
MINIMUM_PASSWORD_LENGTH="$1" MINIMUM_PASSWORD_LENGTH="$1"
;; ;;
# Title shown
-t|--title)
shift
TITLE="$1"
;;
*) *)
# unknown option # unknown option
;; ;;
@ -119,7 +128,7 @@ function interactive_configuration_remote_backups {
data=$(tempfile 2>/dev/null) data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15 trap "rm -f $data" 0 1 2 5 15
dialog --backtitle "Freedombone Configuration" \ dialog --backtitle "Freedombone Configuration" \
--title "Remote Backup ${entering_remote_backups_ctr}" \ --title "$TITLE ${entering_remote_backups_ctr}" \
--form "\nPlease specify the SSH login details:" 11 55 4 \ --form "\nPlease specify the SSH login details:" 11 55 4 \
"Username:" 1 1 "" 1 16 16 15 \ "Username:" 1 1 "" 1 16 16 15 \
"Domain:" 2 1 "" 2 16 16 15 \ "Domain:" 2 1 "" 2 16 16 15 \
@ -153,10 +162,6 @@ function interactive_configuration_remote_backups {
if [ -f $FRIENDS_SERVERS_LIST ]; then if [ -f $FRIENDS_SERVERS_LIST ]; then
chown $MY_USERNAME:$MY_USERNAME $FRIENDS_SERVERS_LIST chown $MY_USERNAME:$MY_USERNAME $FRIENDS_SERVERS_LIST
fi fi
if [[ ${entering_remote_backups_ctr} > 3 ]]; then
fi
} }
function show_result { function show_result {