123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- #!/bin/bash
- #
- # .---. . .
- # | | |
- # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
- # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
- # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
- #
- # Freedom in the Cloud
- #
- # Initial reading of the configuration file, typically called freedombone.cfg
- #
- # License
- # =======
- #
- # Copyright (C) 2014-2016 Bob Mottram <bob@robotics.uk.to>
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU Affero General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU Affero General Public License for more details.
- #
- # 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/>.
-
- function read_config_param {
- param_name="$1"
-
- if [ $CONFIGURATION_FILE ]; then
- if [ -f $CONFIGURATION_FILE ]; then
- if grep -q "${param_name}" $CONFIGURATION_FILE; then
- ${param_name}=$(cat $CONFIGURATION_FILE | grep "${param_name}=" | head -n 1 | awk -F '=' '{print $2}')
- fi
- fi
- fi
- }
-
- function read_configuration {
- # if not installing on a Beaglebone then use sdb as the USB drive by default
- if [ ! $INSTALLING_ON_BBB ]; then
- if [[ $USB_DRIVE == /dev/sda1 ]]; then
- USB_DRIVE=/dev/sdb1
- fi
- fi
-
- if [[ $INSTALLING_FROM_CONFIGURATION_FILE == "yes" ]]; then
- if [ ! -f $CONFIGURATION_FILE ]; then
- echo $"The configuration file $CONFIGURATION_FILE was not found"
- exit 8935
- fi
- fi
-
- if [ -f $CONFIGURATION_FILE ]; then
- read_repo_servers
-
- # Ensure that a copy of the config exists for upgrade purposes
- if [[ $CONFIGURATION_FILE != "/root/${PROJECT_NAME}.cfg" ]]; then
- cp $CONFIGURATION_FILE /root/${PROJECT_NAME}.cfg
- fi
-
- read_config_param "FRIENDS_MIRRORS_SERVER"
- read_config_param "FRIENDS_MIRRORS_SSH_PORT"
- read_config_param "FRIENDS_MIRRORS_PASSWORD"
- read_config_param "MY_MIRRORS_PASSWORD"
-
- read_config_param "SYSTEM_TYPE"
- read_config_param "SSL_PROTOCOLS"
- read_config_param "SSL_CIPHERS"
- read_config_param "SSH_CIPHERS"
- read_config_param "SSH_MACS"
- read_config_param "SSH_KEX"
- read_config_param "SSH_HOST_KEY_ALGORITHMS"
- read_config_param "SSH_PASSWORDS"
- read_config_param "REFRESH_GPG_KEYS_HOURS"
- read_config_param "GPG_KEYSERVER"
- read_config_param "ENABLE_SOCIAL_KEY_MANAGEMENT"
- read_config_param "MY_USERNAME"
- read_config_param "DOMAIN_NAME"
- read_config_param "DEFAULT_DOMAIN_NAME"
- read_config_param "DEFAULT_DOMAIN_CODE"
- read_config_param "NAMESERVER1"
- read_config_param "NAMESERVER2"
- read_config_param "GET_IP_ADDRESS_URL"
- read_config_param "DDNS_PROVIDER"
- read_config_param "DDNS_USERNAME"
- read_config_param "DDNS_PASSWORD"
- read_config_param "LOCAL_NETWORK_STATIC_IP_ADDRESS"
- read_config_param "ROUTER_IP_ADDRESS"
- read_config_param "CPU_CORES"
- read_config_param "WEBSERVER_LOG_LEVEL"
- read_config_param "ROUTE_THROUGH_TOR"
- read_config_param "MY_NAME"
- read_config_param "MY_EMAIL_ADDRESS"
- read_config_param "INSTALLING_ON_BBB"
- read_config_param "SSH_PORT"
- read_config_param "INSTALLED_WITHIN_DOCKER"
- read_config_param "GPG_ENCRYPT_STORED_EMAIL"
- read_config_param "MY_GPG_PUBLIC_KEY"
- read_config_param "MY_GPG_PRIVATE_KEY"
- read_config_param "MY_GPG_PUBLIC_KEY_ID"
- read_config_param "USB_DRIVE"
- read_config_param "MAX_PHP_MEMORY"
- read_config_param "TLS_TIME_SOURCE1"
- read_config_param "TLS_TIME_SOURCE2"
- read_config_param "ONION_ONLY"
- read_config_param "DEFAULT_LANGUAGE"
- read_config_param "MINIMAL_INSTALL"
- read_config_param "LETSENCRYPT_SERVER"
-
- read_config_param "WIFI_INTERFACE"
- read_config_param "WIFI_SSID"
- read_config_param "WIFI_TYPE"
- read_config_param "WIFI_PASSPHRASE"
- read_config_param "WIFI_HOTSPOT"
- read_config_param "WIFI_NETWORKS_FILE"
-
- read_config_param "DEFAULT_SEARCH"
- read_config_param "SEARCH_ENGINE_PASSWORD"
-
- read_config_param "PROJECT_WEBSITE"
- read_config_param "PROJECT_REPO"
-
- read_config_param "GPGIT_REPO"
- read_config_param "GPGIT_COMMIT"
-
- read_config_param "NGINX_ENSITE_REPO"
- read_config_param "NGINX_ENSITE_REPO"
- read_config_param "NGINX_ENSITE_COMMIT"
-
- read_config_param "CLEANUP_MAILDIR_COMMIT"
- read_config_param "CLEANUP_MAILDIR_REPO"
-
- read_config_param "INADYN_REPO"
- read_config_param "INADYN_COMMIT"
-
- read_config_param "DH_KEYLENGTH"
- read_config_param "WIFI_CHANNEL"
-
- read_config_param "IPV6_NETWORK"
- read_config_param "HWRNG_TYPE"
-
- read_config_param "ENABLE_BABEL"
- read_config_param "ENABLE_BATMAN"
- read_config_param "ENABLE_CJDNS"
-
- read_config_param "PUBLIC_MAILING_LIST"
-
- if grep -q "DEBIAN_REPO" $CONFIGURATION_FILE; then
- DEBIAN_REPO=$(grep "DEBIAN_REPO" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
- CHECK_MESSAGE=$"Check your internet connection, /etc/network/interfaces and /etc/resolv.conf, then delete $COMPLETION_FILE, run 'rm -fR /var/lib/apt/lists/* && apt-get update --fix-missing' and run this script again. If hash sum mismatches persist then try setting $DEBIAN_REPO to a different mirror and also change /etc/apt/sources.list."
- fi
- fi
- echo "System type: $SYSTEM_TYPE"
- }
-
- # check that domain names are sensible
- function check_domains {
- if [ ${#WIKI_DOMAIN_NAME} -gt 1 ]; then
- function_check test_domain_name
- test_domain_name "$WIKI_DOMAIN_NAME"
-
- if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
- echo $'Wiki domain name is the same as blog domain name. They must be different'
- exit 97326
- fi
- if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
- echo $'Wiki domain name is the same as microblog domain name. They must be different'
- exit 36827
- fi
- if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
- echo $'Wiki domain name is the same as hubzilla domain name. They must be different'
- exit 65848
- fi
- if [ ${#GIT_DOMAIN_NAME} -gt 1 ]; then
- if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then
- echo $'Wiki domain name is the same as Gogs domain name. They must be different'
- exit 73529
- fi
- fi
- fi
-
- if [ ${#FULLBLOG_DOMAIN_NAME} -gt 1 ]; then
- function_check test_domain_name
- test_domain_name "$FULLBLOG_DOMAIN_NAME"
-
- if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
- echo $'Blog domain name is the same as wiki domain name. They must be different'
- exit 62348
- fi
- if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
- echo $'Blog domain name is the same as microblog domain name. They must be different'
- exit 38236
- fi
- if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
- echo $'Blog domain name is the same as hubzilla domain name. They must be different'
- exit 35483
- fi
- if [ $GIT_DOMAIN_NAME ]; then
- if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then
- echo $'Blog domain name is the same as Gogs domain name. They must be different'
- exit 84695
- fi
- fi
- fi
-
- if [ ${#MICROBLOG_DOMAIN_NAME} -gt 1 ]; then
- function_check test_domain_name
- test_domain_name "$MICROBLOG_DOMAIN_NAME"
-
- if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
- echo $'Microblog domain name is the same as wiki domain name. They must be different'
- exit 73924
- fi
- if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
- echo $'Microblog domain name is the same as blog domain name. They must be different'
- exit 26832
- fi
- if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
- echo $'Microblog domain name is the same as hubzilla domain name. They must be different'
- exit 678382
- fi
- if [ $GIT_DOMAIN_NAME ]; then
- if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then
- echo $'Microblog domain name is the same as Gogs domain name. They must be different'
- exit 684325
- fi
- fi
- fi
-
- if [ $HUBZILLA_DOMAIN_NAME ]; then
- function_check test_domain_name
- test_domain_name "$HUBZILLA_DOMAIN_NAME"
-
- if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
- echo $'Hubzilla domain name is the same as wiki domain name. They must be different'
- exit 83682
- fi
- if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
- echo $'Hubzilla domain name is the same as blog domain name. They must be different'
- exit 74817
- fi
- if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
- echo $'Hubzilla domain name is the same as microblog domain name. They must be different'
- exit 83683
- fi
- if [ ${#GIT_DOMAIN_NAME} -gt 1 ]; then
- if [[ "$test_domain_name" == "$GIT_DOMAIN_NAME" ]]; then
- echo $'Hubzilla domain name is the same as Gogs domain name. They must be different'
- exit 135523
- fi
- fi
- fi
-
- if [ ${#GIT_DOMAIN_NAME} -gt 1 ]; then
- function_check test_domain_name
- test_domain_name "$GIT_DOMAIN_NAME"
-
- if [[ "$test_domain_name" == "$WIKI_DOMAIN_NAME" ]]; then
- echo $'Hubzilla domain name is the same as wiki domain name. They must be different'
- exit 83682
- fi
- if [[ "$test_domain_name" == "$FULLBLOG_DOMAIN_NAME" ]]; then
- echo $'Hubzilla domain name is the same as blog domain name. They must be different'
- exit 74817
- fi
- if [[ "$test_domain_name" == "$MICROBLOG_DOMAIN_NAME" ]]; then
- echo $'Hubzilla domain name is the same as microblog domain name. They must be different'
- exit 83683
- fi
- if [[ "$test_domain_name" == "$HUBZILLA_DOMAIN_NAME" ]]; then
- echo $'Microblog domain name is the same as hubzilla domain name. They must be different'
- exit 678382
- fi
- fi
- }
-
- # NOTE: deliberately no exit 0
|