Consolidation of configuration variables

This commit is contained in:
Bob Mottram 2016-10-09 11:45:41 +01:00
parent 3750bd9215
commit 811a39a924
2 changed files with 104 additions and 139 deletions

View File

@ -172,7 +172,7 @@ function choose_email_address {
esac
done
fi
save_configuration_file
save_configuration_values
}
function choose_default_domain_name {
@ -227,7 +227,7 @@ function choose_default_domain_name {
fi
done
fi
save_configuration_file
save_configuration_values
}
function choose_static_ip {
@ -271,7 +271,7 @@ function choose_static_ip {
esac
LOCAL_NETWORK_STATIC_IP_ADDRESS=$(cat $data | sed -n 1p)
ROUTER_IP_ADDRESS=$(cat $data | sed -n 2p)
save_configuration_file
save_configuration_values
fi
fi
}
@ -319,7 +319,7 @@ function choose_dynamic_dns {
14) DDNS_PROVIDER="default@changeip.com";;
255) exit 1;;
esac
save_configuration_file
save_configuration_values
valid_ddns_username=
while [ ! $valid_ddns_username ]
@ -343,7 +343,7 @@ function choose_dynamic_dns {
255) exit 1;;
esac
done
save_configuration_file
save_configuration_values
valid_ddns_password=
while [ ! $valid_ddns_password ]
@ -373,7 +373,7 @@ function choose_dynamic_dns {
DDNS_PASSWORD=""
fi
done
save_configuration_file
save_configuration_values
fi
}
@ -455,7 +455,7 @@ function choose_dns {
;;
255) exit 1;;
esac
save_configuration_file
save_configuration_values
else
# as defaults for a minimal install process these settings are debatable
NAMESERVER1='85.214.73.63'
@ -575,7 +575,7 @@ function choose_debian_repo {
49) DEBIAN_REPO='ftp.us.debian.org';;
255) exit 1;;
esac
save_configuration_file
save_configuration_values
else
DEBIAN_REPO='ftp.de.debian.org'
fi
@ -605,7 +605,7 @@ function choose_rng {
else
HWRNG_TYPE="beaglebone"
fi
save_configuration_file
save_configuration_values
fi
}
@ -631,7 +631,7 @@ function choose_social_key_management {
0) ENABLE_SOCIAL_KEY_MANAGEMENT="yes";;
255) exit 1;;
esac
save_configuration_file
save_configuration_values
else
# enable for the minimal case
ENABLE_SOCIAL_KEY_MANAGEMENT="yes"
@ -659,7 +659,7 @@ function choose_beaglebone_options {
if [[ $INSTALLING_ON_BBB == "yes" ]]; then
USB_DRIVE=/dev/sda1
fi
save_configuration_file
save_configuration_values
fi
}
@ -742,7 +742,7 @@ function choose_username {
echo $"The directory /home/$MY_USERNAME does not exist"
exit 6437
fi
save_configuration_file
save_configuration_values
}
function choose_full_name {
@ -768,7 +768,7 @@ function choose_full_name {
255) exit 1;;
esac
done
save_configuration_file
save_configuration_values
}
function choose_system_variant {
@ -795,7 +795,7 @@ function choose_system_variant {
27 40 20 $varslist)
variant_choice=$((variant_choice - 1))
export SYSTEM_TYPE=${variants_list[$variant_choice]}
save_configuration_file
save_configuration_values
write_config_param "SYSTEM_TYPE" "$SYSTEM_TYPE"
}
@ -854,53 +854,6 @@ do
shift
done
function save_configuration_file {
if [ ! $CONFIGURATION_FILE ]; then
CONFIGURATION_FILE='freedombone.cfg'
fi
save_variables=(MY_USERNAME
DEFAULT_DOMAIN_NAME
DEFAULT_DOMAIN_CODE
SYSTEM_TYPE
INSTALLING_ON_BBB
USB_DRIVE
DDNS_PROVIDER
DDNS_USERNAME
DDNS_PASSWORD
DEFAULT_LANGUAGE
MY_NAME
MY_EMAIL_ADDRESS
LOCAL_NETWORK_STATIC_IP_ADDRESS
ROUTER_IP_ADDRESS
ENABLE_CJDNS
ENABLE_BATMAN
ENABLE_BABEL
DEBIAN_REPO
NAMESERVER1
NAMESERVER2
HWRNG_TYPE
ENABLE_SOCIAL_KEY_MANAGEMENT
WIFI_SSID
WIFI_INTERFACE
WIFI_TYPE
WIFI_PASSPHRASE
WIFI_HOTSPOT
BATMAN_CELLID
WIFI_CHANNEL
DH_KEYLENGTH
ONION_ONLY
FRIENDS_MIRRORS_SERVER
FRIENDS_MIRRORS_SSH_PORT
FRIENDS_MIRRORS_PASSWORD
MY_MIRRORS_PASSWORD)
for v in "${save_variables[@]}"
do
write_config_param "$v" "${!v}"
done
}
# test a domain name to see if it's valid
function validate_domain_name {
# count the number of dots in the domain name
@ -1169,7 +1122,7 @@ function set_main_repo {
dialog --title $"Main Repository" \
--msgbox $"Main repository set to $FRIENDS_MIRRORS_SERVER" 6 60
fi
save_configuration_file
save_configuration_values
}
function interactive_select_language {
@ -1320,7 +1273,7 @@ function interactive_select_language {
67) DEFAULT_LANGUAGE='uk_UA.UTF-8';;
68) DEFAULT_LANGUAGE='vi_VN.UTF-8';;
esac
save_configuration_file
save_configuration_values
update-locale LANG=${DEFAULT_LANGUAGE}
update-locale LANGUAGE=${DEFAULT_LANGUAGE}
@ -1415,4 +1368,5 @@ fi
read_configuration_values
interactive_config
show_result
exit 0

View File

@ -28,6 +28,81 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
configuration_variables=(FRIENDS_MIRRORS_SERVER
FRIENDS_MIRRORS_SSH_PORT
FRIENDS_MIRRORS_PASSWORD
MY_MIRRORS_PASSWORD
SYSTEM_TYPE
SSL_PROTOCOLS
SSL_CIPHERS
SSH_CIPHERS
SSH_MACS
SSH_KEX
SSH_HOST_KEY_ALGORITHMS
SSH_PASSWORDS
REFRESH_GPG_KEYS_HOURS
GPG_KEYSERVER
ENABLE_SOCIAL_KEY_MANAGEMENT
MY_USERNAME
DOMAIN_NAME
DEFAULT_DOMAIN_NAME
DEFAULT_DOMAIN_CODE
NAMESERVER1
NAMESERVER2
GET_IP_ADDRESS_URL
DDNS_PROVIDER
DDNS_USERNAME
DDNS_PASSWORD
LOCAL_NETWORK_STATIC_IP_ADDRESS
ROUTER_IP_ADDRESS
CPU_CORES
WEBSERVER_LOG_LEVEL
ROUTE_THROUGH_TOR
MY_NAME
MY_EMAIL_ADDRESS
INSTALLING_ON_BBB
SSH_PORT
INSTALLED_WITHIN_DOCKER
GPG_ENCRYPT_STORED_EMAIL
MY_GPG_PUBLIC_KEY
MY_GPG_PRIVATE_KEY
MY_GPG_PUBLIC_KEY_ID
USB_DRIVE
MAX_PHP_MEMORY
TLS_TIME_SOURCE1
TLS_TIME_SOURCE2
ONION_ONLY
DEFAULT_LANGUAGE
MINIMAL_INSTALL
LETSENCRYPT_SERVER
WIFI_INTERFACE
WIFI_SSID
WIFI_TYPE
WIFI_PASSPHRASE
WIFI_HOTSPOT
WIFI_NETWORKS_FILE
DEFAULT_SEARCH
SEARCH_ENGINE_PASSWORD
PROJECT_WEBSITE
PROJECT_REPO
GPGIT_REPO
GPGIT_COMMIT
NGINX_ENSITE_REPO
NGINX_ENSITE_REPO
NGINX_ENSITE_COMMIT
CLEANUP_MAILDIR_COMMIT
CLEANUP_MAILDIR_REPO
INADYN_REPO
INADYN_COMMIT
DH_KEYLENGTH
WIFI_CHANNEL
IPV6_NETWORK
HWRNG_TYPE
ENABLE_BABEL
ENABLE_BATMAN
ENABLE_CJDNS
PUBLIC_MAILING_LIST)
function read_config_param {
param_name="$1"
@ -63,6 +138,17 @@ function write_config_param {
fi
}
function save_configuration_values {
if [ ! $CONFIGURATION_FILE ]; then
CONFIGURATION_FILE='freedombone.cfg'
fi
for v in "${configuration_variables[@]}"
do
write_config_param "$v" "${!v}"
done
}
function read_configuration_values {
# if not installing on a Beaglebone then use sdb as the USB drive by default
if [ ! $INSTALLING_ON_BBB ]; then
@ -79,82 +165,7 @@ function read_configuration_values {
cp $CONFIGURATION_FILE /root/${PROJECT_NAME}.cfg
fi
read_config_variables=(FRIENDS_MIRRORS_SERVER
FRIENDS_MIRRORS_SSH_PORT
FRIENDS_MIRRORS_PASSWORD
MY_MIRRORS_PASSWORD
SYSTEM_TYPE
SSL_PROTOCOLS
SSL_CIPHERS
SSH_CIPHERS
SSH_MACS
SSH_KEX
SSH_HOST_KEY_ALGORITHMS
SSH_PASSWORDS
REFRESH_GPG_KEYS_HOURS
GPG_KEYSERVER
ENABLE_SOCIAL_KEY_MANAGEMENT
MY_USERNAME
DOMAIN_NAME
DEFAULT_DOMAIN_NAME
DEFAULT_DOMAIN_CODE
NAMESERVER1
NAMESERVER2
GET_IP_ADDRESS_URL
DDNS_PROVIDER
DDNS_USERNAME
DDNS_PASSWORD
LOCAL_NETWORK_STATIC_IP_ADDRESS
ROUTER_IP_ADDRESS
CPU_CORES
WEBSERVER_LOG_LEVEL
ROUTE_THROUGH_TOR
MY_NAME
MY_EMAIL_ADDRESS
INSTALLING_ON_BBB
SSH_PORT
INSTALLED_WITHIN_DOCKER
GPG_ENCRYPT_STORED_EMAIL
MY_GPG_PUBLIC_KEY
MY_GPG_PRIVATE_KEY
MY_GPG_PUBLIC_KEY_ID
USB_DRIVE
MAX_PHP_MEMORY
TLS_TIME_SOURCE1
TLS_TIME_SOURCE2
ONION_ONLY
DEFAULT_LANGUAGE
MINIMAL_INSTALL
LETSENCRYPT_SERVER
WIFI_INTERFACE
WIFI_SSID
WIFI_TYPE
WIFI_PASSPHRASE
WIFI_HOTSPOT
WIFI_NETWORKS_FILE
DEFAULT_SEARCH
SEARCH_ENGINE_PASSWORD
PROJECT_WEBSITE
PROJECT_REPO
GPGIT_REPO
GPGIT_COMMIT
NGINX_ENSITE_REPO
NGINX_ENSITE_REPO
NGINX_ENSITE_COMMIT
CLEANUP_MAILDIR_COMMIT
CLEANUP_MAILDIR_REPO
INADYN_REPO
INADYN_COMMIT
DH_KEYLENGTH
WIFI_CHANNEL
IPV6_NETWORK
HWRNG_TYPE
ENABLE_BABEL
ENABLE_BATMAN
ENABLE_CJDNS
PUBLIC_MAILING_LIST)
for v in "${read_config_variables[@]}"
for v in "${configuration_variables[@]}"
do
read_config_param "$v"
done