2122 lines
85 KiB
Bash
Executable File
2122 lines
85 KiB
Bash
Executable File
#!/bin/bash
|
||
#
|
||
# .---. . .
|
||
# | | |
|
||
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
||
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
||
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
||
#
|
||
# Freedom in the Cloud
|
||
#
|
||
# Interactively creates a configuration file for use with the main
|
||
# freedombone command
|
||
#
|
||
# License
|
||
# =======
|
||
#
|
||
# Copyright (C) 2015-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/>.
|
||
|
||
NO_OF_ARGS=$#
|
||
|
||
PROJECT_NAME='freedombone'
|
||
|
||
# username created by default within a debian image
|
||
GENERIC_IMAGE_USERNAME='fbone'
|
||
|
||
export TEXTDOMAIN=${PROJECT_NAME}-config
|
||
export TEXTDOMAINDIR="/usr/share/locale"
|
||
|
||
# Web site
|
||
FREEDOMBONE_WEBSITE="http://freedombone.uk.to"
|
||
|
||
# Minimum number of characters in a password
|
||
MINIMUM_PASSWORD_LENGTH=10
|
||
|
||
# file containing new password
|
||
IMAGE_PASSWORD_FILE=/root/login.txt
|
||
|
||
# Different system variants which may be specified within
|
||
# the SYSTEM_TYPE option
|
||
VARIANT_FULL="full"
|
||
VARIANT_WRITER="writer"
|
||
VARIANT_CLOUD="cloud"
|
||
VARIANT_CHAT="chat"
|
||
VARIANT_MAILBOX="mailbox"
|
||
VARIANT_NONMAILBOX="nonmailbox"
|
||
VARIANT_SOCIAL="social"
|
||
VARIANT_MEDIA="media"
|
||
VARIANT_DEVELOPER="developer"
|
||
VARIANT_MESH="mesh"
|
||
VARIANT_MESH_USER="mesh-user"
|
||
|
||
MY_USERNAME=
|
||
DEFAULT_DOMAIN_NAME=
|
||
DEFAULT_DOMAIN_CODE=
|
||
MY_EMAIL_ADDRESS=
|
||
SYSTEM_TYPE=
|
||
INSTALLING_ON_BBB="no"
|
||
DDNS_PROVIDER=
|
||
DDNS_USERNAME=
|
||
DDNS_PASSWORD=
|
||
MY_NAME=
|
||
LOCAL_NETWORK_STATIC_IP_ADDRESS=
|
||
ROUTER_IP_ADDRESS=
|
||
ENABLE_CJDNS=
|
||
ENABLE_BATMAN=
|
||
ENABLE_BABEL=
|
||
DEBIAN_REPO=
|
||
NAMESERVER1=
|
||
NAMESERVER2=
|
||
WIKI_TITLE=
|
||
WIKI_DOMAIN_NAME=
|
||
WIKI_CODE=
|
||
MY_BLOG_TITLE=
|
||
FULLBLOG_DOMAIN_NAME=
|
||
FULLBLOG_CODE=
|
||
MEDIAGOBLIN_ENABLED='no'
|
||
MEDIAGOBLIN_DOMAIN_NAME=
|
||
MEDIAGOBLIN_CODE=
|
||
HUBZILLA_DOMAIN_NAME=
|
||
HUBZILLA_CODE=
|
||
MICROBLOG_DOMAIN_NAME=
|
||
MICROBLOG_CODE=
|
||
MICROBLOG_WELCOME_MESSAGE=$"<h1>Welcome to \$MICROBLOG_DOMAIN_NAME – a federated microblog</h1><p>Another $PROJECT_NAME site</p>"
|
||
MICROBLOG_BACKGROUND_IMAGE_URL=
|
||
GIT_DOMAIN_NAME=
|
||
GIT_CODE=
|
||
MEDIAGOBLIN_DOMAIN_NAME=
|
||
MEDIAGOBLIN_CODE=
|
||
USB_DRIVE=/dev/sdb1
|
||
HWRNG_TYPE=
|
||
ENABLE_SOCIAL_KEY_MANAGEMENT=
|
||
WIFI_INTERFACE=wlan0
|
||
WIFI_TYPE='wpa2-psk'
|
||
WIFI_SSID=
|
||
WIFI_PASSPHRASE=
|
||
WIFI_HOTSPOT=
|
||
WIFI_NETWORKS_FILE=~/${PROJECT_NAME}-wifi.cfg
|
||
BATMAN_CELLID='any'
|
||
WIFI_CHANNEL=
|
||
CONFIGURATION_FILE=
|
||
DH_KEYLENGTH=
|
||
MINIMAL_INSTALL="yes"
|
||
DEFAULT_LANGUAGE='en_GB.UTF-8'
|
||
ONION_ONLY="no"
|
||
SELECTED_USERNAME=
|
||
|
||
# Mirrors settings
|
||
FRIENDS_MIRRORS_SERVER=
|
||
FRIENDS_MIRRORS_SSH_PORT=2222
|
||
FRIENDS_MIRRORS_PASSWORD=
|
||
MY_MIRRORS_PASSWORD=
|
||
|
||
VALID_CODE=
|
||
|
||
function show_help {
|
||
echo ''
|
||
echo $"${PROJECT_NAME}-config -f [config filename] -m [min password length]"
|
||
echo ''
|
||
echo $'Creates an inventory of remote backup locations'
|
||
echo ''
|
||
echo ''
|
||
echo $' -h --help Show help'
|
||
echo $' -f --filename Configuration file (usually freedombone.cfg)'
|
||
echo $' -m --min Minimum password length (characters)'
|
||
echo $' -w --www Freedombone web site'
|
||
echo $' -b --bm Freedombone support Bitmessage address'
|
||
echo $' -o --onion [yes|no] Whether to only create .onion sites'
|
||
echo $' --minimal [yes|no] For minimalistic "consumer grade" installs'
|
||
echo ''
|
||
exit 0
|
||
}
|
||
|
||
function validate_freedns_code {
|
||
freedns_code="$1"
|
||
|
||
FREEDNS_MESSAGE=$"Please enter the FreeDNS code for this domain.\n\nThe code can be found by going to https://freedns.afraid.org, selecting 'Dynamic DNS' and then opening 'Wget example'. The code will consist of letters and numbers and be between the ? and = characters."
|
||
|
||
if [[ "$freedns_code" == *"."* || "$freedns_code" == "http"* || "$freedns_code" == *"wget "* || "$freedns_code" == *" "* ]]; then
|
||
dialog --title $"Invalid FreeDNS Code" --msgbox "$FREEDNS_MESSAGE" 10 70
|
||
VALID_CODE=
|
||
fi
|
||
if [ ${#freedns_code} -lt 30 ]; then
|
||
dialog --title $"Invalid FreeDNS Code" --msgbox $'FreeDNS code is too short. Did you enter the entire code?' 6 70
|
||
VALID_CODE=
|
||
fi
|
||
VALID_CODE='yes'
|
||
}
|
||
|
||
# Get the commandline options
|
||
while [[ $# > 1 ]]
|
||
do
|
||
key="$1"
|
||
|
||
case $key in
|
||
-h|--help)
|
||
show_help
|
||
;;
|
||
# Configuration filename
|
||
-f|--filename)
|
||
shift
|
||
CONFIGURATION_FILE="$1"
|
||
;;
|
||
# Minimum password length
|
||
-m|--min)
|
||
shift
|
||
MINIMUM_PASSWORD_LENGTH="$1"
|
||
;;
|
||
# Freedombone website
|
||
-w|--www)
|
||
shift
|
||
FREEDOMBONE_WEBSITE="$1"
|
||
;;
|
||
--minimal)
|
||
shift
|
||
MINIMAL_INSTALL="$1"
|
||
;;
|
||
-o|--onion)
|
||
shift
|
||
ONION_ONLY="$1"
|
||
;;
|
||
*)
|
||
# unknown option
|
||
;;
|
||
esac
|
||
shift
|
||
done
|
||
|
||
function save_configuration_file {
|
||
if [ ! $CONFIGURATION_FILE ]; then
|
||
CONFIGURATION_FILE='freedombone.cfg'
|
||
fi
|
||
|
||
echo "MY_USERNAME=$MY_USERNAME" > $CONFIGURATION_FILE
|
||
echo "DEFAULT_DOMAIN_NAME=$DEFAULT_DOMAIN_NAME" >> $CONFIGURATION_FILE
|
||
if [ $DEFAULT_DOMAIN_CODE ]; then
|
||
echo "DEFAULT_DOMAIN_CODE=$DEFAULT_DOMAIN_CODE" >> $CONFIGURATION_FILE
|
||
fi
|
||
echo "SYSTEM_TYPE=$SYSTEM_TYPE" >> $CONFIGURATION_FILE
|
||
echo "INSTALLING_ON_BBB=$INSTALLING_ON_BBB" >> $CONFIGURATION_FILE
|
||
echo "USB_DRIVE=$USB_DRIVE" >> $CONFIGURATION_FILE
|
||
echo "DDNS_PROVIDER=$DDNS_PROVIDER" >> $CONFIGURATION_FILE
|
||
echo "DDNS_USERNAME=$DDNS_USERNAME" >> $CONFIGURATION_FILE
|
||
echo "DDNS_PASSWORD=$DDNS_PASSWORD" >> $CONFIGURATION_FILE
|
||
echo "DEFAULT_LANGUAGE=$DEFAULT_LANGUAGE" >> $CONFIGURATION_FILE
|
||
if [ "$MY_NAME" ]; then
|
||
echo "MY_NAME=$MY_NAME" >> $CONFIGURATION_FILE
|
||
fi
|
||
echo "MY_EMAIL_ADDRESS=$MY_EMAIL_ADDRESS" >> $CONFIGURATION_FILE
|
||
if [ $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then
|
||
echo "LOCAL_NETWORK_STATIC_IP_ADDRESS=$LOCAL_NETWORK_STATIC_IP_ADDRESS" >> $CONFIGURATION_FILE
|
||
echo "ROUTER_IP_ADDRESS=$ROUTER_IP_ADDRESS" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $ENABLE_CJDNS ]; then
|
||
echo "ENABLE_CJDNS=$ENABLE_CJDNS" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $ENABLE_BATMAN ]; then
|
||
echo "ENABLE_BATMAN=$ENABLE_BATMAN" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $ENABLE_BABEL ]; then
|
||
echo "ENABLE_BABEL=$ENABLE_BABEL" >> $CONFIGURATION_FILE
|
||
fi
|
||
echo "DEBIAN_REPO=$DEBIAN_REPO" >> $CONFIGURATION_FILE
|
||
if [ $NAMESERVER1 ]; then
|
||
echo "NAMESERVER1=$NAMESERVER1" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $NAMESERVER2 ]; then
|
||
echo "NAMESERVER2=$NAMESERVER2" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ "$WIKI_TITLE" ]; then
|
||
echo "WIKI_TITLE=$WIKI_TITLE" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $WIKI_DOMAIN_NAME ]; then
|
||
echo "WIKI_DOMAIN_NAME=$WIKI_DOMAIN_NAME" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $WIKI_CODE ]; then
|
||
echo "WIKI_CODE=$WIKI_CODE" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ "$MY_BLOG_TITLE" ]; then
|
||
echo "MY_BLOG_TITLE=$MY_BLOG_TITLE" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $FULLBLOG_DOMAIN_NAME ]; then
|
||
echo "FULLBLOG_DOMAIN_NAME=$FULLBLOG_DOMAIN_NAME" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $FULLBLOG_CODE ]; then
|
||
echo "FULLBLOG_CODE=$FULLBLOG_CODE" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $HUBZILLA_DOMAIN_NAME ]; then
|
||
echo "HUBZILLA_DOMAIN_NAME=$HUBZILLA_DOMAIN_NAME" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $HUBZILLA_CODE ]; then
|
||
echo "HUBZILLA_CODE=$HUBZILLA_CODE" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ ${#MICROBLOG_DOMAIN_NAME} -gt 1 ]; then
|
||
echo "MICROBLOG_DOMAIN_NAME=$MICROBLOG_DOMAIN_NAME" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $MICROBLOG_CODE ]; then
|
||
echo "MICROBLOG_CODE=$MICROBLOG_CODE" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ ${#MICROBLOG_WELCOME_MESSAGE} -gt 1 ]; then
|
||
echo "MICROBLOG_WELCOME_MESSAGE=$MICROBLOG_WELCOME_MESSAGE" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $MICROBLOG_BACKGROUND_IMAGE_URL ]; then
|
||
echo "MICROBLOG_BACKGROUND_IMAGE_URL=$MICROBLOG_BACKGROUND_IMAGE_URL" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $GIT_DOMAIN_NAME ]; then
|
||
echo "GIT_DOMAIN_NAME=$GIT_DOMAIN_NAME" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $GIT_CODE ]; then
|
||
echo "GIT_CODE=$GIT_CODE" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $MEDIAGOBLIN_DOMAIN_NAME ]; then
|
||
echo "MEDIAGOBLIN_DOMAIN_NAME=$MEDIAGOBLIN_DOMAIN_NAME" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $MEDIAGOBLIN_CODE ]; then
|
||
echo "MEDIAGOBLIN_CODE=$MEDIAGOBLIN_CODE" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $HWRNG_TYPE ]; then
|
||
echo "HWRNG_TYPE=$HWRNG_TYPE" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $ENABLE_SOCIAL_KEY_MANAGEMENT ]; then
|
||
echo "ENABLE_SOCIAL_KEY_MANAGEMENT=$ENABLE_SOCIAL_KEY_MANAGEMENT" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $WIFI_SSID ]; then
|
||
echo "WIFI_SSID=$WIFI_SSID" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $WIFI_INTERFACE ]; then
|
||
echo "WIFI_INTERFACE=$WIFI_INTERFACE" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $WIFI_TYPE ]; then
|
||
echo "WIFI_TYPE=$WIFI_TYPE" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ ${#WIFI_PASSPHRASE} -gt 1 ]; then
|
||
echo "WIFI_PASSPHRASE=$WIFI_PASSPHRASE" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $WIFI_HOTSPOT ]; then
|
||
echo "WIFI_HOTSPOT=$WIFI_HOTSPOT" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $BATMAN_CELLID ]; then
|
||
echo "BATMAN_CELLID=$BATMAN_CELLID" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $WIFI_CHANNEL ]; then
|
||
echo "WIFI_CHANNEL=$WIFI_CHANNEL" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $DH_KEYLENGTH ]; then
|
||
echo "DH_KEYLENGTH=$DH_KEYLENGTH" >> $CONFIGURATION_FILE
|
||
fi
|
||
echo "ONION_ONLY=$ONION_ONLY" >> $CONFIGURATION_FILE
|
||
|
||
if [ $FRIENDS_MIRRORS_SERVER ]; then
|
||
echo "FRIENDS_MIRRORS_SERVER=$FRIENDS_MIRRORS_SERVER" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $FRIENDS_MIRRORS_SSH_PORT ]; then
|
||
echo "FRIENDS_MIRRORS_SSH_PORT=$FRIENDS_MIRRORS_SSH_PORT" >> $CONFIGURATION_FILE
|
||
fi
|
||
if [ $FRIENDS_MIRRORS_PASSWORD ]; then
|
||
echo "FRIENDS_MIRRORS_PASSWORD=$FRIENDS_MIRRORS_PASSWORD" >> $CONFIGURATION_FILE
|
||
fi
|
||
}
|
||
|
||
# test a domain name to see if it's valid
|
||
function validate_domain_name {
|
||
# count the number of dots in the domain name
|
||
dots=${TEST_DOMAIN_NAME//[^.]}
|
||
no_of_dots=${#dots}
|
||
if (( no_of_dots > 3 )); then
|
||
TEST_DOMAIN_NAME="The domain $TEST_DOMAIN_NAME has too many subdomains. It should be of the type w.x.y.z, x.y.z or y.z"
|
||
fi
|
||
if (( no_of_dots == 0 )); then
|
||
TEST_DOMAIN_NAME="The domain $TEST_DOMAIN_NAME has no top level domain. It should be of the type w.x.y.z, x.y.z or y.z"
|
||
fi
|
||
}
|
||
|
||
function interactive_gpg_from_remote {
|
||
REMOTE_SERVERS_LIST=/home/$MY_USERNAME/keyshareservers.txt
|
||
|
||
# get a list of remote servers
|
||
${PROJECT_NAME}-remote -u $MY_USERNAME -l $REMOTE_SERVERS_LIST -t "Remote server"
|
||
|
||
if [ ! -f $REMOTE_SERVERS_LIST ]; then
|
||
dialog --title $"Encryption keys" --msgbox $'Error obtaining server list' 6 70
|
||
return 1
|
||
fi
|
||
|
||
# check the number of entries in the file
|
||
no_of_servers=$(cat $REMOTE_SERVERS_LIST | wc -l)
|
||
if (( no_of_servers < 3 )); then
|
||
dialog --title $"Encryption keys" \
|
||
--msgbox $'There must be at least three servers to recover the key' 6 70
|
||
return 2
|
||
fi
|
||
|
||
# try to recover the key from the servers
|
||
apt-get -y install libgfshare-bin gnupg
|
||
${PROJECT_NAME}-recoverkey -u $MY_USERNAME -l $REMOTE_SERVERS_LIST
|
||
if [ ! "$?" = "0" ]; then
|
||
dialog --title $"Encryption keys" --msgbox $'Your key could not be recovered' 6 70
|
||
return 3
|
||
fi
|
||
|
||
dialog --title $"Encryption keys" --msgbox $'Your key has been recovered' 6 70
|
||
|
||
return 0
|
||
}
|
||
|
||
function reconstruct_key {
|
||
if [ ! -d /home/$MY_USERNAME/.gnupg_fragments ]; then
|
||
return
|
||
fi
|
||
cd /home/$MY_USERNAME/.gnupg_fragments
|
||
no_of_shares=$(ls -afq keyshare.asc.* | wc -l)
|
||
if (( no_of_shares < 4 )); then
|
||
dialog --title $"Encryption keys" --msgbox $'Not enough fragments to reconstruct the key' 6 70
|
||
exit 7348
|
||
fi
|
||
apt-get -y install libgfshare-bin gnupg
|
||
gfcombine /home/$MY_USERNAME/.gnupg_fragments/keyshare*
|
||
if [ ! "$?" = "0" ]; then
|
||
dialog --title $"Encryption keys" --msgbox $'Unable to reconstruct the key' 6 70
|
||
exit 7348
|
||
fi
|
||
|
||
KEYS_FILE=/home/$MY_USERNAME/.gnupg_fragments/keyshare.asc
|
||
if [ ! -f $KEYS_FILE ]; then
|
||
dialog --title $"Encryption keys" --msgbox $'Unable to reconstruct the key' 6 70
|
||
fi
|
||
|
||
su -c "gpg --allow-secret-key-import --import $KEYS_FILE" - $MY_USERNAME
|
||
if [ ! "$?" = "0" ]; then
|
||
echo $'Unable to import gpg key'
|
||
shred -zu $KEYS_FILE
|
||
rm -rf /home/$MY_USERNAME/.tempgnupg
|
||
exit 9654
|
||
fi
|
||
shred -zu $KEYS_FILE
|
||
|
||
dialog --title $"Encryption keys" --msgbox $'Key has been reconstructed' 6 70
|
||
}
|
||
|
||
function interactive_gpg_from_usb {
|
||
dialog --title $"Encryption keys" \
|
||
--msgbox $'Plug in a USB drive containing a copy of your full key or key fragment' 6 70
|
||
|
||
HOME_DIR=/home/$MY_USERNAME
|
||
GPG_LOADING="yes"
|
||
SSH_IMPORTED="no"
|
||
GPG_CTR=0
|
||
while [[ $GPG_LOADING == "yes" ]]
|
||
do
|
||
if [[ $INSTALLING_ON_BBB == "yes" ]]; then
|
||
GPG_USB_DRIVE='/dev/sda1'
|
||
if [ ! -b $GPG_USB_DRIVE ]; then
|
||
if (( GPG_CTR > 0 )); then
|
||
reconstruct_key
|
||
return 0
|
||
fi
|
||
dialog --title $"Encryption keys" --msgbox $'No USB drive found' 6 30
|
||
exit 739836
|
||
fi
|
||
else
|
||
GPG_USB_DRIVE='/dev/sdb1'
|
||
if [ ! -b $GPG_USB_DRIVE ]; then
|
||
GPG_USB_DRIVE='/dev/sdc1'
|
||
if [ ! -b $GPG_USB_DRIVE ]; then
|
||
GPG_USB_DRIVE='/dev/sdd1'
|
||
if [ ! -b $GPG_USB_DRIVE ]; then
|
||
if (( GPG_CTR > 0 )); then
|
||
reconstruct_key
|
||
return 0
|
||
fi
|
||
dialog --title $"Encryption keys" --msgbox $'No USB drive found' 6 30
|
||
exit 27852
|
||
fi
|
||
fi
|
||
fi
|
||
fi
|
||
|
||
GPG_USB_MOUNT='/mnt/usb'
|
||
umount -f $GPG_USB_MOUNT
|
||
if [ ! -d $GPG_USB_MOUNT ]; then
|
||
mkdir -p $GPG_USB_MOUNT
|
||
fi
|
||
|
||
if [ -f /dev/mapper/encrypted_usb ]; then
|
||
rm -rf /dev/mapper/encrypted_usb
|
||
fi
|
||
cryptsetup luksClose encrypted_usb
|
||
cryptsetup luksOpen $GPG_USB_DRIVE encrypted_usb
|
||
if [ "$?" = "0" ]; then
|
||
GPG_USB_DRIVE=/dev/mapper/encrypted_usb
|
||
fi
|
||
mount $GPG_USB_DRIVE $GPG_USB_MOUNT
|
||
if [ ! "$?" = "0" ]; then
|
||
if (( GPG_CTR > 0 )); then
|
||
rm -rf $GPG_USB_MOUNT
|
||
reconstruct_key
|
||
return 0
|
||
fi
|
||
dialog --title $"Encryption keys" \
|
||
--msgbox $"There was a problem mounting the USB drive to $GPG_USB_MOUNT" 6 70
|
||
rm -rf $GPG_USB_MOUNT
|
||
exit 74393
|
||
fi
|
||
|
||
if [ ! -d $GPG_USB_MOUNT/.gnupg ]; then
|
||
if [ ! -d $GPG_USB_MOUNT/.gnupg_fragments ]; then
|
||
if (( GPG_CTR > 0 )); then
|
||
umount -f $GPG_USB_MOUNT
|
||
rm -rf $GPG_USB_MOUNT
|
||
reconstruct_key
|
||
return 0
|
||
fi
|
||
dialog --title $"Encryption keys" \
|
||
--msgbox $"The directory $GPG_USB_MOUNT/.gnupg or $GPG_USB_MOUNT/.gnupg_fragments was not found" 6 70
|
||
umount -f $GPG_USB_MOUNT
|
||
rm -rf $GPG_USB_MOUNT
|
||
exit 723814
|
||
fi
|
||
fi
|
||
|
||
if [ -d $GPG_USB_MOUNT/.gnupg ]; then
|
||
if [ ! -d $HOME_DIR/.gnupg ]; then
|
||
mkdir $HOME_DIR/.gnupg
|
||
fi
|
||
cp -r $GPG_USB_MOUNT/.gnupg/* $HOME_DIR/.gnupg
|
||
GPG_LOADING="no"
|
||
dialog --title $"Encryption keys" \
|
||
--msgbox $"GPG Keyring loaded to $HOME_DIR" 6 70
|
||
else
|
||
if [ ! -d $HOME_DIR/.gnupg_fragments ]; then
|
||
mkdir $HOME_DIR/.gnupg_fragments
|
||
fi
|
||
cp -r $GPG_USB_MOUNT/.gnupg_fragments/* $HOME_DIR/.gnupg_fragments
|
||
fi
|
||
|
||
if [[ $SSH_IMPORTED == "no" ]]; then
|
||
if [ -d $GPG_USB_MOUNT/.ssh ]; then
|
||
if [ ! -d $HOME_DIR/.ssh ]; then
|
||
mkdir $HOME_DIR/.ssh
|
||
fi
|
||
cp $GPG_USB_MOUNT/.ssh/* $HOME_DIR/.ssh
|
||
dialog --title $"Encryption keys" \
|
||
--msgbox $"ssh keys imported" 6 70
|
||
SSH_IMPORTED="yes"
|
||
fi
|
||
fi
|
||
|
||
umount -f $GPG_USB_MOUNT
|
||
rm -rf $GPG_USB_MOUNT
|
||
if [[ $GPG_LOADING == "yes" ]]; then
|
||
dialog --title $"Encryption keys" \
|
||
--msgbox $"Now remove the USB drive. Insert the next drive containing a key fragment, or select Ok to finish" 6 70
|
||
fi
|
||
GPG_CTR=$((GPG_CTR + 1))
|
||
done
|
||
}
|
||
|
||
function interactive_gpg {
|
||
GPG_CONFIGURED="no"
|
||
while [[ $GPG_CONFIGURED != "yes" ]]
|
||
do
|
||
GPG_CONFIGURED="yes"
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--radiolist $"GPG/PGP keys for your system:" 13 70 3 \
|
||
1 $"Generate new keys (new user)" on \
|
||
2 $"Import keys from USB drive/s" off \
|
||
3 $"Retrieve keys from friends servers" off 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
1) exit 1;;
|
||
255) exit 2;;
|
||
esac
|
||
case $(cat $data) in
|
||
1) if [ -d /home/$MY_USERNAME/.gnupg ]; then
|
||
rm -rf /home/$MY_USERNAME/.gnupg
|
||
fi
|
||
break;;
|
||
2) interactive_gpg_from_usb
|
||
break;;
|
||
3) interactive_gpg_from_remote
|
||
if [ ! "$?" = "0" ]; then
|
||
GPG_CONFIGURED="no"
|
||
fi;;
|
||
esac
|
||
done
|
||
}
|
||
|
||
function set_main_repo {
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Control Panel" \
|
||
--title $"Main Repository (Mirrors)" \
|
||
--form $"If you don't know what this means then just select Ok.\n\nIf you don't wish to use the default repositories they can be obtained from mirrored repos on another ${PROJECT_NAME} system.\n\nThe repositories are for applications which are not yet packaged for Debian." 18 65 4 \
|
||
$"URL:" 1 1 "$FRIENDS_MIRRORS_SERVER" 1 18 40 18 \
|
||
$"SSH Port:" 2 1 "$FRIENDS_MIRRORS_SSH_PORT" 2 18 10 10000 \
|
||
$"Password:" 3 1 "$FRIENDS_MIRRORS_PASSWORD" 3 18 40 10000 \
|
||
2> $data
|
||
sel=$?
|
||
case $sel in
|
||
1) return;;
|
||
255) return;;
|
||
esac
|
||
new_mirrors_url=$(cat $data | sed -n 1p)
|
||
new_mirrors_ssh_port=$(cat $data | sed -n 2p)
|
||
new_mirrors_password=$(cat $data | sed -n 3p)
|
||
|
||
if [ ${#new_mirrors_url} -lt 2 ]; then
|
||
return
|
||
fi
|
||
if [ ${#new_mirrors_ssh_port} -lt 1 ]; then
|
||
return
|
||
fi
|
||
if [ ${#new_mirrors_password} -lt 10 ]; then
|
||
dialog --title $"Main Repository" \
|
||
--msgbox $'Mirrors password was too short. Should be at least 10 characters.' 6 40
|
||
return
|
||
fi
|
||
|
||
if [[ $new_mirrors_url == *"."* ]]; then
|
||
FRIENDS_MIRRORS_SERVER=$new_mirrors_url
|
||
FRIENDS_MIRRORS_SSH_PORT=$new_mirrors_ssh_port
|
||
FRIENDS_MIRRORS_PASSWORD=$new_mirrors_password
|
||
|
||
dialog --title $"Main Repository" \
|
||
--msgbox $"Main repository set to $FRIENDS_MIRRORS_SERVER" 6 60
|
||
fi
|
||
}
|
||
|
||
function interactive_select_language {
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--radiolist $"Select your language:" 26 40 24 \
|
||
1 $"Afrikaans" off \
|
||
2 $"Albanian" off \
|
||
3 $"Arabic" off \
|
||
4 $"Basque" off \
|
||
5 $"Belarusian" off \
|
||
6 $"Bosnian" off \
|
||
7 $"Bulgarian" off \
|
||
8 $"Catalan" off \
|
||
9 $"Croatian" off \
|
||
10 $"Chinese (Simplified)" off \
|
||
11 $"Chinese (Traditional)" off \
|
||
12 $"Czech" off \
|
||
13 $"Danish" off \
|
||
14 $"Dutch" off \
|
||
15 $"English" on \
|
||
16 $"English (US)" off \
|
||
17 $"Estonian" off \
|
||
18 $"Farsi" off \
|
||
19 $"Filipino" off \
|
||
20 $"Finnish" off \
|
||
21 $"French" off \
|
||
22 $"French (Canada)" off \
|
||
23 $"Gaelic" off \
|
||
24 $"Gallego" off \
|
||
25 $"Georgian" off \
|
||
26 $"German" off \
|
||
27 $"German (Personal)" off \
|
||
28 $"Greek" off \
|
||
29 $"Gujarati" off \
|
||
30 $"Hebrew" off \
|
||
31 $"Hindi" off \
|
||
32 $"Hungarian" off \
|
||
33 $"Icelandic" off \
|
||
34 $"Indonesian" off \
|
||
35 $"Italian" off \
|
||
36 $"Japanese" off \
|
||
37 $"Kannada" off \
|
||
38 $"Khmer" off \
|
||
39 $"Korean" off \
|
||
40 $"Lao" off \
|
||
41 $"Lithuanian" off \
|
||
42 $"Latvian" off \
|
||
43 $"Malayalam" off \
|
||
44 $"Malaysian" off \
|
||
45 $"Maori (Ngai Tahu)" off \
|
||
46 $"Maori (Waikoto Uni)" off \
|
||
47 $"Mongolian" off \
|
||
48 $"Norwegian" off \
|
||
49 $"Norwegian (Primary)" off \
|
||
50 $"Nynorsk" off \
|
||
51 $"Polish" off \
|
||
52 $"Portuguese" off \
|
||
53 $"Portuguese (Brazil)" off \
|
||
54 $"Romanian" off \
|
||
55 $"Russian" off \
|
||
56 $"Samoan" off \
|
||
57 $"Serbian" off \
|
||
58 $"Slovak" off \
|
||
59 $"Slovenian" off \
|
||
60 $"Somali" off \
|
||
61 $"Spanish (International)" off \
|
||
62 $"Swedish" off \
|
||
63 $"Tagalog" off \
|
||
64 $"Tamil" off \
|
||
65 $"Thai" off \
|
||
66 $"Turkish" off \
|
||
67 $"Ukrainian" off \
|
||
68 $"Vietnamese" off 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
case $(cat $data) in
|
||
1) DEFAULT_LANGUAGE='af_ZA.UTF-8';;
|
||
2) DEFAULT_LANGUAGE='sq_AL.UTF-8';;
|
||
3) DEFAULT_LANGUAGE='ar_SA.UTF-8';;
|
||
4) DEFAULT_LANGUAGE='eu_ES.UTF-8';;
|
||
5) DEFAULT_LANGUAGE='be_BY.UTF-8';;
|
||
6) DEFAULT_LANGUAGE='bs_BA.UTF-8';;
|
||
7) DEFAULT_LANGUAGE='bg_BG.UTF-8';;
|
||
8) DEFAULT_LANGUAGE='ca_ES.UTF-8';;
|
||
9) DEFAULT_LANGUAGE='hr_HR.UTF-8';;
|
||
10) DEFAULT_LANGUAGE='zh_CN.UTF-8';;
|
||
11) DEFAULT_LANGUAGE='zh_TW.UTF-8';;
|
||
12) DEFAULT_LANGUAGE='cs_CZ.UTF-8';;
|
||
13) DEFAULT_LANGUAGE='da_DK.UTF-8';;
|
||
14) DEFAULT_LANGUAGE='nl_NL.UTF-8';;
|
||
15) DEFAULT_LANGUAGE='en.UTF-8';;
|
||
16) DEFAULT_LANGUAGE='en_us.UTF-8';;
|
||
17) DEFAULT_LANGUAGE='et_EE.UTF-8';;
|
||
18) DEFAULT_LANGUAGE='fa_IR.UTF-8';;
|
||
19) DEFAULT_LANGUAGE='ph_PH.UTF-8';;
|
||
20) DEFAULT_LANGUAGE='fi_FI.UTF-8';;
|
||
21) DEFAULT_LANGUAGE='fr_FR.UTF-8';;
|
||
22) DEFAULT_LANGUAGE='fr_CA.UTF-8';;
|
||
23) DEFAULT_LANGUAGE='ga.UTF-8';;
|
||
24) DEFAULT_LANGUAGE='l_ES.UTF-8';;
|
||
25) DEFAULT_LANGUAGE='ka_GE.UTF-8';;
|
||
26) DEFAULT_LANGUAGE='de_DE.UTF-8';;
|
||
27) DEFAULT_LANGUAGE='de_DE.UTF-8';;
|
||
28) DEFAULT_LANGUAGE='el_GR.UTF-8';;
|
||
29) DEFAULT_LANGUAGE='gu.UTF-8';;
|
||
30) DEFAULT_LANGUAGE='he_IL.utf8';;
|
||
31) DEFAULT_LANGUAGE='hi_IN.UTF-8';;
|
||
32) DEFAULT_LANGUAGE='hu.UTF-8';;
|
||
33) DEFAULT_LANGUAGE='is_IS.UTF-8';;
|
||
34) DEFAULT_LANGUAGE='id_ID.UTF-8';;
|
||
35) DEFAULT_LANGUAGE='it_IT.UTF-8';;
|
||
36) DEFAULT_LANGUAGE='ja_JP.UTF-8';;
|
||
37) DEFAULT_LANGUAGE='kn_IN.UTF-8';;
|
||
38) DEFAULT_LANGUAGE='km_KH.UTF-8';;
|
||
39) DEFAULT_LANGUAGE='ko_KR.UTF-8';;
|
||
40) DEFAULT_LANGUAGE='lo_LA.UTF-8';;
|
||
41) DEFAULT_LANGUAGE='lt_LT.UTF-8';;
|
||
42) DEFAULT_LANGUAGE='lat.UTF-8';;
|
||
43) DEFAULT_LANGUAGE='ml_IN.UTF-8';;
|
||
44) DEFAULT_LANGUAGE='ms_MY.UTF-8';;
|
||
45) DEFAULT_LANGUAGE='mi_NZ.UTF-8';;
|
||
46) DEFAULT_LANGUAGE='mi_NZ.UTF-8';;
|
||
47) DEFAULT_LANGUAGE='mn.UTF-8';;
|
||
48) DEFAULT_LANGUAGE='no_NO.UTF-8';;
|
||
49) DEFAULT_LANGUAGE='no_NO.UTF-8';;
|
||
50) DEFAULT_LANGUAGE='nn_NO.UTF-8';;
|
||
51) DEFAULT_LANGUAGE='pl.UTF-8';;
|
||
52) DEFAULT_LANGUAGE='pt_PT.UTF-8';;
|
||
53) DEFAULT_LANGUAGE='pt_BR.UTF-8';;
|
||
54) DEFAULT_LANGUAGE='ro_RO.UTF-8';;
|
||
55) DEFAULT_LANGUAGE='ru_RU.UTF-8';;
|
||
56) DEFAULT_LANGUAGE='mi_NZ.UTF-8';;
|
||
57) DEFAULT_LANGUAGE='sr_CS.UTF-8';;
|
||
58) DEFAULT_LANGUAGE='sk_SK.UTF-8';;
|
||
59) DEFAULT_LANGUAGE='sl_SI.UTF-8';;
|
||
60) DEFAULT_LANGUAGE='so_SO.UTF-8';;
|
||
61) DEFAULT_LANGUAGE='es_ES.UTF-8';;
|
||
62) DEFAULT_LANGUAGE='sv_SE.UTF-8';;
|
||
63) DEFAULT_LANGUAGE='tl.UTF-8';;
|
||
64) DEFAULT_LANGUAGE='ta_IN.UTF-8';;
|
||
65) DEFAULT_LANGUAGE='th_TH.UTF-8';;
|
||
66) DEFAULT_LANGUAGE='tr_TR.UTF-8';;
|
||
67) DEFAULT_LANGUAGE='uk_UA.UTF-8';;
|
||
68) DEFAULT_LANGUAGE='vi_VN.UTF-8';;
|
||
esac
|
||
save_configuration_file
|
||
|
||
update-locale LANG=${DEFAULT_LANGUAGE}
|
||
update-locale LANGUAGE=${DEFAULT_LANGUAGE}
|
||
update-locale LC_MESSAGES=${DEFAULT_LANGUAGE}
|
||
update-locale LC_ALL=${DEFAULT_LANGUAGE}
|
||
update-locale LC_CTYPE=${DEFAULT_LANGUAGE}
|
||
}
|
||
|
||
function select_user {
|
||
SELECTED_USERNAME=
|
||
|
||
users_array=($(ls /home))
|
||
|
||
delete=(mirrors git)
|
||
for del in ${delete[@]}
|
||
do
|
||
users_array=(${users_array[@]/$del})
|
||
done
|
||
|
||
i=0
|
||
W=()
|
||
name=()
|
||
for u in ${users_array[@]}
|
||
do
|
||
i=$((i+1))
|
||
W+=($i "$u")
|
||
name+=("$u")
|
||
done
|
||
|
||
user_index=$(dialog --backtitle $"Freedombone Configuration" --title $"Select User" --menu $"Select one of the following:" 24 40 17 "${W[@]}" 3>&2 2>&1 1>&3)
|
||
|
||
if [ $? -eq 0 ]; then
|
||
SELECTED_USERNAME="${name[$((user_index-1))]}"
|
||
fi
|
||
}
|
||
|
||
function interactive_configuration {
|
||
# create a temporary copy of the configuration file
|
||
# which can be used to pre-populate selections
|
||
if [ -f $CONFIGURATION_FILE ]; then
|
||
cp $CONFIGURATION_FILE temp.cfg
|
||
fi
|
||
|
||
interactive_select_language
|
||
|
||
if [[ $ONION_ONLY == "no" ]]; then
|
||
INITIAL_MESSAGE=$"Welcome to the Freedombone interactive installer. Communications freedom is only a short time away.\n\nEnsure that you have your domain and dynamic DNS settings ready.\n\nFor more information please visit $FREEDOMBONE_WEBSITE."
|
||
else
|
||
INITIAL_MESSAGE=$"Welcome to the Freedombone interactive installer. Communications freedom is only a short time away.\n\nWeb sites created will only be viewable within a Tor browser.\n\nFor more information please visit $FREEDOMBONE_WEBSITE."
|
||
fi
|
||
|
||
dialog --title $"Freedombone" --msgbox "$INITIAL_MESSAGE" 15 50
|
||
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--radiolist $"Type of Installation:" 18 40 11 \
|
||
1 $"Full" on \
|
||
2 $"Writer" off \
|
||
3 $"Cloud" off \
|
||
4 $"Chat" off \
|
||
5 $"Mailbox" off \
|
||
6 $"Non-Mailbox" off \
|
||
7 $"Social" off \
|
||
8 $"Media" off \
|
||
9 $"Developer" off \
|
||
10 $"Mesh (router)" off \
|
||
11 $"Mesh (user device)" off 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
case $(cat $data) in
|
||
1) SYSTEM_TYPE=$VARIANT_FULL;;
|
||
2) SYSTEM_TYPE=$VARIANT_WRITER;;
|
||
3) SYSTEM_TYPE=$VARIANT_CLOUD;;
|
||
4) SYSTEM_TYPE=$VARIANT_CHAT;;
|
||
5) SYSTEM_TYPE=$VARIANT_MAILBOX;;
|
||
6) SYSTEM_TYPE=$VARIANT_NONMAILBOX;;
|
||
7) SYSTEM_TYPE=$VARIANT_SOCIAL;;
|
||
8) SYSTEM_TYPE=$VARIANT_MEDIA;;
|
||
9) SYSTEM_TYPE=$VARIANT_DEVELOPER;;
|
||
10) SYSTEM_TYPE=$VARIANT_MESH;;
|
||
11) SYSTEM_TYPE=$VARIANT_MESH_USER;;
|
||
esac
|
||
save_configuration_file
|
||
|
||
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" && $SYSTEM_TYPE != "$VARIANT_MESH_USER" ]]; then
|
||
set_main_repo
|
||
save_configuration_file
|
||
fi
|
||
|
||
if [[ $SYSTEM_TYPE == "$VARIANT_MESH" || $SYSTEM_TYPE == "$VARIANT_MESH_USER" ]]; then
|
||
ENABLE_BATMAN="yes"
|
||
ENABLE_CJDNS="no"
|
||
ENABLE_BABEL="no"
|
||
if [ ! $WIFI_SSID ]; then
|
||
WIFI_SSID='mesh'
|
||
fi
|
||
|
||
#data=$(tempfile 2>/dev/null)
|
||
#trap "rm -f $data" 0 1 2 5 15
|
||
#dialog --backtitle "Freedombone Configuration" \
|
||
# --radiolist "Select your type of mesh network:" 10 40 3 \
|
||
# 1 "Babel" off \
|
||
# 2 "B.A.T.M.A.N. Advanced" on \
|
||
# 3 "cjdns" off 2> $data
|
||
#sel=$?
|
||
#case $sel in
|
||
# 1) exit 1;;
|
||
# 255) exit 1;;
|
||
#esac
|
||
#case $(cat $data) in
|
||
# 1) ENABLE_BABEL="yes";;
|
||
# 2) ENABLE_BATMAN="yes";;
|
||
# 3) ENABLE_CJDNS="yes";;
|
||
#esac
|
||
save_configuration_file
|
||
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--inputbox $"Wireless Mesh ESSID\n\nIf you press enter the default will be '$WIFI_SSID'" 10 40 "$(grep 'WIFI_SSID' temp.cfg | awk -F '=' '{print $2}')" 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
0) WIFI_SSID=$(cat $data);;
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
save_configuration_file
|
||
|
||
if [[ $SYSTEM_TYPE != "$VARIANT_MESH_USER" ]]; then
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--inputbox $"Give your mesh peer a name" 10 40 "$(grep 'DEFAULT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
0) DEFAULT_DOMAIN_NAME=$(cat $data);;
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
else
|
||
DEFAULT_DOMAIN_NAME=$(hostname)
|
||
fi
|
||
save_configuration_file
|
||
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--radiolist $"Wifi Channel (spaced to be non-overlapping):" 11 50 4 \
|
||
1 "1" on \
|
||
2 "5" off \
|
||
3 "9" off \
|
||
4 "13" off 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
case $(cat $data) in
|
||
1) WIFI_CHANNEL=1;;
|
||
2) WIFI_CHANNEL=5;;
|
||
3) WIFI_CHANNEL=9;;
|
||
4) WIFI_CHANNEL=13;;
|
||
esac
|
||
save_configuration_file
|
||
fi
|
||
|
||
#if [[ $ENABLE_BATMAN == "yes" ]]; then
|
||
# data=$(tempfile 2>/dev/null)
|
||
# trap "rm -f $data" 0 1 2 5 15
|
||
# dialog --backtitle "Freedombone Configuration" \
|
||
# --inputbox "Optionally register with an Access Point" 10 40 "$(grep 'BATMAN_CELLID' temp.cfg | awk -F '=' '{print $2}')" 2> $data
|
||
# sel=$?
|
||
# case $sel in
|
||
# 0) BATMAN_CELLID=$(cat $data);;
|
||
# 1) exit 1;;
|
||
# 255) exit 1;;
|
||
# esac
|
||
# save_configuration_file
|
||
#fi
|
||
|
||
if [[ $SYSTEM_TYPE == "$VARIANT_MESH_USER" ]]; then
|
||
${PROJECT_NAME}-client --essid $WIFI_SSID --channel $WIFI_CHANNEL
|
||
if [ "$?" = "0" ]; then
|
||
clear
|
||
echo ".---. . . "
|
||
echo "| | | "
|
||
echo "|--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-. "
|
||
echo "| | (.-' (.-' ( | ( )| | | | )( )| | (.-' "
|
||
echo "' ' --' --' -' - -' ' ' -' -' -' ' - --'"
|
||
echo ''
|
||
echo $'Your system is now ready for connection to the mesh network'
|
||
echo ''
|
||
echo $'To connect to the network open a terminal and type:'
|
||
echo ''
|
||
echo ' meshweb'
|
||
echo ''
|
||
echo $'To disconnect from the mesh and return to the internet type:'
|
||
echo ''
|
||
echo ' sudo batman stop'
|
||
echo ''
|
||
echo $'To turn your system into a dedicated mesh peer you could add'
|
||
echo $'the meshweb command to your startup applications'
|
||
echo ''
|
||
touch /tmp/meshuserdevice
|
||
exit 0
|
||
else
|
||
echo $'Failed to fully install the mesh networking system'
|
||
exit 74589
|
||
fi
|
||
fi
|
||
|
||
if [ -d /home/$GENERIC_IMAGE_USERNAME ]; then
|
||
if [ ! -f $IMAGE_PASSWORD_FILE ]; then
|
||
echo 'Cannot find the password file for the admin user'
|
||
exit 62753
|
||
fi
|
||
# when installing from an image which comes with a known default user account
|
||
SELECTED_USERNAME=
|
||
while [ ! $SELECTED_USERNAME ]
|
||
do
|
||
if [ ! $SELECTED_USERNAME ]; then
|
||
SELECTED_USERNAME=$(grep 'MY_USERNAME' temp.cfg | awk -F '=' '{print $2}')
|
||
fi
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--title $"Username" \
|
||
--inputbox $"Set your username for the system\n\nYour username should not contain any spaces" 12 60 "$SELECTED_USERNAME" 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
0) possible_username=$(cat $data)
|
||
SELECTED_USERNAME=
|
||
if [[ $possible_username != *' '* && $possible_username != *'/'* && $possible_username != *'\'* && $possible_username != *'*'* ]]; then
|
||
if [ $possible_username ]; then
|
||
if [ ${#possible_username} -gt 1 ]; then
|
||
if [[ $possible_username != $GENERIC_IMAGE_USERNAME ]]; then
|
||
MY_USERNAME=$(cat $data)
|
||
useradd -m -s /bin/bash $MY_USERNAME
|
||
if [ -d /home/$MY_USERNAME ]; then
|
||
echo "${MY_USERNAME}:$(printf `cat $IMAGE_PASSWORD_FILE`)" | chpasswd
|
||
# Add the user as a sudoer - they will be the new admin user
|
||
if ! grep -q "$MY_USERNAME ALL=(ALL) ALL" /etc/sudoers; then
|
||
echo "$MY_USERNAME ALL=(ALL) ALL" >> /etc/sudoers
|
||
# remove the generic image admin user from sudoers
|
||
sed -i "s|${GENERIC_IMAGE_USERNAME}.*||g" /etc/sudoers
|
||
fi
|
||
break
|
||
fi
|
||
fi
|
||
fi
|
||
fi
|
||
fi
|
||
;;
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
done
|
||
else
|
||
no_of_users=$(find /home/* -maxdepth 0 -type d | wc -l)
|
||
if [ $no_of_users -eq 1 ]; then
|
||
# only a single user on the system
|
||
MY_USERNAME=$(ls /home)
|
||
else
|
||
# select one from a number of users
|
||
if [[ $SYSTEM_TYPE == "$VARIANT_MESH" && $DEFAULT_DOMAIN_NAME && -d /home/$DEFAULT_DOMAIN_NAME ]]; then
|
||
MY_USERNAME=$DEFAULT_DOMAIN_NAME
|
||
else
|
||
select_user
|
||
if [ ! $SELECTED_USERNAME ]; then
|
||
echo $'No username selected'
|
||
exit 72589
|
||
fi
|
||
MY_USERNAME="$SELECTED_USERNAME"
|
||
fi
|
||
fi
|
||
fi
|
||
|
||
if [ ! $MY_USERNAME ]; then
|
||
echo $'No user account was selected'
|
||
exit 64398
|
||
fi
|
||
if [[ $MY_USERNAME == '-f' ]]; then
|
||
echo $'No user account was selected'
|
||
exit 8347
|
||
fi
|
||
if [[ $MY_USERNAME == 'debian' || $MY_USERNAME == 'fbone' ]]; then
|
||
echo $"Don't use the default user account"
|
||
exit 9341
|
||
fi
|
||
if [ ! -d /home/$MY_USERNAME ]; then
|
||
echo $"The directory /home/$MY_USERNAME does not exist"
|
||
exit 6437
|
||
fi
|
||
save_configuration_file
|
||
|
||
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
|
||
valid_name=
|
||
while [ ! $valid_name ]
|
||
do
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--inputbox $"Your full name (or nick)" 10 30 "$(grep 'MY_NAME' temp.cfg | awk -F '=' '{print $2}')" 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
0) possible_name=$(cat $data)
|
||
if [ "$possible_name" ]; then
|
||
if [ ${#possible_name} -gt 1 ]; then
|
||
valid_name="$possible_name"
|
||
MY_NAME="$possible_name"
|
||
break;
|
||
fi
|
||
fi
|
||
;;
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
done
|
||
save_configuration_file
|
||
fi
|
||
|
||
if [[ $MINIMAL_INSTALL == "no" ]]; then
|
||
if [[ $(grep "INSTALLING_ON_BBB" temp.cfg | awk -F '=' '{print $2}') == "yes" ]]; then
|
||
dialog --title $"Install Target" \
|
||
--backtitle $"Freedombone Configuration" \
|
||
--yesno $"\nAre you installing onto a Beaglebone Black?" 7 60
|
||
else
|
||
dialog --title $"Install Target" \
|
||
--backtitle $"Freedombone Configuration" \
|
||
--defaultno \
|
||
--yesno $"\nAre you installing onto a Beaglebone Black?" 7 60
|
||
fi
|
||
sel=$?
|
||
case $sel in
|
||
0) INSTALLING_ON_BBB="yes";;
|
||
1) INSTALLING_ON_BBB="no";;
|
||
255) exit 1;;
|
||
esac
|
||
if [[ $INSTALLING_ON_BBB == "yes" ]]; then
|
||
USB_DRIVE=/dev/sda1
|
||
fi
|
||
save_configuration_file
|
||
fi
|
||
|
||
if [[ $MINIMAL_INSTALL == "no" ]]; then
|
||
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
|
||
interactive_gpg
|
||
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
SOCIAL_KEY_STR=$"\nDo you wish to enable social key management, otherwise known as \"the unforgettable key\"?\n\nThis means that fragments of your GPG key will be included with any remote backups so that if you later lose your key then it can be reconstructed from your friends servers. If you select \"no\" then you can still do social key management, but offline using physical USB thumb drives, which is more secure but less convenient."
|
||
if [[ $(grep "ENABLE_SOCIAL_KEY_MANAGEMENT" temp.cfg | awk -F '=' '{print $2}') == "yes" ]]; then
|
||
dialog --title $"Social Key Management" \
|
||
--backtitle $"Freedombone Configuration" \
|
||
--yesno "$SOCIAL_KEY_STR" 15 60
|
||
else
|
||
dialog --title $"Social Key Management" \
|
||
--backtitle $"Freedombone Configuration" \
|
||
--defaultno \
|
||
--yesno "$SOCIAL_KEY_STR" 15 60
|
||
fi
|
||
sel=$?
|
||
case $sel in
|
||
0) ENABLE_SOCIAL_KEY_MANAGEMENT="yes";;
|
||
255) exit 1;;
|
||
esac
|
||
save_configuration_file
|
||
fi
|
||
else
|
||
# enable for the minimal case
|
||
ENABLE_SOCIAL_KEY_MANAGEMENT="yes"
|
||
fi
|
||
|
||
if [[ $MINIMAL_INSTALL == "no" ]]; then
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
if [[ $INSTALLING_ON_BBB != "yes" ]]; then
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--radiolist $"Type of Random Number Generator:" 10 40 2 \
|
||
1 Haveged on \
|
||
2 OneRNG off 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
case $(cat $data) in
|
||
2) HWRNG_TYPE="onerng"
|
||
dialog --title $"OneRNG Device" \
|
||
--msgbox $"Please ensure that the OneRNG device is disconnected. You can reconnect it later during the installation" 8 60
|
||
;;
|
||
255) exit 1;;
|
||
esac
|
||
else
|
||
HWRNG_TYPE="beaglebone"
|
||
fi
|
||
save_configuration_file
|
||
fi
|
||
|
||
if [[ $MINIMAL_INSTALL == "no" ]]; then
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--radiolist $"Where to download Debian packages from:" 25 45 49 \
|
||
1 $"Australia" off \
|
||
2 $"Austria" off \
|
||
3 $"Belarus" off \
|
||
4 $"Belgium" off \
|
||
5 $"Bosnia and Herzegovina" off \
|
||
6 $"Brazil" off \
|
||
7 $"Bulgaria" off \
|
||
8 $"Canada" off \
|
||
9 $"Chile" off \
|
||
10 $"China" off \
|
||
11 $"Croatia" off \
|
||
12 $"Czech Republic" off \
|
||
13 $"Denmark" off \
|
||
14 $"El Salvador" off \
|
||
15 $"Estonia" off \
|
||
16 $"Finland" off \
|
||
17 $"France 1" off \
|
||
18 $"France 2" off \
|
||
19 $"Germany 1" off \
|
||
20 $"Germany 2" off \
|
||
21 $"Greece" off \
|
||
22 $"Hungary" off \
|
||
23 $"Iceland" off \
|
||
24 $"Iran" off \
|
||
25 $"Ireland" off \
|
||
26 $"Italy" off \
|
||
27 $"Japan" off \
|
||
28 $"Korea" off \
|
||
29 $"Lithuania" off \
|
||
30 $"Mexico" off \
|
||
31 $"Netherlands" off \
|
||
32 $"New Caledonia" off \
|
||
33 $"New Zealand" off \
|
||
34 $"Norway" off \
|
||
35 $"Poland" off \
|
||
36 $"Portugal" off \
|
||
37 $"Romania" off \
|
||
38 $"Russia" off \
|
||
39 $"Slovakia" off \
|
||
40 $"Slovenia" off \
|
||
41 $"Spain" off \
|
||
42 $"Sweden" off \
|
||
43 $"Switzerland" off \
|
||
44 $"Taiwan" off \
|
||
45 $"Thailand" off \
|
||
46 $"Turkey" off \
|
||
47 $"Ukraine" off \
|
||
48 $"United Kingdom" off \
|
||
49 $"United States" on 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
case $(cat $data) in
|
||
1) DEBIAN_REPO='ftp.au.debian.org';;
|
||
2) DEBIAN_REPO='ftp.at.debian.org';;
|
||
3) DEBIAN_REPO='ftp.by.debian.org';;
|
||
4) DEBIAN_REPO='ftp.be.debian.org';;
|
||
5) DEBIAN_REPO='ftp.ba.debian.org';;
|
||
6) DEBIAN_REPO='ftp.br.debian.org';;
|
||
7) DEBIAN_REPO='ftp.bg.debian.org';;
|
||
8) DEBIAN_REPO='ftp.ca.debian.org';;
|
||
9) DEBIAN_REPO='ftp.cl.debian.org';;
|
||
10) DEBIAN_REPO='ftp.cn.debian.org';;
|
||
11) DEBIAN_REPO='ftp.hr.debian.org';;
|
||
12) DEBIAN_REPO='ftp.cz.debian.org';;
|
||
13) DEBIAN_REPO='ftp.dk.debian.org';;
|
||
14) DEBIAN_REPO='ftp.sv.debian.org';;
|
||
15) DEBIAN_REPO='ftp.ee.debian.org';;
|
||
16) DEBIAN_REPO='ftp.fi.debian.org';;
|
||
17) DEBIAN_REPO='ftp2.fr.debian.org';;
|
||
18) DEBIAN_REPO='ftp.fr.debian.org';;
|
||
19) DEBIAN_REPO='ftp2.de.debian.org';;
|
||
20) DEBIAN_REPO='ftp.de.debian.org';;
|
||
21) DEBIAN_REPO='ftp.gr.debian.org';;
|
||
22) DEBIAN_REPO='ftp.hu.debian.org';;
|
||
23) DEBIAN_REPO='ftp.is.debian.org';;
|
||
24) DEBIAN_REPO='ftp.ir.debian.org';;
|
||
25) DEBIAN_REPO='ftp.ie.debian.org';;
|
||
26) DEBIAN_REPO='ftp.it.debian.org';;
|
||
27) DEBIAN_REPO='ftp.jp.debian.org';;
|
||
28) DEBIAN_REPO='ftp.kr.debian.org';;
|
||
29) DEBIAN_REPO='ftp.lt.debian.org';;
|
||
30) DEBIAN_REPO='ftp.mx.debian.org';;
|
||
31) DEBIAN_REPO='ftp.nl.debian.org';;
|
||
32) DEBIAN_REPO='ftp.nc.debian.org';;
|
||
33) DEBIAN_REPO='ftp.nz.debian.org';;
|
||
34) DEBIAN_REPO='ftp.no.debian.org';;
|
||
35) DEBIAN_REPO='ftp.pl.debian.org';;
|
||
36) DEBIAN_REPO='ftp.pt.debian.org';;
|
||
37) DEBIAN_REPO='ftp.ro.debian.org';;
|
||
38) DEBIAN_REPO='ftp.ru.debian.org';;
|
||
39) DEBIAN_REPO='ftp.sk.debian.org';;
|
||
40) DEBIAN_REPO='ftp.si.debian.org';;
|
||
41) DEBIAN_REPO='ftp.es.debian.org';;
|
||
42) DEBIAN_REPO='ftp.se.debian.org';;
|
||
43) DEBIAN_REPO='ftp.ch.debian.org';;
|
||
44) DEBIAN_REPO='ftp.tw.debian.org';;
|
||
45) DEBIAN_REPO='ftp.th.debian.org';;
|
||
46) DEBIAN_REPO='ftp.tr.debian.org';;
|
||
47) DEBIAN_REPO='ftp.ua.debian.org';;
|
||
48) DEBIAN_REPO='ftp.uk.debian.org';;
|
||
49) DEBIAN_REPO='ftp.us.debian.org';;
|
||
255) exit 1;;
|
||
esac
|
||
save_configuration_file
|
||
else
|
||
DEBIAN_REPO='ftp.de.debian.org'
|
||
fi
|
||
|
||
if [[ $MINIMAL_INSTALL == "no" && $ONION_ONLY == "no" ]]; then
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--radiolist $"Pick a domain name service (DNS):" 25 50 16 \
|
||
1 $"Digital Courage" on \
|
||
2 $"German Privacy Foundation 1" off \
|
||
3 $"German Privacy Foundation 2" off \
|
||
4 $"Chaos Computer Club" off \
|
||
5 $"ClaraNet" off \
|
||
6 $"OpenNIC 1" off \
|
||
7 $"OpenNIC 2" off \
|
||
8 $"OpenNIC 3" off \
|
||
9 $"OpenNIC 4" off \
|
||
10 $"OpenNIC 5" off \
|
||
11 $"OpenNIC 6" off \
|
||
12 $"OpenNIC 7" off \
|
||
13 $"PowerNS" off \
|
||
14 $"ValiDOM" off \
|
||
15 $"Freie Unzensierte" off \
|
||
16 $"Google" off 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
case $(cat $data) in
|
||
1) NAMESERVER1='85.214.73.63'
|
||
NAMESERVER2='213.73.91.35'
|
||
;;
|
||
2) NAMESERVER1='87.118.100.175'
|
||
NAMESERVER2='94.75.228.29'
|
||
;;
|
||
3) NAMESERVER1='85.25.251.254'
|
||
NAMESERVER2='2.141.58.13'
|
||
;;
|
||
4) NAMESERVER1='213.73.91.35'
|
||
NAMESERVER2='85.214.73.63'
|
||
;;
|
||
5) NAMESERVER1='212.82.225.7'
|
||
NAMESERVER2='212.82.226.212'
|
||
;;
|
||
6) NAMESERVER1='58.6.115.42'
|
||
NAMESERVER2='58.6.115.43'
|
||
;;
|
||
7) NAMESERVER1='119.31.230.42'
|
||
NAMESERVER2='200.252.98.162'
|
||
;;
|
||
8) NAMESERVER1='217.79.186.148'
|
||
NAMESERVER2='81.89.98.6'
|
||
;;
|
||
9) NAMESERVER1='78.159.101.37'
|
||
NAMESERVER2='203.167.220.153'
|
||
;;
|
||
10) NAMESERVER1='82.229.244.191'
|
||
NAMESERVER2='82.229.244.191'
|
||
;;
|
||
11) NAMESERVER1='216.87.84.211'
|
||
NAMESERVER2='66.244.95.20'
|
||
;;
|
||
12) NAMESERVER1='207.192.69.155'
|
||
NAMESERVER2='72.14.189.120'
|
||
;;
|
||
13) NAMESERVER1='194.145.226.26'
|
||
NAMESERVER2='77.220.232.44'
|
||
;;
|
||
14) NAMESERVER1='78.46.89.147'
|
||
NAMESERVER2='88.198.75.145'
|
||
;;
|
||
15) NAMESERVER1='85.25.149.144'
|
||
NAMESERVER2='87.106.37.196'
|
||
;;
|
||
16) NAMESERVER1='8.8.8.8'
|
||
NAMESERVER2='4.4.4.4'
|
||
;;
|
||
255) exit 1;;
|
||
esac
|
||
save_configuration_file
|
||
else
|
||
# as defaults for a minimal install process these settings are debatable
|
||
NAMESERVER1='85.214.73.63'
|
||
NAMESERVER2='213.73.91.35'
|
||
fi
|
||
|
||
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
|
||
${PROJECT_NAME}-wifi --networksinteractive $WIFI_NETWORKS_FILE
|
||
fi
|
||
|
||
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" && $ONION_ONLY == "no" ]]; then
|
||
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--radiolist $"Choose Dynamic DNS provider:" 15 40 14 \
|
||
1 dyndns off \
|
||
2 freedns on \
|
||
3 zoneedit off \
|
||
4 no-ip off \
|
||
5 easydns off \
|
||
6 tzo off \
|
||
7 3322 off \
|
||
8 dnsomatic off \
|
||
9 tunnelbroker off \
|
||
10 dns.he.net off \
|
||
11 dynsip off \
|
||
12 sitelutions off \
|
||
13 dnsexit off \
|
||
14 changeip off 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
case $(cat $data) in
|
||
1) DDNS_PROVIDER="default@dyndns.org";;
|
||
2) DDNS_PROVIDER="default@freedns.afraid.org";;
|
||
3) DDNS_PROVIDER="default@zoneedit.com";;
|
||
4) DDNS_PROVIDER="default@no-ip.com";;
|
||
5) DDNS_PROVIDER="default@easydns.com";;
|
||
6) DDNS_PROVIDER="default@tzo.com";;
|
||
7) DDNS_PROVIDER="dyndns@3322.org";;
|
||
8) DDNS_PROVIDER="default@dnsomatic.com";;
|
||
9) DDNS_PROVIDER="ipv6tb@he.net";;
|
||
10) DDNS_PROVIDER="dyndns@he.net";;
|
||
11) DDNS_PROVIDER="default@dynsip.org";;
|
||
12) DDNS_PROVIDER="default@sitelutions.com";;
|
||
13) DDNS_PROVIDER="default@dnsexit.com";;
|
||
14) DDNS_PROVIDER="default@changeip.com";;
|
||
255) exit 1;;
|
||
esac
|
||
save_configuration_file
|
||
|
||
valid_ddns_username=
|
||
while [ ! $valid_ddns_username ]
|
||
do
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--inputbox $"Dynamic DNS provider username" 10 30 "$(grep 'DDNS_USERNAME' temp.cfg | awk -F '=' '{print $2}')" 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
0) possible_username=$(cat $data)
|
||
if [ "$possible_username" ]; then
|
||
if [ ${#possible_username} -gt 1 ]; then
|
||
valid_ddns_username=$(cat $data)
|
||
DDNS_USERNAME=$valid_ddns_username
|
||
break;
|
||
fi
|
||
fi
|
||
;;
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
done
|
||
save_configuration_file
|
||
|
||
valid_ddns_password=
|
||
while [ ! $valid_ddns_password ]
|
||
do
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--clear \
|
||
--insecure \
|
||
--passwordbox $"Dynamic DNS provider password" 10 30 "$(grep 'DDNS_PASSWORD' temp.cfg | awk -F '=' '{print $2}')" 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
0) possible_password=$(cat $data)
|
||
if [ "$possible_password" ]; then
|
||
if [ ${#possible_password} -gt 1 ]; then
|
||
valid_ddns_password=$(cat $data)
|
||
DDNS_PASSWORD=$valid_ddns_password
|
||
break;
|
||
fi
|
||
fi
|
||
;;
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
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
|
||
DDNS_PASSWORD=""
|
||
fi
|
||
done
|
||
save_configuration_file
|
||
fi
|
||
|
||
if [[ $MINIMAL_INSTALL == "no" && $ONION_ONLY == "no" ]]; then
|
||
SET_STATIC_IP="no"
|
||
dialog --title $"Static local IP address" \
|
||
--backtitle $"Freedombone Configuration" \
|
||
--defaultno \
|
||
--yesno $"\nDo you want to set a static local IP address for this system?\n\nFor example, 192.168.1.10" 10 60
|
||
sel=$?
|
||
case $sel in
|
||
0) SET_STATIC_IP="yes";;
|
||
255) exit 1;;
|
||
esac
|
||
|
||
if [[ $SET_STATIC_IP == "yes" ]]; then
|
||
if [ ! $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then
|
||
LOCAL_NETWORK_STATIC_IP_ADDRESS=$(grep 'LOCAL_NETWORK_STATIC_IP_ADDRESS' temp.cfg | awk -F '=' '{print $2}')
|
||
if [ ! $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then
|
||
LOCAL_NETWORK_STATIC_IP_ADDRESS='192.168..'
|
||
fi
|
||
fi
|
||
if [ ! $ROUTER_IP_ADDRESS ]; then
|
||
ROUTER_IP_ADDRESS=$(grep 'ROUTER_IP_ADDRESS' temp.cfg | awk -F '=' '{print $2}')
|
||
if [ ! $ROUTER_IP_ADDRESS ]; then
|
||
ROUTER_IP_ADDRESS='192.168..'
|
||
fi
|
||
fi
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--title $"Local Network Configuration" \
|
||
--form $"\nPlease enter the IP addresses:" 11 55 3 \
|
||
$"This system:" 1 1 "$LOCAL_NETWORK_STATIC_IP_ADDRESS" 1 16 16 15 \
|
||
$"Internet router:" 2 1 "$ROUTER_IP_ADDRESS" 2 16 16 15 \
|
||
2> $data
|
||
sel=$?
|
||
case $sel in
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
LOCAL_NETWORK_STATIC_IP_ADDRESS=$(cat $data | sed -n 1p)
|
||
ROUTER_IP_ADDRESS=$(cat $data | sed -n 2p)
|
||
save_configuration_file
|
||
fi
|
||
fi
|
||
|
||
if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then
|
||
if [[ $ONION_ONLY != "no" ]]; then
|
||
WIKI_TITLE='My Wiki'
|
||
WIKI_DOMAIN_NAME='wiki.local'
|
||
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
|
||
fi
|
||
save_configuration_file
|
||
fi
|
||
|
||
if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then
|
||
if [[ $ONION_ONLY != "no" ]]; then
|
||
MY_BLOG_TITLE='My Blog'
|
||
FULLBLOG_DOMAIN_NAME='blog.local'
|
||
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
|
||
fi
|
||
save_configuration_file
|
||
fi
|
||
|
||
if [[ $MEDIAGOBLIN_ENABLED == 'yes' ]]; then
|
||
if [[ $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then
|
||
if [[ $ONION_ONLY != "no" ]]; then
|
||
MEDIAGOBLIN_DOMAIN_NAME='media.local'
|
||
else
|
||
MEDIAGOBLIN_DETAILS_COMPLETE=
|
||
while [ ! $MEDIAGOBLIN_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 $"Mediagoblin Configuration" \
|
||
--form $"\nPlease enter your Mediagoblin details, or just select Ok if you don't need a Mediagoblin site:" 11 55 2 \
|
||
$"Domain:" 1 1 "$(grep 'MEDIAGOBLIN_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \
|
||
$"Code:" 2 1 "$(grep 'MEDIAGOBLIN_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 16 33 255 \
|
||
2> $data
|
||
else
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--title $"Mediagoblin Configuration" \
|
||
--form $"\nPlease enter your Mediagoblin details, or just select Ok if you don't need a Mediagoblin site:" 11 55 2 \
|
||
$"Domain:" 1 1 "$(grep 'MEDIAGOBLIN_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \
|
||
2> $data
|
||
fi
|
||
sel=$?
|
||
case $sel in
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
MEDIAGOBLIN_DOMAIN_NAME=$(cat $data | sed -n 1p)
|
||
if [ $MEDIAGOBLIN_DOMAIN_NAME ]; then
|
||
TEST_DOMAIN_NAME=$MEDIAGOBLIN_DOMAIN_NAME
|
||
validate_domain_name
|
||
if [[ $TEST_DOMAIN_NAME != $MEDIAGOBLIN_DOMAIN_NAME ]]; then
|
||
MEDIAGOBLIN_DOMAIN_NAME='invalid'
|
||
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
||
else
|
||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||
MEDIAGOBLIN_CODE=$(cat $data | sed -n 2p)
|
||
validate_freedns_code "$MEDIAGOBLIN_CODE"
|
||
if [ ! $VALID_CODE ]; then
|
||
MEDIAGOBLIN_DOMAIN_NAME='invalid'
|
||
fi
|
||
fi
|
||
fi
|
||
fi
|
||
if [ $MEDIAGOBLIN_DOMAIN_NAME ]; then
|
||
if [[ $MEDIAGOBLIN_DOMAIN_NAME == 'invalid' ]]; then
|
||
MEDIAGOBLIN_DOMAIN_NAME=
|
||
else
|
||
MEDIAGOBLIN_DETAILS_COMPLETE="yes"
|
||
fi
|
||
fi
|
||
done
|
||
fi
|
||
save_configuration_file
|
||
fi
|
||
fi
|
||
|
||
|
||
if [[ $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then
|
||
if [[ $ONION_ONLY != "no" ]]; then
|
||
HUBZILLA_DOMAIN_NAME='hubzilla.local'
|
||
else
|
||
HUBZILLA_DETAILS_COMPLETE=
|
||
while [ ! $HUBZILLA_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 $"Hubzilla Configuration" \
|
||
--form $"\nPlease enter your Hubzilla details.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 14 55 3 \
|
||
$"Domain:" 1 1 "$(grep 'HUBZILLA_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \
|
||
$"Code:" 2 1 "$(grep 'HUBZILLA_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 16 33 255 \
|
||
2> $data
|
||
else
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--title $"Hubzilla Configuration" \
|
||
--form $"\nPlease enter your Hubzilla details\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 11 55 3 \
|
||
$"Domain:" 1 1 "$(grep 'HUBZILLA_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \
|
||
2> $data
|
||
fi
|
||
sel=$?
|
||
case $sel in
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
HUBZILLA_DOMAIN_NAME=$(cat $data | sed -n 1p)
|
||
if [ $HUBZILLA_DOMAIN_NAME ]; then
|
||
TEST_DOMAIN_NAME=$HUBZILLA_DOMAIN_NAME
|
||
validate_domain_name
|
||
if [[ $TEST_DOMAIN_NAME != $HUBZILLA_DOMAIN_NAME ]]; then
|
||
HUBZILLA_DOMAIN_NAME=
|
||
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
||
else
|
||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||
HUBZILLA_CODE=$(cat $data | sed -n 2p)
|
||
validate_freedns_code "$HUBZILLA_CODE"
|
||
if [ ! $VALID_CODE ]; then
|
||
HUBZILLA_DOMAIN_NAME=
|
||
fi
|
||
fi
|
||
fi
|
||
fi
|
||
if [ $HUBZILLA_DOMAIN_NAME ]; then
|
||
HUBZILLA_DETAILS_COMPLETE="yes"
|
||
fi
|
||
done
|
||
fi
|
||
save_configuration_file
|
||
fi
|
||
|
||
if [[ $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then
|
||
if [[ $ONION_ONLY != "no" ]]; then
|
||
MICROBLOG_DOMAIN_NAME='microblog.local'
|
||
else
|
||
MICROBLOG_DETAILS_COMPLETE=
|
||
while [ ! $MICROBLOG_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 $"Microblog Configuration" \
|
||
--form $"\nPlease enter your Microblog details. Welcome message and background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 16 65 4 \
|
||
$"Domain:" 1 1 "$(grep 'MICROBLOG_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
||
$"Welcome Message:" 2 1 "$(grep '$MICROBLOG_WELCOME_MESSAGE' temp.cfg | awk -F '=' '{print $2}')" 2 25 255 255 \
|
||
$"Background image URL:" 3 1 "$(grep '$MICROBLOG_BACKGROUND_IMAGE_URL' temp.cfg | awk -F '=' '{print $2}')" 3 25 255 255 \
|
||
$"Code:" 4 1 "$(grep 'MICROBLOG_CODE' temp.cfg | awk -F '=' '{print $2}')" 4 25 33 255 \
|
||
2> $data
|
||
else
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--title $"Microblog Configuration" \
|
||
--form $"\nPlease enter your Microblog details. Welcome message and background image URL can be left blank.\n\nIMPORTANT: This should be a domain name which is supported by Let's Encrypt:" 16 65 4 \
|
||
$"Domain:" 1 1 "$(grep 'MICROBLOG_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 25 33 40 \
|
||
$"Welcome Message:" 2 1 "$(grep '$MICROBLOG_WELCOME_MESSAGE' temp.cfg | awk -F '=' '{print $2}')" 2 25 255 255 \
|
||
$"Background image URL:" 3 1 "$(grep '$MICROBLOG_BACKGROUND_IMAGE_URL' temp.cfg | awk -F '=' '{print $2}')" 3 25 255 255 \
|
||
2> $data
|
||
fi
|
||
sel=$?
|
||
case $sel in
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
MICROBLOG_DOMAIN_NAME=$(cat $data | sed -n 1p)
|
||
welcome_msg=$(cat $data | sed -n 2p)
|
||
if [ ${#welcome_msg} -gt 1 ]; then
|
||
MICROBLOG_WELCOME_MESSAGE=$welcome_msg
|
||
fi
|
||
img_url=$(cat $data | sed -n 3p)
|
||
if [ ${#img_url} -gt 1 ]; then
|
||
MICROBLOG_BACKGROUND_IMAGE_URL=$img_url
|
||
fi
|
||
if [ $MICROBLOG_DOMAIN_NAME ]; then
|
||
if [[ $MICROBLOG_DOMAIN_NAME == "$HUBZILLA_DOMAIN_NAME" ]]; then
|
||
MICROBLOG_DOMAIN_NAME=""
|
||
fi
|
||
TEST_DOMAIN_NAME=$MICROBLOG_DOMAIN_NAME
|
||
validate_domain_name
|
||
if [[ $TEST_DOMAIN_NAME != $MICROBLOG_DOMAIN_NAME ]]; then
|
||
MICROBLOG_DOMAIN_NAME=
|
||
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
||
else
|
||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||
MICROBLOG_CODE=$(cat $data | sed -n 4p)
|
||
validate_freedns_code "$MICROBLOG_CODE"
|
||
if [ ! $VALID_CODE ]; then
|
||
MICROBLOG_DOMAIN_NAME=
|
||
fi
|
||
fi
|
||
fi
|
||
fi
|
||
if [ $MICROBLOG_DOMAIN_NAME ]; then
|
||
MICROBLOG_DETAILS_COMPLETE="yes"
|
||
fi
|
||
done
|
||
fi
|
||
save_configuration_file
|
||
fi
|
||
|
||
if [[ $SYSTEM_TYPE == "$VARIANT_DEVELOPER" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then
|
||
if [[ $ONION_ONLY != "no" ]]; then
|
||
GIT_DOMAIN_NAME='git.local'
|
||
else
|
||
DEVELOPER_DETAILS_COMPLETE=
|
||
while [ ! $DEVELOPER_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 $"Developer Configuration" \
|
||
--form $"\nPlease enter your Git hosting site details.\nIf You don't need developer tools then just select Ok" 11 55 3 \
|
||
$"Domain:" 1 1 "$(grep 'GIT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \
|
||
$"Code:" 2 1 "$(grep 'GIT_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 16 33 255 \
|
||
2> $data
|
||
else
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--title $"Developer Configuration" \
|
||
--form $"\nPlease enter your Git hosting site details.\nIf You don't need developer tools then just select Ok" 11 55 2 \
|
||
$"Domain:" 1 1 "$(grep 'GIT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \
|
||
2> $data
|
||
fi
|
||
sel=$?
|
||
case $sel in
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
GIT_DOMAIN_NAME=$(cat $data | sed -n 1p)
|
||
if [ $GIT_DOMAIN_NAME ]; then
|
||
TEST_DOMAIN_NAME=$GIT_DOMAIN_NAME
|
||
validate_domain_name
|
||
if [[ $TEST_DOMAIN_NAME != $GIT_DOMAIN_NAME ]]; then
|
||
GIT_DOMAIN_NAME=
|
||
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
||
else
|
||
if [[ $DDNS_PROVIDER == "default@freedns.afraid.org" ]]; then
|
||
GIT_CODE=$(cat $data | sed -n 2p)
|
||
validate_freedns_code "$GIT_CODE"
|
||
if [ ! $VALID_CODE ]; then
|
||
GIT_DOMAIN_NAME=
|
||
fi
|
||
fi
|
||
fi
|
||
else
|
||
DEVELOPER_DETAILS_COMPLETE="yes"
|
||
fi
|
||
if [ $GIT_DOMAIN_NAME ]; then
|
||
DEVELOPER_DETAILS_COMPLETE="yes"
|
||
fi
|
||
done
|
||
fi
|
||
save_configuration_file
|
||
fi
|
||
|
||
if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then
|
||
if [[ $ONION_ONLY != "no" ]]; then
|
||
DEFAULT_DOMAIN_NAME="${PROJECT_NAME}.local"
|
||
else
|
||
DEFAULT_DOMAIN_DETAILS_COMPLETE=
|
||
while [ ! $DEFAULT_DOMAIN_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 $"Your main domain name" \
|
||
--form $"\nWhich domain name should your email/XMPP/IRC/VoIP be associated with?" 11 55 3 \
|
||
$"Domain:" 1 1 "$(grep 'DEFAULT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 1 16 33 40 \
|
||
$"Code:" 2 1 "$(grep 'DEFAULT_DOMAIN_CODE' temp.cfg | awk -F '=' '{print $2}')" 2 16 33 255 \
|
||
2> $data
|
||
sel=$?
|
||
case $sel in
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
DEFAULT_DOMAIN_NAME=$(cat $data | sed -n 1p)
|
||
DEFAULT_DOMAIN_CODE=$(cat $data | sed -n 2p)
|
||
if [ $DEFAULT_DOMAIN_NAME ]; then
|
||
validate_freedns_code "$DEFAULT_DOMAIN_CODE"
|
||
if [ ! $VALID_CODE ]; then
|
||
DEFAULT_DOMAIN_NAME=
|
||
fi
|
||
fi
|
||
else
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--inputbox $"Which domain name should your email/XMPP/IRC/VoIP be associated with?" 10 45 \
|
||
"$(grep 'DEFAULT_DOMAIN_NAME' temp.cfg | awk -F '=' '{print $2}')" 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
0) DEFAULT_DOMAIN_NAME=$(cat $data);;
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
fi
|
||
if [ $DEFAULT_DOMAIN_NAME ]; then
|
||
TEST_DOMAIN_NAME=$DEFAULT_DOMAIN_NAME
|
||
validate_domain_name
|
||
if [[ $TEST_DOMAIN_NAME != $DEFAULT_DOMAIN_NAME ]]; then
|
||
DEFAULT_DOMAIN_NAME=
|
||
dialog --title $"Domain name validation" --msgbox "$TEST_DOMAIN_NAME" 15 50
|
||
else
|
||
DEFAULT_DOMAIN_DETAILS_COMPLETE="yes"
|
||
fi
|
||
fi
|
||
done
|
||
fi
|
||
save_configuration_file
|
||
|
||
if [[ $ONION_ONLY != "no" ]]; then
|
||
EMAIL_ADDRESS=$MY_USERNAME@$DEFAULT_DOMAIN_NAME
|
||
else
|
||
while [ ${#MY_EMAIL_ADDRESS} -lt 5 ]
|
||
do
|
||
EMAIL_ADDRESS=$(grep 'MY_EMAIL_ADDRESS' temp.cfg | awk -F '=' '{print $2}')
|
||
if [ ! $EMAIL_ADDRESS ]; then
|
||
EMAIL_ADDRESS=$MY_USERNAME@$DEFAULT_DOMAIN_NAME
|
||
fi
|
||
if [ ${#MY_EMAIL_ADDRESS} -lt 5 ]; then
|
||
EMAIL_ADDRESS=$MY_USERNAME@$DEFAULT_DOMAIN_NAME
|
||
fi
|
||
|
||
data=$(tempfile 2>/dev/null)
|
||
trap "rm -f $data" 0 1 2 5 15
|
||
dialog --backtitle $"Freedombone Configuration" \
|
||
--inputbox $"Your email address" 10 30 "$EMAIL_ADDRESS" 2> $data
|
||
sel=$?
|
||
case $sel in
|
||
0) MY_EMAIL_ADDRESS=$(cat $data);;
|
||
1) exit 1;;
|
||
255) exit 1;;
|
||
esac
|
||
done
|
||
fi
|
||
save_configuration_file
|
||
fi
|
||
|
||
# delete the temporary configuration file
|
||
if [ -f temp.cfg ]; then
|
||
shred -zu temp.cfg
|
||
fi
|
||
}
|
||
|
||
function show_result {
|
||
#clear
|
||
echo ''
|
||
echo -n $"Configuration filename:"
|
||
echo " $CONFIGURATION_FILE"
|
||
echo ''
|
||
echo $'Contents:'
|
||
echo ''
|
||
cat $CONFIGURATION_FILE
|
||
echo ''
|
||
}
|
||
|
||
function read_configuration {
|
||
if [ ! $CONFIGURATION_FILE ]; then
|
||
CONFIGURATION_FILE='freedombone.cfg'
|
||
fi
|
||
|
||
if [ -f $CONFIGURATION_FILE ]; then
|
||
if grep -q "FRIENDS_MIRRORS_SERVER" $CONFIGURATION_FILE; then
|
||
FRIENDS_MIRRORS_SERVER=$(grep "FRIENDS_MIRRORS_SERVER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "FRIENDS_MIRRORS_SSH_PORT" $CONFIGURATION_FILE; then
|
||
FRIENDS_MIRRORS_SSH_PORT=$(grep "FRIENDS_MIRRORS_SSH_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then
|
||
FRIENDS_MIRRORS_PASSWORD=$(grep "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "ENABLE_SOCIAL_KEY_MANAGEMENT" $CONFIGURATION_FILE; then
|
||
ENABLE_SOCIAL_KEY_MANAGEMENT=$(grep "ENABLE_SOCIAL_KEY_MANAGEMENT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "GIT_DOMAIN_NAME" $CONFIGURATION_FILE; then
|
||
GIT_DOMAIN_NAME=$(grep "GIT_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "GIT_CODE" $CONFIGURATION_FILE; then
|
||
GIT_CODE=$(grep "GIT_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "MY_USERNAME" $CONFIGURATION_FILE; then
|
||
MY_USERNAME=$(grep "MY_USERNAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "DOMAIN_NAME" $CONFIGURATION_FILE; then
|
||
# for backwards compatability
|
||
DEFAULT_DOMAIN_NAME=$(grep "DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "DEFAULT_DOMAIN_NAME" $CONFIGURATION_FILE; then
|
||
DEFAULT_DOMAIN_NAME=$(grep "DEFAULT_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "DEFAULT_DOMAIN_CODE" $CONFIGURATION_FILE; then
|
||
DEFAULT_DOMAIN_CODE=$(grep "DEFAULT_DOMAIN_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "NAMESERVER1" $CONFIGURATION_FILE; then
|
||
NAMESERVER1=$(grep "NAMESERVER1" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "NAMESERVER2" $CONFIGURATION_FILE; then
|
||
NAMESERVER2=$(grep "NAMESERVER2" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
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
|
||
if grep -q "DDNS_PROVIDER" $CONFIGURATION_FILE; then
|
||
DDNS_PROVIDER=$(grep "DDNS_PROVIDER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "DDNS_USERNAME" $CONFIGURATION_FILE; then
|
||
DDNS_USERNAME=$(grep "DDNS_USERNAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "DDNS_PASSWORD" $CONFIGURATION_FILE; then
|
||
DDNS_PASSWORD=$(grep "DDNS_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "LOCAL_NETWORK_STATIC_IP_ADDRESS" $CONFIGURATION_FILE; then
|
||
LOCAL_NETWORK_STATIC_IP_ADDRESS=$(grep "LOCAL_NETWORK_STATIC_IP_ADDRESS" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "ENABLE_CJDNS" $CONFIGURATION_FILE; then
|
||
ENABLE_CJDNS=$(grep "ENABLE_CJDNS" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "ENABLE_BATMAN" $CONFIGURATION_FILE; then
|
||
ENABLE_BATMAN=$(grep "ENABLE_BATMAN" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "ENABLE_BABEL" $CONFIGURATION_FILE; then
|
||
ENABLE_BABEL=$(grep "ENABLE_BABEL" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "ROUTER_IP_ADDRESS" $CONFIGURATION_FILE; then
|
||
ROUTER_IP_ADDRESS=$(grep "ROUTER_IP_ADDRESS" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "WIKI_TITLE" $CONFIGURATION_FILE; then
|
||
WIKI_TITLE=$(grep "WIKI_TITLE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "MY_NAME" $CONFIGURATION_FILE; then
|
||
MY_NAME=$(grep "MY_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "MY_EMAIL_ADDRESS" $CONFIGURATION_FILE; then
|
||
MY_EMAIL_ADDRESS=$(grep "MY_EMAIL_ADDRESS" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "INSTALLING_ON_BBB" $CONFIGURATION_FILE; then
|
||
INSTALLING_ON_BBB=$(grep "INSTALLING_ON_BBB" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "USB_DRIVE" $CONFIGURATION_FILE; then
|
||
USB_DRIVE=$(grep "USB_DRIVE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "PUBLIC_MAILING_LIST" $CONFIGURATION_FILE; then
|
||
PUBLIC_MAILING_LIST=$(grep "PUBLIC_MAILING_LIST" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "MICROBLOG_DOMAIN_NAME" $CONFIGURATION_FILE; then
|
||
MICROBLOG_DOMAIN_NAME=$(grep "MICROBLOG_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "MICROBLOG_CODE" $CONFIGURATION_FILE; then
|
||
MICROBLOG_CODE=$(grep "MICROBLOG_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "MICROBLOG_WELCOME_MESSAGE" $CONFIGURATION_FILE; then
|
||
MICROBLOG_WELCOME_MESSAGE=$(grep "MICROBLOG_WELCOME_MESSAGE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "MICROBLOG_BACKGROUND_IMAGE_URL" $CONFIGURATION_FILE; then
|
||
MICROBLOG_BACKGROUND_IMAGE_URL=$(grep "MICROBLOG_BACKGROUND_IMAGE_URL" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE; then
|
||
HUBZILLA_DOMAIN_NAME=$(grep "HUBZILLA_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "HUBZILLA_CODE" $CONFIGURATION_FILE; then
|
||
HUBZILLA_CODE=$(grep "HUBZILLA_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "MEDIAGOBLIN_DOMAIN_NAME" $CONFIGURATION_FILE; then
|
||
MEDIAGOBLIN_DOMAIN_NAME=$(grep "MEDIAGOBLIN_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "MEDIAGOBLIN_CODE" $CONFIGURATION_FILE; then
|
||
MEDIAGOBLIN_CODE=$(grep "MEDIAGOBLIN_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "WIKI_DOMAIN_NAME" $CONFIGURATION_FILE; then
|
||
WIKI_DOMAIN_NAME=$(grep "WIKI_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "WIKI_CODE" $CONFIGURATION_FILE; then
|
||
WIKI_CODE=$(grep "WIKI_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "FULLBLOG_DOMAIN_NAME" $CONFIGURATION_FILE; then
|
||
FULLBLOG_DOMAIN_NAME=$(grep "FULLBLOG_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "FULLBLOG_CODE" $CONFIGURATION_FILE; then
|
||
FULLBLOG_CODE=$(grep "FULLBLOG_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "MY_BLOG_TITLE" $CONFIGURATION_FILE; then
|
||
MY_BLOG_TITLE=$(grep "MY_BLOG_TITLE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "MY_BLOG_SUBTITLE" $CONFIGURATION_FILE; then
|
||
MY_BLOG_SUBTITLE=$(grep "MY_BLOG_SUBTITLE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "MEDIAGOBLIN_DOMAIN_NAME" $CONFIGURATION_FILE; then
|
||
MEDIAGOBLIN_DOMAIN_NAME=$(grep "MEDIAGOBLIN_DOMAIN_NAME" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "MEDIAGOBLIN_CODE" $CONFIGURATION_FILE; then
|
||
MEDIAGOBLIN_CODE=$(grep "MEDIAGOBLIN_CODE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "WIFI_SSID" $CONFIGURATION_FILE; then
|
||
WIFI_SSID=$(grep "WIFI_SSID" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "WIFI_INTERFACE" $CONFIGURATION_FILE; then
|
||
WIFI_INTERFACE=$(grep "WIFI_INTERFACE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "WIFI_TYPE" $CONFIGURATION_FILE; then
|
||
WIFI_TYPE=$(grep "WIFI_TYPE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "WIFI_PASSPHRASE" $CONFIGURATION_FILE; then
|
||
WIFI_PASSPHRASE=$(grep "WIFI_PASSPHRASE" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "BATMAN_CELLID" $CONFIGURATION_FILE; then
|
||
BATMAN_CELLID=$(grep "BATMAN_CELLID" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "WIFI_CHANNEL" $CONFIGURATION_FILE; then
|
||
WIFI_CHANNEL=$(grep "WIFI_CHANNEL" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
if grep -q "ONION_ONLY" $CONFIGURATION_FILE; then
|
||
ONION_ONLY=$(grep "ONION_ONLY" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
|
||
fi
|
||
fi
|
||
}
|
||
|
||
read_configuration
|
||
interactive_configuration
|
||
show_result
|
||
exit 0
|