diff --git a/src/freedombone b/src/freedombone index 1f73ae6d..c076afa5 100755 --- a/src/freedombone +++ b/src/freedombone @@ -1712,6 +1712,35 @@ function add_onion_service { echo $(cat /var/lib/tor/hidden_service_${onion_service_name}/hostname) } +function setup_wifi { + if [[ $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then + return + fi + if [ ! $WIFI_SSID ]; then + return + fi + if [ ${#WIFI_SSID} -lt 2 ]; then + return + fi + if grep -Fxq "setup_wifi" $COMPLETION_FILE; then + return + fi + if [[ $WIFI_TYPE != 'none' ]]; then + if [ ! $WIFI_PASSPHRASE ]; then + echo $'No wifi passphrase was given' + return + fi + if [ ${#WIFI_PASSPHRASE} -lt 2 ]; then + echo $'Wifi passphrase was too short' + return + fi + ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE -p $WIFI_PASSPHRASE + else + ${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE + fi + echo 'setup_wifi' >> $COMPLETION_FILE +} + function create_avahi_onion_domains { if [[ $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then return @@ -6589,11 +6618,11 @@ function install_tox_client { exit 67248 fi - # initial setup of username + # initial setup of username #su -c "echo 'n - #/nick $MY_USERNAME - #/exit - #' | $TOXIC_FILE -d" - $MY_USERNAME + #/nick $MY_USERNAME + #/exit + #' | $TOXIC_FILE -d" - $MY_USERNAME echo 'install_tox_client' >> $COMPLETION_FILE } @@ -6876,57 +6905,57 @@ function install_irc_client { echo ' },' >> /home/$MY_USERNAME/.irssi/config echo ' {' >> /home/$MY_USERNAME/.irssi/config echo " address = \"127.0.0.1\";" >> /home/$MY_USERNAME/.irssi/config - if [[ $ONION_ONLY == 'no' ]]; then - echo " port = \"${IRC_PORT}\";" >> /home/$MY_USERNAME/.irssi/config - echo ' use_ssl = "yes";' >> /home/$MY_USERNAME/.irssi/config - else - IRC_ONION_HOSTNAME=$(cat $COMPLETION_FILE | grep "IRC onion domain" | awk -F ':' '{print $2}') - echo " port = \"${IRC_ONION_PORT}\";" >> /home/$MY_USERNAME/.irssi/config - echo ' use_ssl = "no";' >> /home/$MY_USERNAME/.irssi/config - fi - echo ' chatnet = "Freedombone";' >> /home/$MY_USERNAME/.irssi/config - echo ' ssl_verify = "no";' >> /home/$MY_USERNAME/.irssi/config - echo ' autoconnect = "yes";' >> /home/$MY_USERNAME/.irssi/config - if [ $IRC_PASSWORD ]; then - echo " password = \"${IRC_PASSWORD}\";" >> /home/$MY_USERNAME/.irssi/config - fi - echo ' }' >> /home/$MY_USERNAME/.irssi/config - echo ');' >> /home/$MY_USERNAME/.irssi/config - echo '' >> /home/$MY_USERNAME/.irssi/config - echo 'chatnets = {' >> /home/$MY_USERNAME/.irssi/config - echo ' Freedombone = {' >> /home/$MY_USERNAME/.irssi/config - echo ' type = "IRC";' >> /home/$MY_USERNAME/.irssi/config - echo ' max_kicks = "1";' >> /home/$MY_USERNAME/.irssi/config - echo ' max_msgs = "4";' >> /home/$MY_USERNAME/.irssi/config - echo ' max_whois = "1";' >> /home/$MY_USERNAME/.irssi/config - echo ' };' >> /home/$MY_USERNAME/.irssi/config - echo ' Freenode = {' >> /home/$MY_USERNAME/.irssi/config - echo ' type = "IRC";' >> /home/$MY_USERNAME/.irssi/config - echo ' max_kicks = "1";' >> /home/$MY_USERNAME/.irssi/config - echo ' max_msgs = "4";' >> /home/$MY_USERNAME/.irssi/config - echo ' max_whois = "1";' >> /home/$MY_USERNAME/.irssi/config - echo ' };' >> /home/$MY_USERNAME/.irssi/config - echo ' OFTC = {' >> /home/$MY_USERNAME/.irssi/config - echo ' type = "IRC";' >> /home/$MY_USERNAME/.irssi/config - echo ' max_kicks = "1";' >> /home/$MY_USERNAME/.irssi/config - echo ' max_msgs = "1";' >> /home/$MY_USERNAME/.irssi/config - echo ' max_whois = "1";' >> /home/$MY_USERNAME/.irssi/config - echo ' };' >> /home/$MY_USERNAME/.irssi/config - echo '};' >> /home/$MY_USERNAME/.irssi/config - echo '' >> /home/$MY_USERNAME/.irssi/config - echo 'channels = (' >> /home/$MY_USERNAME/.irssi/config - echo ' { name = "#freedombone"; chatnet = "Freedombone"; autojoin = "Yes"; },' >> /home/$MY_USERNAME/.irssi/config - echo ');' >> /home/$MY_USERNAME/.irssi/config - echo '' >> /home/$MY_USERNAME/.irssi/config - echo 'settings = {' >> /home/$MY_USERNAME/.irssi/config - echo " core = { real_name = \"$MY_NAME\"; user_name = \"$MY_USERNAME\"; nick = \"$MY_USERNAME\"; };" >> /home/$MY_USERNAME/.irssi/config - echo ' "fe-text" = { actlist_sort = "refnum"; };' >> /home/$MY_USERNAME/.irssi/config - echo '};' >> /home/$MY_USERNAME/.irssi/config - echo 'ignores = ( { level = "CTCPS"; } );' >> /home/$MY_USERNAME/.irssi/config + if [[ $ONION_ONLY == 'no' ]]; then + echo " port = \"${IRC_PORT}\";" >> /home/$MY_USERNAME/.irssi/config + echo ' use_ssl = "yes";' >> /home/$MY_USERNAME/.irssi/config + else + IRC_ONION_HOSTNAME=$(cat $COMPLETION_FILE | grep "IRC onion domain" | awk -F ':' '{print $2}') + echo " port = \"${IRC_ONION_PORT}\";" >> /home/$MY_USERNAME/.irssi/config + echo ' use_ssl = "no";' >> /home/$MY_USERNAME/.irssi/config + fi + echo ' chatnet = "Freedombone";' >> /home/$MY_USERNAME/.irssi/config + echo ' ssl_verify = "no";' >> /home/$MY_USERNAME/.irssi/config + echo ' autoconnect = "yes";' >> /home/$MY_USERNAME/.irssi/config + if [ $IRC_PASSWORD ]; then + echo " password = \"${IRC_PASSWORD}\";" >> /home/$MY_USERNAME/.irssi/config + fi + echo ' }' >> /home/$MY_USERNAME/.irssi/config + echo ');' >> /home/$MY_USERNAME/.irssi/config + echo '' >> /home/$MY_USERNAME/.irssi/config + echo 'chatnets = {' >> /home/$MY_USERNAME/.irssi/config + echo ' Freedombone = {' >> /home/$MY_USERNAME/.irssi/config + echo ' type = "IRC";' >> /home/$MY_USERNAME/.irssi/config + echo ' max_kicks = "1";' >> /home/$MY_USERNAME/.irssi/config + echo ' max_msgs = "4";' >> /home/$MY_USERNAME/.irssi/config + echo ' max_whois = "1";' >> /home/$MY_USERNAME/.irssi/config + echo ' };' >> /home/$MY_USERNAME/.irssi/config + echo ' Freenode = {' >> /home/$MY_USERNAME/.irssi/config + echo ' type = "IRC";' >> /home/$MY_USERNAME/.irssi/config + echo ' max_kicks = "1";' >> /home/$MY_USERNAME/.irssi/config + echo ' max_msgs = "4";' >> /home/$MY_USERNAME/.irssi/config + echo ' max_whois = "1";' >> /home/$MY_USERNAME/.irssi/config + echo ' };' >> /home/$MY_USERNAME/.irssi/config + echo ' OFTC = {' >> /home/$MY_USERNAME/.irssi/config + echo ' type = "IRC";' >> /home/$MY_USERNAME/.irssi/config + echo ' max_kicks = "1";' >> /home/$MY_USERNAME/.irssi/config + echo ' max_msgs = "1";' >> /home/$MY_USERNAME/.irssi/config + echo ' max_whois = "1";' >> /home/$MY_USERNAME/.irssi/config + echo ' };' >> /home/$MY_USERNAME/.irssi/config + echo '};' >> /home/$MY_USERNAME/.irssi/config + echo '' >> /home/$MY_USERNAME/.irssi/config + echo 'channels = (' >> /home/$MY_USERNAME/.irssi/config + echo ' { name = "#freedombone"; chatnet = "Freedombone"; autojoin = "Yes"; },' >> /home/$MY_USERNAME/.irssi/config + echo ');' >> /home/$MY_USERNAME/.irssi/config + echo '' >> /home/$MY_USERNAME/.irssi/config + echo 'settings = {' >> /home/$MY_USERNAME/.irssi/config + echo " core = { real_name = \"$MY_NAME\"; user_name = \"$MY_USERNAME\"; nick = \"$MY_USERNAME\"; };" >> /home/$MY_USERNAME/.irssi/config + echo ' "fe-text" = { actlist_sort = "refnum"; };' >> /home/$MY_USERNAME/.irssi/config + echo '};' >> /home/$MY_USERNAME/.irssi/config + echo 'ignores = ( { level = "CTCPS"; } );' >> /home/$MY_USERNAME/.irssi/config - chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.irssi + chown -R $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.irssi - echo 'install_irc_client' >> $COMPLETION_FILE + echo 'install_irc_client' >> $COMPLETION_FILE } function install_irc_server { @@ -10395,6 +10424,7 @@ set_your_domain_name time_synchronisation configure_internet_protocol create_git_project +setup_wifi configure_ssh configure_ssh_onion allow_ssh_to_onion_address diff --git a/src/freedombone-config b/src/freedombone-config index f6d8f501..a23e4dbc 100755 --- a/src/freedombone-config +++ b/src/freedombone-config @@ -262,67 +262,67 @@ function save_configuration_file { 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 [ $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 + 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 [ $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 + 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 @@ -841,330 +841,330 @@ function interactive_configuration { 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 + 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 + 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 + 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 + 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 [[ $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 [[ $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 [ -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 [ ! $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 [[ $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 [[ $(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 + 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 + 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 + 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 \ + 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 \ @@ -1175,83 +1175,83 @@ function interactive_configuration { 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';; + 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 + 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 \ + 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 \ @@ -1313,138 +1313,162 @@ function interactive_configuration { 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 + 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" && $ONION_ONLY == "no" ]]; then + if [[ $SYSTEM_TYPE != "$VARIANT_MESH" ]]; then + data=$(tempfile 2>/dev/null) + trap "rm -f $data" 0 1 2 5 15 + dialog --backtitle $"Freedombone Configuration" \ + --title $"Wifi setup" \ + --form $"\nIf you wish to use wifi rather than wired ethernet then enter the details below, otherwise just select Ok:" 15 55 5 \ + $"Interface:" 1 1 "$WIFI_INTERFACE" 1 16 16 15 \ + $"SSID:" 2 1 "$WIFI_SSID" 2 16 30 30 \ + $"Type:" 3 1 "$WIFI_TYPE" 3 16 16 15 \ + $"Passphrase:" 4 1 "$WIFI_PASSPHRASE" 4 16 30 30 \ + 2> $data + sel=$? + case $sel in + 1) exit 1;; + 255) exit 1;; + esac + WIFI_INTERFACE=$(cat $data | sed -n 1p) + WIFI_SSID=$(cat $data | sed -n 2p) + WIFI_TYPE=$(cat $data | sed -n 3p) + WIFI_PASSPHRASE=$(cat $data | sed -n 4p) + save_configuration_file + fi - 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 + + if [[ $SYSTEM_TYPE != "$VARIANT_MESH" && $ONION_ONLY == "no" ]]; then - 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 + 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_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 + 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 - 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 + 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 [[ $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" && $ONION_ONLY == "no" ]]; then SET_STATIC_IP="no" diff --git a/src/freedombone-wifi b/src/freedombone-wifi index c143f82b..52bac9e8 100755 --- a/src/freedombone-wifi +++ b/src/freedombone-wifi @@ -36,7 +36,7 @@ export TEXTDOMAINDIR="/usr/share/locale" CONFIGURATION_FILE=$HOME/${PROJECT_NAME}.cfg COMPLETION_FILE=$HOME/${PROJECT_NAME}-completed.txt -WIFI_DEVICE=wlan0 +WIFI_INTERFACE=wlan0 WIFI_TYPE='wpa2-psk' WIFI_SSID= WIFI_PASSPHRASE= @@ -53,30 +53,30 @@ function wifi_wpa2_psk { ssid=$1 passphrase=$2 psk=$(wifi_get_psk "$ssid" "$passphrase") - echo "auto $WIFI_DEVICE" > /etc/network/interfaces.d/wifi - echo 'iface $WIFI_DEVICE inet dhcp' >> /etc/network/interfaces.d/wifi + echo "auto $WIFI_INTERFACE" > /etc/network/interfaces.d/wifi + echo 'iface $WIFI_INTERFACE inet dhcp' >> /etc/network/interfaces.d/wifi echo " wpa-ssid $ssid" >> /etc/network/interfaces.d/wifi echo " wpa-psk $psk" >> /etc/network/interfaces.d/wifi } function wifi_none { ssid=$1 - echo "auto $WIFI_DEVICE" > /etc/network/interfaces.d/wifi - echo 'iface $WIFI_DEVICE inet dhcp' >> /etc/network/interfaces.d/wifi + echo "auto $WIFI_INTERFACE" > /etc/network/interfaces.d/wifi + echo 'iface $WIFI_INTERFACE inet dhcp' >> /etc/network/interfaces.d/wifi echo " wireless-essid $ssid" >> /etc/network/interfaces.d/wifi } function show_help { echo '' - echo $"${PROJECT_NAME}-wifi -d [device] -t [type] -s [ssid] -p [passphrase]" + echo $"${PROJECT_NAME}-wifi -i [interface] -t [type] -s [ssid] -p [passphrase]" echo '' echo $'Wifi configuration tool' echo '' - echo $' --help Show help' - echo $' -d --device [name] Device name' - echo $' -t --type [wpa2-psk|none] Security type' - echo $' -s --ssid [id] Set SSID' - echo $' -p --passphrase [text] Set passphrase' + echo $' --help Show help' + echo $' -i --interface [wlan0|wlan1...] Device name' + echo $' -t --type [wpa2-psk|none] Security type' + echo $' -s --ssid [id] Set SSID' + echo $' -p --passphrase [text] Set passphrase' echo '' exit 0 } @@ -89,9 +89,9 @@ do --help) show_help ;; - -d|--device) + -i|--if|--interface) shift - WIFI_DEVICE=${1} + WIFI_INTERFACE=${1} ;; -t|--type) shift