From 29376c60cd6f5c43ac081f2c7b23ee25c6add337 Mon Sep 17 00:00:00 2001 From: gradyoti Date: Tue, 3 Jun 2014 11:42:09 -0400 Subject: [PATCH 01/63] added setup wizard --- default-files/etc/cli | 11 ++++ default-files/usr/bin/setupwizard | 92 +++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 default-files/etc/cli create mode 100755 default-files/usr/bin/setupwizard diff --git a/default-files/etc/cli b/default-files/etc/cli new file mode 100644 index 0000000..2d6d513 --- /dev/null +++ b/default-files/etc/cli @@ -0,0 +1,11 @@ +#!/bin/sh + +<<'COMMENT' + +Plan of Attack: +* Stub out required functions +* Set up 'main' interface +* Set up helper functions + +COMMENT + diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard new file mode 100755 index 0000000..44560aa --- /dev/null +++ b/default-files/usr/bin/setupwizard @@ -0,0 +1,92 @@ +#!/bin/ash + +< mesh encryption password +* access point name +* channel +* require a password? +--> AP password + +COMMENT + + +echo "Welcome to the configuration wizard." + +echo "Please enter an administrator password: " + +passwd + +echo "Thank you." +echo "Please enter node name: " + +read NODE_NAME + +commotion + + + +< Date: Tue, 3 Jun 2014 15:49:34 -0400 Subject: [PATCH 02/63] added save changes --- default-files/usr/bin/setupwizard | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 44560aa..bb94ddc 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -26,11 +26,18 @@ echo "Please enter an administrator password: " passwd echo "Thank you." -echo "Please enter node name: " +echo "Please enter new profile name: " + +read PROFILE_NAME + +commotion new $PROFILE_NAME + + + +# commit profile changes +commotion save $PROFILE_NAME -read NODE_NAME -commotion From 37409ac30c3323777e1c86e91a5b0655d7812d09 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 3 Jun 2014 16:39:40 -0400 Subject: [PATCH 03/63] added option to set mesh password. --- default-files/usr/bin/setupwizard | 33 +++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index bb94ddc..2d2ecac 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -21,23 +21,48 @@ COMMENT echo "Welcome to the configuration wizard." -echo "Please enter an administrator password: " +echo "Please choose an administrator password: " passwd -echo "Thank you." + + + echo "Please enter new profile name: " read PROFILE_NAME commotion new $PROFILE_NAME +echo "Please enter mesh network name: " +read MESH_NAME -# commit profile changes -commotion save $PROFILE_NAME +commotion set $PROFILE_NAME ssid $MESH_NAME + +echo "Please select a valid channel: " +read MESH_CHANNEL +commotion set $PROFILE_NAME channel $MESH_CHANNEL + + +echo "Would you like to use encryption for the mesh network?" + read answer + case $answer in + [Yy]* ) echo "Please choose an encryption password: "; + read MESH_PASSWORD; + commotion set $PROFILE_NAME key $MESH_PASSWORD; + break;; + + [Nn]* ) break;; + * ) echo "Please answer yes[y] or no[n]";; + esac + + + +# commit profile changes +commotion save $PROFILE_NAME From 0ec21817236b1e05012a2bf5335ce783cda089f7 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Wed, 4 Jun 2014 13:24:43 -0400 Subject: [PATCH 04/63] added password check --- default-files/usr/bin/setupwizard | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 2d2ecac..3ce6829 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -19,14 +19,12 @@ User workflow COMMENT -echo "Welcome to the configuration wizard." - -echo "Please choose an administrator password: " - -passwd - - +echo -e "\n\nWelcome to the configuration wizard.\n" +if [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ]; then + echo "Please choose an administrator password: " + passwd +fi echo "Please enter new profile name: " From b035bc209703493e80ee209cd3041409c06335a4 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Wed, 4 Jun 2014 17:14:19 -0400 Subject: [PATCH 05/63] drafted AP setup and added uci commits to mesh setup --- default-files/usr/bin/setupwizard | 102 +++++++++++++++--------------- 1 file changed, 50 insertions(+), 52 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 3ce6829..5b2cf5f 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -36,87 +36,85 @@ echo "Please enter mesh network name: " read MESH_NAME -commotion set $PROFILE_NAME ssid $MESH_NAME - echo "Please select a valid channel: " +commotion set $PROFILE_NAME ssid $MESH_NAME + read MESH_CHANNEL commotion set $PROFILE_NAME channel $MESH_CHANNEL +# generate bssid +BSSID=`commotion genbssid $MESH_NAME $MESH_CHANNEL` -echo "Would you like to use encryption for the mesh network?" +# write changes to uci +MESH_CONFIG=`uci add wireless wifi-iface` + +uci rename wireless.$MESH_CONFIG=$MESH_NAME +uci set wireless.$MESH_NAME.mode=adhoc +uci set wireless.$MESH_NAME.device=radio0 +uci set wireless.$MESH_NAME.network=$MESH_NAME +uci set wireless.$MESH_NAME.ssid=$MESH_NAME +uci set wireless.$MESH_NAME.bssid=$BSSID + + +echo "Does this mesh network use encryption?" read answer case $answer in [Yy]* ) echo "Please choose an encryption password: "; read MESH_PASSWORD; - commotion set $PROFILE_NAME key $MESH_PASSWORD; + commotion set $PROFILE_NAME key $MESH_PASSWORD; + uci set wireless.$MESH_NAME.encryption=psk2; + uci set wireless.$MESH_NAME.key=$MESH_PASSWORD; break;; [Nn]* ) break;; * ) echo "Please answer yes[y] or no[n]";; esac - - # commit profile changes commotion save $PROFILE_NAME +# commit uci changes +uci commit -< Date: Thu, 5 Jun 2014 13:08:17 -0400 Subject: [PATCH 06/63] added uci network calls --- default-files/usr/bin/setupwizard | 57 ++++++++++++++++--------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 5b2cf5f..da9f6f0 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -1,24 +1,5 @@ #!/bin/ash -< mesh encryption password -* access point name -* channel -* require a password? ---> AP password - -COMMENT - - echo -e "\n\nWelcome to the configuration wizard.\n" if [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ]; then @@ -38,10 +19,10 @@ read MESH_NAME echo "Please select a valid channel: " -commotion set $PROFILE_NAME ssid $MESH_NAME - read MESH_CHANNEL +commotion set $PROFILE_NAME ssid $MESH_NAME + commotion set $PROFILE_NAME channel $MESH_CHANNEL # generate bssid @@ -49,14 +30,7 @@ BSSID=`commotion genbssid $MESH_NAME $MESH_CHANNEL` # write changes to uci MESH_CONFIG=`uci add wireless wifi-iface` - uci rename wireless.$MESH_CONFIG=$MESH_NAME -uci set wireless.$MESH_NAME.mode=adhoc -uci set wireless.$MESH_NAME.device=radio0 -uci set wireless.$MESH_NAME.network=$MESH_NAME -uci set wireless.$MESH_NAME.ssid=$MESH_NAME -uci set wireless.$MESH_NAME.bssid=$BSSID - echo "Does this mesh network use encryption?" read answer @@ -72,6 +46,33 @@ echo "Does this mesh network use encryption?" * ) echo "Please answer yes[y] or no[n]";; esac +# set wireless config +uci set wireless.$MESH_NAME.mode=adhoc +uci set wireless.$MESH_NAME.device=radio0 +uci set wireless.$MESH_NAME.network=$MESH_NAME +uci set wireless.$MESH_NAME.ssid=$MESH_NAME + +#uci set wireless.$MESH_NAME.bssid=$BSSID + +uci set wireless.radio0.channel=$MESH_CHANNEL +uci set wireless.radio0.disabled=0 + + +# set network config +uci set network.$MESH_NAME=interface +uci set network.$MESH_NAME.class=mesh +uci set network.$MESH_NAME.profile=$MESH_NAME +uci set network.$MESH_NAME.proto=commotion + + +# set hostname + + +# set firewall + + + + # commit profile changes commotion save $PROFILE_NAME From 511c56cf735c1fe446bc122972d0895903196911 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 5 Jun 2014 13:20:24 -0400 Subject: [PATCH 07/63] changed MESH_CONFIG to WIRELESS_CONFIG --- default-files/usr/bin/setupwizard | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index da9f6f0..9de76f3 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -29,8 +29,8 @@ commotion set $PROFILE_NAME channel $MESH_CHANNEL BSSID=`commotion genbssid $MESH_NAME $MESH_CHANNEL` # write changes to uci -MESH_CONFIG=`uci add wireless wifi-iface` -uci rename wireless.$MESH_CONFIG=$MESH_NAME +WIRELESS_CONFIG=`uci add wireless wifi-iface` +uci rename wireless.$WIRELESS_CONFIG=commotionMesh echo "Does this mesh network use encryption?" read answer @@ -38,8 +38,8 @@ echo "Does this mesh network use encryption?" [Yy]* ) echo "Please choose an encryption password: "; read MESH_PASSWORD; commotion set $PROFILE_NAME key $MESH_PASSWORD; - uci set wireless.$MESH_NAME.encryption=psk2; - uci set wireless.$MESH_NAME.key=$MESH_PASSWORD; + uci set wireless.commotionMesh.encryption=psk2; + uci set wireless.commotionMesh.key=$MESH_PASSWORD; break;; [Nn]* ) break;; @@ -47,10 +47,10 @@ echo "Does this mesh network use encryption?" esac # set wireless config -uci set wireless.$MESH_NAME.mode=adhoc -uci set wireless.$MESH_NAME.device=radio0 -uci set wireless.$MESH_NAME.network=$MESH_NAME -uci set wireless.$MESH_NAME.ssid=$MESH_NAME +uci set wireless.commotionMesh.mode=adhoc +uci set wireless.commotionMesh.device=radio0 +uci set wireless.$commotionMesh.network=$MESH_NAME +uci set wireless.$commotionMesh.ssid=$MESH_NAME #uci set wireless.$MESH_NAME.bssid=$BSSID @@ -58,11 +58,14 @@ uci set wireless.radio0.channel=$MESH_CHANNEL uci set wireless.radio0.disabled=0 + # set network config -uci set network.$MESH_NAME=interface -uci set network.$MESH_NAME.class=mesh -uci set network.$MESH_NAME.profile=$MESH_NAME -uci set network.$MESH_NAME.proto=commotion +uci add network.interface +uci rename network.interface +uci set network.$commotionMesh=interface +uci set network.$commotionMesh.class=mesh +uci set network.$commotionMesh.profile=$MESH_NAME +uci set network.$commotionMesh.proto=commotion # set hostname From 565683b84e6395301057d38f34d5fe3792f9c3ee Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 5 Jun 2014 13:30:33 -0400 Subject: [PATCH 08/63] fixed typos and deleted redundant network config entry --- default-files/usr/bin/setupwizard | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 9de76f3..f7b7b94 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -49,8 +49,8 @@ echo "Does this mesh network use encryption?" # set wireless config uci set wireless.commotionMesh.mode=adhoc uci set wireless.commotionMesh.device=radio0 -uci set wireless.$commotionMesh.network=$MESH_NAME -uci set wireless.$commotionMesh.ssid=$MESH_NAME +uci set wireless.commotionMesh.network=$MESH_NAME +uci set wireless.commotionMesh.ssid=$MESH_NAME #uci set wireless.$MESH_NAME.bssid=$BSSID @@ -60,12 +60,10 @@ uci set wireless.radio0.disabled=0 # set network config -uci add network.interface -uci rename network.interface -uci set network.$commotionMesh=interface -uci set network.$commotionMesh.class=mesh -uci set network.$commotionMesh.profile=$MESH_NAME -uci set network.$commotionMesh.proto=commotion +uci set network.$MESH_NAME=interface +uci set network.$MESH_NAME.class=mesh +uci set network.$MESH_NAME.profile=$MESH_NAME +uci set network.$MESH_NAME.proto=commotion # set hostname From a7230a73f540f07426dccabfdb958ebf375f445c Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 5 Jun 2014 13:40:55 -0400 Subject: [PATCH 09/63] cleanup --- default-files/usr/bin/setupwizard | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index f7b7b94..c59f9ea 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -7,7 +7,7 @@ if [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ]; then passwd fi -echo "Please enter new profile name: " +echo "Please enter new Commotion profile name: " read PROFILE_NAME @@ -58,7 +58,6 @@ uci set wireless.radio0.channel=$MESH_CHANNEL uci set wireless.radio0.disabled=0 - # set network config uci set network.$MESH_NAME=interface uci set network.$MESH_NAME.class=mesh From faab0ccb689abbc40addda17dcd6c52bc3e15a97 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 5 Jun 2014 14:26:27 -0400 Subject: [PATCH 10/63] fixed uci warnings --- default-files/usr/bin/setupwizard | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index c59f9ea..59a514c 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -7,6 +7,19 @@ if [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ]; then passwd fi +if [ `grep \'commotion\' /etc/config/system ]; then + echo -e "Set the hostname for this device?" + read answer + case $answer in + [Yy]* ) echo "Enter new hostname: "; + read HOSTNAME; + uci set system.hostname + break;; + + [Nn]* ) break;; + * ) echo "Please answer yes[y] or no[n]";; + esac + echo "Please enter new Commotion profile name: " read PROFILE_NAME @@ -51,20 +64,15 @@ uci set wireless.commotionMesh.mode=adhoc uci set wireless.commotionMesh.device=radio0 uci set wireless.commotionMesh.network=$MESH_NAME uci set wireless.commotionMesh.ssid=$MESH_NAME - -#uci set wireless.$MESH_NAME.bssid=$BSSID - uci set wireless.radio0.channel=$MESH_CHANNEL uci set wireless.radio0.disabled=0 - # set network config uci set network.$MESH_NAME=interface uci set network.$MESH_NAME.class=mesh uci set network.$MESH_NAME.profile=$MESH_NAME uci set network.$MESH_NAME.proto=commotion - # set hostname @@ -77,7 +85,9 @@ uci set network.$MESH_NAME.proto=commotion commotion save $PROFILE_NAME # commit uci changes -uci commit +uci commit wireless +uci commit network +uci commit system From fad80e44d4113ff0c8502b7c861bcd5424bdf760 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 5 Jun 2014 14:28:32 -0400 Subject: [PATCH 11/63] added option to change hostname --- default-files/usr/bin/setupwizard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 59a514c..ebafd73 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -13,7 +13,7 @@ if [ `grep \'commotion\' /etc/config/system ]; then case $answer in [Yy]* ) echo "Enter new hostname: "; read HOSTNAME; - uci set system.hostname + uci set system.@system[0].hostname=$HOSTNAME break;; [Nn]* ) break;; From e5941564e32b160e5a0f21ab68ef378634c551e5 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 5 Jun 2014 14:29:46 -0400 Subject: [PATCH 12/63] removed unnecessary bssid generation --- default-files/usr/bin/setupwizard | 3 --- 1 file changed, 3 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index ebafd73..c5a9963 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -38,9 +38,6 @@ commotion set $PROFILE_NAME ssid $MESH_NAME commotion set $PROFILE_NAME channel $MESH_CHANNEL -# generate bssid -BSSID=`commotion genbssid $MESH_NAME $MESH_CHANNEL` - # write changes to uci WIRELESS_CONFIG=`uci add wireless wifi-iface` uci rename wireless.$WIRELESS_CONFIG=commotionMesh From eee90c9fb734ded9d82fdef82ad8f249fff32807 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 5 Jun 2014 14:32:43 -0400 Subject: [PATCH 13/63] fixed typo --- default-files/usr/bin/setupwizard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index c5a9963..9e06970 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -13,7 +13,7 @@ if [ `grep \'commotion\' /etc/config/system ]; then case $answer in [Yy]* ) echo "Enter new hostname: "; read HOSTNAME; - uci set system.@system[0].hostname=$HOSTNAME + uci set system.@system[0].hostname=$HOSTNAME; break;; [Nn]* ) break;; From c8c42a227ab57b1b4d371347f6e3133861be2d1e Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 5 Jun 2014 14:33:58 -0400 Subject: [PATCH 14/63] fixed more typos --- default-files/usr/bin/setupwizard | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 9e06970..09f13da 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -7,7 +7,7 @@ if [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ]; then passwd fi -if [ `grep \'commotion\' /etc/config/system ]; then +if [ `grep \'commotion\' /etc/config/system` ]; then echo -e "Set the hostname for this device?" read answer case $answer in @@ -19,6 +19,7 @@ if [ `grep \'commotion\' /etc/config/system ]; then [Nn]* ) break;; * ) echo "Please answer yes[y] or no[n]";; esac +fi echo "Please enter new Commotion profile name: " From 4bc1550f351966b41649737e65c459d4c6b37feb Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 5 Jun 2014 14:49:56 -0400 Subject: [PATCH 15/63] removed network option in /etc/config/wireless --- default-files/usr/bin/setupwizard | 1 - 1 file changed, 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 09f13da..6e09c6e 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -60,7 +60,6 @@ echo "Does this mesh network use encryption?" # set wireless config uci set wireless.commotionMesh.mode=adhoc uci set wireless.commotionMesh.device=radio0 -uci set wireless.commotionMesh.network=$MESH_NAME uci set wireless.commotionMesh.ssid=$MESH_NAME uci set wireless.radio0.channel=$MESH_CHANNEL uci set wireless.radio0.disabled=0 From 28d1ba0be2de20820f5ed94750adeb7ec6357bfd Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 5 Jun 2014 15:02:23 -0400 Subject: [PATCH 16/63] fixed hostname check --- default-files/usr/bin/setupwizard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 6e09c6e..d3a0e7f 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -7,7 +7,7 @@ if [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ]; then passwd fi -if [ `grep \'commotion\' /etc/config/system` ]; then +if [ !`grep -q \'commotion\' /etc/config/system`]; then echo -e "Set the hostname for this device?" read answer case $answer in From 676dff6e58c5a90274c176c0e175f9ff13bb53b7 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 5 Jun 2014 15:14:19 -0400 Subject: [PATCH 17/63] fixed hostname statement. Now repeats after incorrect input --- default-files/usr/bin/setupwizard | 42 +++++++++++++++++++------------ 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index d3a0e7f..f9686c2 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -2,23 +2,26 @@ echo -e "\n\nWelcome to the configuration wizard.\n" +# if password not set, require password set if [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ]; then echo "Please choose an administrator password: " passwd fi -if [ !`grep -q \'commotion\' /etc/config/system`]; then - echo -e "Set the hostname for this device?" - read answer - case $answer in - [Yy]* ) echo "Enter new hostname: "; - read HOSTNAME; - uci set system.@system[0].hostname=$HOSTNAME; - break;; - - [Nn]* ) break;; - * ) echo "Please answer yes[y] or no[n]";; - esac +# if hostname not changed, allow option to set hostname +if [ !`grep -q \'commotion\' /etc/config/system` ]; then + while true; do + echo -e "Set the hostname for this device?" + read answer + case $answer in + [Yy]* ) echo "Enter new hostname: "; + read HOSTNAME; + uci set system.@system[0].hostname=$HOSTNAME; + break;; + [Nn]* ) break;; + * ) echo "Please answer yes[y] or no[n]";; + esac + done fi echo "Please enter new Commotion profile name: " @@ -70,14 +73,10 @@ uci set network.$MESH_NAME.class=mesh uci set network.$MESH_NAME.profile=$MESH_NAME uci set network.$MESH_NAME.proto=commotion -# set hostname - - # set firewall - # commit profile changes commotion save $PROFILE_NAME @@ -90,6 +89,17 @@ uci commit system < Date: Fri, 6 Jun 2014 14:54:27 -0400 Subject: [PATCH 18/63] added firewall and network configurations --- default-files/usr/bin/setupwizard | 76 +++++++++++++++++++++++++------ 1 file changed, 63 insertions(+), 13 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index f9686c2..2184a81 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -1,4 +1,5 @@ #!/bin/ash +. /lib/functions.sh echo -e "\n\nWelcome to the configuration wizard.\n" @@ -47,23 +48,25 @@ WIRELESS_CONFIG=`uci add wireless wifi-iface` uci rename wireless.$WIRELESS_CONFIG=commotionMesh echo "Does this mesh network use encryption?" - read answer - case $answer in - [Yy]* ) echo "Please choose an encryption password: "; - read MESH_PASSWORD; - commotion set $PROFILE_NAME key $MESH_PASSWORD; - uci set wireless.commotionMesh.encryption=psk2; - uci set wireless.commotionMesh.key=$MESH_PASSWORD; - break;; - - [Nn]* ) break;; - * ) echo "Please answer yes[y] or no[n]";; - esac - + while true; do + read answer + case $answer in + [Yy]* ) echo "Please choose an encryption password: "; + read MESH_PASSWORD; + commotion set $PROFILE_NAME key $MESH_PASSWORD; + uci set wireless.commotionMesh.encryption=psk2; + uci set wireless.commotionMesh.key=$MESH_PASSWORD; + break;; + [Nn]* ) break;; + * ) echo "Please answer yes[y] or no[n]";; + esac + done + # set wireless config uci set wireless.commotionMesh.mode=adhoc uci set wireless.commotionMesh.device=radio0 uci set wireless.commotionMesh.ssid=$MESH_NAME +uci set wireless.commotionMesh.network=$MESH_NAME uci set wireless.radio0.channel=$MESH_CHANNEL uci set wireless.radio0.disabled=0 @@ -74,9 +77,17 @@ uci set network.$MESH_NAME.profile=$MESH_NAME uci set network.$MESH_NAME.proto=commotion # set firewall +uci add_list firewall.@zone[1].network=$MESH_NAME + + + + +# may have to set network in wireless (equal to $MESH_NAME) + + # commit profile changes commotion save $PROFILE_NAME @@ -84,7 +95,10 @@ commotion save $PROFILE_NAME uci commit wireless uci commit network uci commit system +uci commit firewall +# restart networking +/etc/init.d/network restart < Date: Fri, 6 Jun 2014 14:55:27 -0400 Subject: [PATCH 19/63] fixed typo --- default-files/usr/bin/setupwizard | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 2184a81..1a1e7ad 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -25,16 +25,12 @@ if [ !`grep -q \'commotion\' /etc/config/system` ]; then done fi -echo "Please enter new Commotion profile name: " - -read PROFILE_NAME - -commotion new $PROFILE_NAME - echo "Please enter mesh network name: " read MESH_NAME +commotion new $MESH_NAME + echo "Please select a valid channel: " read MESH_CHANNEL @@ -89,7 +85,7 @@ uci add_list firewall.@zone[1].network=$MESH_NAME # commit profile changes -commotion save $PROFILE_NAME +commotion save $MESH_NAME # commit uci changes uci commit wireless From 92c2602c648b9ad586c3dd75831373d85930d57b Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Fri, 6 Jun 2014 14:56:10 -0400 Subject: [PATCH 20/63] added commotiond restart --- default-files/usr/bin/setupwizard | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 1a1e7ad..ce6e39f 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -94,7 +94,8 @@ uci commit system uci commit firewall # restart networking -/etc/init.d/network restart +/etc/init.d/commotiond restart +/etc/init.d/network reload < Date: Fri, 6 Jun 2014 15:05:21 -0400 Subject: [PATCH 21/63] fixed broken profile calls. Profiles now saved under mesh network name --- default-files/usr/bin/setupwizard | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index ce6e39f..9fa54df 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -35,9 +35,9 @@ echo "Please select a valid channel: " read MESH_CHANNEL -commotion set $PROFILE_NAME ssid $MESH_NAME +commotion set $MESH_NAME ssid $MESH_NAME -commotion set $PROFILE_NAME channel $MESH_CHANNEL +commotion set $MESH_NAME channel $MESH_CHANNEL # write changes to uci WIRELESS_CONFIG=`uci add wireless wifi-iface` @@ -49,7 +49,7 @@ echo "Does this mesh network use encryption?" case $answer in [Yy]* ) echo "Please choose an encryption password: "; read MESH_PASSWORD; - commotion set $PROFILE_NAME key $MESH_PASSWORD; + commotion set $MESH_NAME key $MESH_PASSWORD; uci set wireless.commotionMesh.encryption=psk2; uci set wireless.commotionMesh.key=$MESH_PASSWORD; break;; @@ -75,15 +75,6 @@ uci set network.$MESH_NAME.proto=commotion # set firewall uci add_list firewall.@zone[1].network=$MESH_NAME - - - - - - -# may have to set network in wireless (equal to $MESH_NAME) - - # commit profile changes commotion save $MESH_NAME From 244a690ca1cdd630230547d905d36b7ddd379723 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Fri, 6 Jun 2014 15:10:26 -0400 Subject: [PATCH 22/63] added encryption 'none' field when no encryption used --- default-files/usr/bin/setupwizard | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 9fa54df..06cbd24 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -53,7 +53,9 @@ echo "Does this mesh network use encryption?" uci set wireless.commotionMesh.encryption=psk2; uci set wireless.commotionMesh.key=$MESH_PASSWORD; break;; - [Nn]* ) break;; + [Nn]* ) + uci set wireless.commotionMesh.key=none + break;; * ) echo "Please answer yes[y] or no[n]";; esac done @@ -84,6 +86,8 @@ uci commit network uci commit system uci commit firewall +echo -e "\n\nSettings saved. Restarting networking.\n\n" + # restart networking /etc/init.d/commotiond restart /etc/init.d/network reload From 827afd347d4440bea44e96cb207d26e36dc0ff7c Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Fri, 6 Jun 2014 15:16:00 -0400 Subject: [PATCH 23/63] changed MESH_CHANNEL to CHANNEL since channels must match --- default-files/usr/bin/setupwizard | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 06cbd24..9365e36 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -33,11 +33,11 @@ commotion new $MESH_NAME echo "Please select a valid channel: " -read MESH_CHANNEL +read CHANNEL commotion set $MESH_NAME ssid $MESH_NAME -commotion set $MESH_NAME channel $MESH_CHANNEL +commotion set $MESH_NAME channel $CHANNEL # write changes to uci WIRELESS_CONFIG=`uci add wireless wifi-iface` @@ -60,12 +60,15 @@ echo "Does this mesh network use encryption?" esac done + +# SET UCI VALUES + # set wireless config uci set wireless.commotionMesh.mode=adhoc uci set wireless.commotionMesh.device=radio0 uci set wireless.commotionMesh.ssid=$MESH_NAME uci set wireless.commotionMesh.network=$MESH_NAME -uci set wireless.radio0.channel=$MESH_CHANNEL +uci set wireless.radio0.channel=$CHANNEL uci set wireless.radio0.disabled=0 # set network config @@ -77,6 +80,12 @@ uci set network.$MESH_NAME.proto=commotion # set firewall uci add_list firewall.@zone[1].network=$MESH_NAME + + +# SET COMMOTION PROFILE VALUES +commotion set channel $CHANNEL + + # commit profile changes commotion save $MESH_NAME From 6ca68e70c71875a4dd4ade5ad1089f4eb2a2b35f Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Fri, 6 Jun 2014 15:23:48 -0400 Subject: [PATCH 24/63] changed encryption entry for no encryption --- default-files/usr/bin/setupwizard | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 9365e36..f06df0c 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -54,7 +54,7 @@ echo "Does this mesh network use encryption?" uci set wireless.commotionMesh.key=$MESH_PASSWORD; break;; [Nn]* ) - uci set wireless.commotionMesh.key=none + uci set wireless.commotionMesh.encryption=none break;; * ) echo "Please answer yes[y] or no[n]";; esac @@ -81,9 +81,9 @@ uci set network.$MESH_NAME.proto=commotion uci add_list firewall.@zone[1].network=$MESH_NAME - # SET COMMOTION PROFILE VALUES commotion set channel $CHANNEL +commotion set ssid $MESH_SSID # commit profile changes @@ -102,6 +102,10 @@ echo -e "\n\nSettings saved. Restarting networking.\n\n" /etc/init.d/network reload + + + + < Date: Mon, 9 Jun 2014 16:42:16 -0400 Subject: [PATCH 25/63] refactored and added access point configuration --- default-files/usr/bin/setupwizard | 135 ++++++++++++++---------------- 1 file changed, 63 insertions(+), 72 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index f06df0c..d8ccead 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -29,41 +29,30 @@ echo "Please enter mesh network name: " read MESH_NAME -commotion new $MESH_NAME - echo "Please select a valid channel: " read CHANNEL -commotion set $MESH_NAME ssid $MESH_NAME - -commotion set $MESH_NAME channel $CHANNEL - -# write changes to uci -WIRELESS_CONFIG=`uci add wireless wifi-iface` -uci rename wireless.$WIRELESS_CONFIG=commotionMesh - echo "Does this mesh network use encryption?" while true; do read answer case $answer in [Yy]* ) echo "Please choose an encryption password: "; read MESH_PASSWORD; - commotion set $MESH_NAME key $MESH_PASSWORD; - uci set wireless.commotionMesh.encryption=psk2; - uci set wireless.commotionMesh.key=$MESH_PASSWORD; break;; [Nn]* ) - uci set wireless.commotionMesh.encryption=none break;; * ) echo "Please answer yes[y] or no[n]";; esac done -# SET UCI VALUES - -# set wireless config +# SET MESH UCI VALUES + +# wireless settings +MESH_CONFIG=`uci add wireless wifi-iface` +uci rename wireless.$MESH_CONFIG=commotionMesh + uci set wireless.commotionMesh.mode=adhoc uci set wireless.commotionMesh.device=radio0 uci set wireless.commotionMesh.ssid=$MESH_NAME @@ -71,88 +60,92 @@ uci set wireless.commotionMesh.network=$MESH_NAME uci set wireless.radio0.channel=$CHANNEL uci set wireless.radio0.disabled=0 -# set network config +# network settings uci set network.$MESH_NAME=interface uci set network.$MESH_NAME.class=mesh uci set network.$MESH_NAME.profile=$MESH_NAME uci set network.$MESH_NAME.proto=commotion -# set firewall +# firewall settings uci add_list firewall.@zone[1].network=$MESH_NAME # SET COMMOTION PROFILE VALUES -commotion set channel $CHANNEL -commotion set ssid $MESH_SSID - - -# commit profile changes -commotion save $MESH_NAME - -# commit uci changes -uci commit wireless -uci commit network -uci commit system -uci commit firewall - -echo -e "\n\nSettings saved. Restarting networking.\n\n" - -# restart networking -/etc/init.d/commotiond restart -/etc/init.d/network reload - +commotion new $MESH_NAME +commotion set $MESH_NAME ssid $MESH_NAME +commotion set $MESH_NAME channel $CHANNEL +# SET ENCRYPTION (if any) +if [ $MESH_PASSWORD ]; then + commotion set $MESH_NAME key $MESH_PASSWORD; + uci set wireless.commotionMesh.encryption=psk2; + uci set wireless.commotionMesh.key=$MESH_PASSWORD; +else + commotion set $MESH_NAME encryption none + uci set wireless.commotionMesh.encryption=none +fi -< Date: Tue, 10 Jun 2014 11:35:44 -0400 Subject: [PATCH 26/63] added setup_wizard file to indicate that setupwizard has already been run --- default-files/usr/bin/setupwizard | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index d8ccead..78b5b73 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -1,6 +1,23 @@ #!/bin/ash . /lib/functions.sh +# check to see if setupwizard has already been run + +# if setup_wizard file does not exist, create it +if [[ ! -f /etc/config/setup_wizard]]; then + touch /etc/config/setup_wizard + + # indicator for whether setup wizard has already run + SETUP_RUN=`uci add setup_wizard settings` + uci rename setup_wizard.$SETUP_RUN=settings + uci set setup_wizard.settings.enabled=1 + + # indicator for whether password has been set + PASSWORD_SET='uci add setup_wizard uci` + uci rename setup_wizard.$PASSWORD_SET=passwords + uci set setup_wizard.passwords.admin_pass=true +fi + echo -e "\n\nWelcome to the configuration wizard.\n" # if password not set, require password set From 9a54b654675a20cc7f50992f569e13017fd64481 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 10 Jun 2014 14:56:01 -0400 Subject: [PATCH 27/63] configuration changes now reflected in setup_wizard config --- default-files/usr/bin/setupwizard | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 78b5b73..79cce99 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -15,7 +15,7 @@ if [[ ! -f /etc/config/setup_wizard]]; then # indicator for whether password has been set PASSWORD_SET='uci add setup_wizard uci` uci rename setup_wizard.$PASSWORD_SET=passwords - uci set setup_wizard.passwords.admin_pass=true + uci set setup_wizard.passwords.admin_pass=false fi echo -e "\n\nWelcome to the configuration wizard.\n" @@ -24,6 +24,7 @@ echo -e "\n\nWelcome to the configuration wizard.\n" if [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ]; then echo "Please choose an administrator password: " passwd + uci set setup_wizard.admin_pass=true fi # if hostname not changed, allow option to set hostname @@ -149,6 +150,9 @@ if [ $AP_NAME ]; then fi +# mark changes in setup_wizard config +uci set setup_wizard.settings.enabled=0 + # commit profile changes commotion save $MESH_NAME From c4db0b50f3cdfb7d5ac285ceb9be865d9de96c3b Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 10 Jun 2014 15:21:34 -0400 Subject: [PATCH 28/63] fixed typo --- default-files/usr/bin/setupwizard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 79cce99..f5f13e6 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -13,7 +13,7 @@ if [[ ! -f /etc/config/setup_wizard]]; then uci set setup_wizard.settings.enabled=1 # indicator for whether password has been set - PASSWORD_SET='uci add setup_wizard uci` + PASSWORD_SET=`uci add setup_wizard uci` uci rename setup_wizard.$PASSWORD_SET=passwords uci set setup_wizard.passwords.admin_pass=false fi From c54d2a5842f154246263fad688ff982aae3cd7fd Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 10 Jun 2014 15:25:26 -0400 Subject: [PATCH 29/63] fixed setup_wizard uci calls --- default-files/usr/bin/setupwizard | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index f5f13e6..d1d609b 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -24,7 +24,7 @@ echo -e "\n\nWelcome to the configuration wizard.\n" if [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ]; then echo "Please choose an administrator password: " passwd - uci set setup_wizard.admin_pass=true + uci set setup_wizard.passwords.admin_pass=true fi # if hostname not changed, allow option to set hostname @@ -152,6 +152,7 @@ fi # mark changes in setup_wizard config uci set setup_wizard.settings.enabled=0 +uci commit setup_wizard # commit profile changes commotion save $MESH_NAME From 64abf25c0ee10c00bc2f360afb9d0c7f72983126 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 10 Jun 2014 15:33:47 -0400 Subject: [PATCH 30/63] fixed typo --- default-files/usr/bin/setupwizard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index d1d609b..32cd86b 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -4,7 +4,7 @@ # check to see if setupwizard has already been run # if setup_wizard file does not exist, create it -if [[ ! -f /etc/config/setup_wizard]]; then +if [[ ! -f /etc/config/setup_wizard ]]; then touch /etc/config/setup_wizard # indicator for whether setup wizard has already run From c7ede163378b52c80d4cf8194ef5f1c71a2fbc80 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 10 Jun 2014 15:48:21 -0400 Subject: [PATCH 31/63] changed password from 'true' to 'changed' to conform with gui setupwizard --- default-files/usr/bin/setupwizard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 32cd86b..bfd2c56 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -24,7 +24,7 @@ echo -e "\n\nWelcome to the configuration wizard.\n" if [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ]; then echo "Please choose an administrator password: " passwd - uci set setup_wizard.passwords.admin_pass=true + uci set setup_wizard.passwords.admin_pass=changed fi # if hostname not changed, allow option to set hostname From a955178359fc431444409ad9e6656d5b6ef04e39 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 10 Jun 2014 16:27:42 -0400 Subject: [PATCH 32/63] renamed setupwizard to setupwizard.sh --- .../usr/bin/{setupwizard => setupwizard.sh} | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) rename default-files/usr/bin/{setupwizard => setupwizard.sh} (93%) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard.sh similarity index 93% rename from default-files/usr/bin/setupwizard rename to default-files/usr/bin/setupwizard.sh index bfd2c56..008cefa 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard.sh @@ -147,7 +147,6 @@ if [ $AP_NAME ]; then else uci set wireless.$AP_NAME.encryption=none fi - fi # mark changes in setup_wizard config @@ -163,7 +162,29 @@ uci commit network uci commit system uci commit firewall -echo -e "\n\nSettings saved. Restarting networking.\n\n" +echo -e "\n\nSettings saved." + +echo -e "\n\nCONFIGURATION + +NODE SETTINGS +Hostname: $HOSTNAME + +MESH SETTINGS +Mesh name: $MESH_NAME +Mesh channel: $CHANNEL +`if [ $MESH_PASSWORD ]; then + echo -e +"Mesh encryption: yes" +else + echo -e +"Mesh encryption: no" +fi` + +ACCESS POINT SETTINGS" + +echo -e "\n\nKeep this configuration?\n\n" + +echo -e "\n\nRestarting networking.\n\n" # restart networking /etc/init.d/commotiond restart From f041b8db23049d55de2284f6f7a5b90eff847ea4 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 10 Jun 2014 16:29:48 -0400 Subject: [PATCH 33/63] fixed output for settings review --- default-files/usr/bin/setupwizard.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index 008cefa..1121256 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -173,14 +173,14 @@ MESH SETTINGS Mesh name: $MESH_NAME Mesh channel: $CHANNEL `if [ $MESH_PASSWORD ]; then - echo -e -"Mesh encryption: yes" + echo -e "Mesh encryption: yes" else - echo -e -"Mesh encryption: no" + echo -e "Mesh encryption: no" fi` -ACCESS POINT SETTINGS" +`fi [ $AP_NAME ]; then + + ACCESS POINT SETTINGS" echo -e "\n\nKeep this configuration?\n\n" From c872e03d218869fe77758c030feba6749feb19c5 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Wed, 11 Jun 2014 10:56:32 -0400 Subject: [PATCH 34/63] added reset option prompt --- default-files/usr/bin/setupwizard.sh | 46 ++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index 1121256..e9ecd88 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -167,24 +167,50 @@ echo -e "\n\nSettings saved." echo -e "\n\nCONFIGURATION NODE SETTINGS -Hostname: $HOSTNAME +Hostname: $HOSTNAME + MESH SETTINGS -Mesh name: $MESH_NAME -Mesh channel: $CHANNEL -`if [ $MESH_PASSWORD ]; then - echo -e "Mesh encryption: yes" +SSID: $MESH_NAME +Channel: $CHANNEL" +if [ $MESH_PASSWORD ]; then + echo -e "Encryption: yes +Password: $MESH_PASSWORD" else - echo -e "Mesh encryption: no" -fi` + echo -e "Encryption: no" +fi -`fi [ $AP_NAME ]; then +if [ $AP_NAME ]; then - ACCESS POINT SETTINGS" +echo -e "\n +ACCESS POINT SETTINGS +SSID: $AP_NAME +Channel: $CHANNEL" +fi + +if [ $AP_PASSWORD ]; then + echo -e "Encryption: yes +Password: $AP_PASSWORD" +else + echo -e "Encryption: no" +fi +while true; do echo -e "\n\nKeep this configuration?\n\n" + read answer + case $answer in + [Yy]* ) break;; + [Nn]* ) echo "Reverting configuration settings."; + # Reset button + + break;; + * ) echo "Please answer yes[y] or no[n]";; + esac + done + + -echo -e "\n\nRestarting networking.\n\n" +echo -e "\n\nSetup Wizard completed. Restarting networking.\n\n" # restart networking /etc/init.d/commotiond restart From e7a5a6ffdc0b345def1e2f8870faccce153947b5 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Wed, 11 Jun 2014 14:31:25 -0400 Subject: [PATCH 35/63] refactored script into get and set functions --- default-files/usr/bin/setupwizard.sh | 180 ++++++++++++++++----------- 1 file changed, 105 insertions(+), 75 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index e9ecd88..c0fa476 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -1,8 +1,19 @@ #!/bin/ash -. /lib/functions.sh # check to see if setupwizard has already been run +clear_values() { + #SETUP_RUN + #PASSWORD_SET + unset HOSTNAME + unset MESH_NAME + unset CHANNEL + unset MESH_PASSWORD + unset AP_NAME + unset AP_PASSWORD +} + +get_config() { # if setup_wizard file does not exist, create it if [[ ! -f /etc/config/setup_wizard ]]; then touch /etc/config/setup_wizard @@ -35,7 +46,7 @@ if [ !`grep -q \'commotion\' /etc/config/system` ]; then case $answer in [Yy]* ) echo "Enter new hostname: "; read HOSTNAME; - uci set system.@system[0].hostname=$HOSTNAME; + uci set system.@system[0].hostname="$HOSTNAME"; break;; [Nn]* ) break;; * ) echo "Please answer yes[y] or no[n]";; @@ -65,6 +76,83 @@ echo "Does this mesh network use encryption?" done +# ACCESS POINT + +echo -e "Set up an access point?" + while true; do + read answer + case $answer in + [Yy]* ) echo -e "\nAccess point name: "; + read AP_NAME; + break;; + [Nn]* ) break;; + * ) echo "Please answer yes[y] or no[n]";; + esac +done + +if [ $AP_NAME ]; then + + # access point encryption + echo "Would you like to use encryption for the access point?" + read answer + case $answer in + [Yy]* ) echo "Please choose an encryption password for the AP: "; + read AP_PASSWORD; + break;; + [Nn]* ) break;; + * ) echo "Please answer yes[y] or no[n]";; + esac +fi + +echo -e "\n\nCONFIGURATION + +NODE SETTINGS +Hostname: $HOSTNAME + + +MESH SETTINGS +SSID: $MESH_NAME +Channel: $CHANNEL" +if [ $MESH_PASSWORD ]; then + echo -e "Encryption: yes +Password: $MESH_PASSWORD" +else + echo -e "Encryption: no" +fi + +if [ $AP_NAME ]; then + +echo -e "\n +ACCESS POINT SETTINGS +SSID: $AP_NAME +Channel: $CHANNEL" +fi + +if [ $AP_PASSWORD ]; then + echo -e "Encryption: yes +Password: $AP_PASSWORD" +else + echo -e "Encryption: no" +fi + +while true; do +echo -e "\n\nKeep this configuration?\n\n" + read answer + case $answer in + [Yy]* ) exit 0;; + #break;; + [Nn]* ) echo "Reverting configuration settings."; + clear_values; + exit 1;; + #break;; + * ) echo "Please answer yes[y] or no[n]";; + esac + done +} + + +set_config() { + # SET MESH UCI VALUES # wireless settings @@ -104,34 +192,11 @@ else commotion set $MESH_NAME encryption none uci set wireless.commotionMesh.encryption=none fi + + - -# ACCESS POINT - -echo -e "Set up an access point?" - read answer - case $answer in - [Yy]* ) echo -e "\nAccess point name: " - read AP_NAME; - break;; - - [Nn]* ) break;; - * ) echo "Please answer yes[y] or no[n]";; - esac - +# SET AP SETTINGS if [ $AP_NAME ]; then - - # access point encryption - echo "Would you like to use encryption for the access point?" - read answer - case $answer in - [Yy]* ) echo "Please choose an encryption password for the AP: "; - read AP_PASSWORD; - break;; - [Nn]* ) break;; - * ) echo "Please answer yes[y] or no[n]";; - esac - # set AP uci values AP_CONFIG=`uci add wireless wifi-iface` uci rename wireless.$AP_CONFIG=$AP_NAME @@ -148,6 +213,7 @@ if [ $AP_NAME ]; then uci set wireless.$AP_NAME.encryption=none fi fi + # mark changes in setup_wizard config uci set setup_wizard.settings.enabled=0 @@ -164,58 +230,22 @@ uci commit firewall echo -e "\n\nSettings saved." -echo -e "\n\nCONFIGURATION - -NODE SETTINGS -Hostname: $HOSTNAME - - -MESH SETTINGS -SSID: $MESH_NAME -Channel: $CHANNEL" -if [ $MESH_PASSWORD ]; then - echo -e "Encryption: yes -Password: $MESH_PASSWORD" -else - echo -e "Encryption: no" -fi - -if [ $AP_NAME ]; then - -echo -e "\n -ACCESS POINT SETTINGS -SSID: $AP_NAME -Channel: $CHANNEL" -fi - -if [ $AP_PASSWORD ]; then - echo -e "Encryption: yes -Password: $AP_PASSWORD" -else - echo -e "Encryption: no" -fi - -while true; do -echo -e "\n\nKeep this configuration?\n\n" - read answer - case $answer in - [Yy]* ) break;; - [Nn]* ) echo "Reverting configuration settings."; - # Reset button - - break;; - * ) echo "Please answer yes[y] or no[n]";; - esac - done - - - -echo -e "\n\nSetup Wizard completed. Restarting networking.\n\n" +echo -e "\n\nRestarting networking.\n\n" # restart networking /etc/init.d/commotiond restart /etc/init.d/network reload +} + +# Run setup wizard +get_config +if [ $? -eq 1 ]; then + # didn't keep config + get_config +elif [ $? -wq 0 ]; then + set_config +fi < Date: Wed, 11 Jun 2014 15:54:29 -0400 Subject: [PATCH 36/63] refactored setupwizard to allow multiple runs of get_config --- default-files/usr/bin/setupwizard.sh | 62 +++++++--------------------- 1 file changed, 16 insertions(+), 46 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index c0fa476..f091084 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -11,6 +11,7 @@ clear_values() { unset MESH_PASSWORD unset AP_NAME unset AP_PASSWORD + commotion delete $MESH_NAME } get_config() { @@ -94,6 +95,7 @@ if [ $AP_NAME ]; then # access point encryption echo "Would you like to use encryption for the access point?" + while true; do read answer case $answer in [Yy]* ) echo "Please choose an encryption password for the AP: "; @@ -102,6 +104,7 @@ if [ $AP_NAME ]; then [Nn]* ) break;; * ) echo "Please answer yes[y] or no[n]";; esac + done fi echo -e "\n\nCONFIGURATION @@ -139,11 +142,11 @@ while true; do echo -e "\n\nKeep this configuration?\n\n" read answer case $answer in - [Yy]* ) exit 0;; + [Yy]* ) return 0;; #break;; [Nn]* ) echo "Reverting configuration settings."; clear_values; - exit 1;; + return 1;; #break;; * ) echo "Please answer yes[y] or no[n]";; esac @@ -192,8 +195,7 @@ else commotion set $MESH_NAME encryption none uci set wireless.commotionMesh.encryption=none fi - - + # SET AP SETTINGS if [ $AP_NAME ]; then @@ -237,47 +239,15 @@ echo -e "\n\nRestarting networking.\n\n" /etc/init.d/network reload } -# Run setup wizard -get_config - -if [ $? -eq 1 ]; then - # didn't keep config - get_config -elif [ $? -wq 0 ]; then - set_config -fi - - -< Date: Wed, 11 Jun 2014 16:05:44 -0400 Subject: [PATCH 37/63] added clear variables --- default-files/usr/bin/setupwizard.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index f091084..7d2eb4b 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -3,8 +3,8 @@ # check to see if setupwizard has already been run clear_values() { - #SETUP_RUN - #PASSWORD_SET + unset SETUP_RUN + unset PASSWORD_SET unset HOSTNAME unset MESH_NAME unset CHANNEL From 4fcb0201332c54542b02c10fe02b203524180e43 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Wed, 11 Jun 2014 16:56:53 -0400 Subject: [PATCH 38/63] wrapped variables to prevent code execution --- default-files/usr/bin/setupwizard.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index 7d2eb4b..39649ce 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -139,7 +139,7 @@ else fi while true; do -echo -e "\n\nKeep this configuration?\n\n" +echo -e "\n\nKeep this configuration?" read answer case $answer in [Yy]* ) return 0;; From bed5c81b6f678b6fe9bef2e22384ceab483fa845 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 12 Jun 2014 11:56:26 -0400 Subject: [PATCH 39/63] fixed typo --- default-files/usr/bin/setupwizard.sh | 66 +++++++++++++++------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index 39649ce..401c186 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -2,6 +2,8 @@ # check to see if setupwizard has already been run + + clear_values() { unset SETUP_RUN unset PASSWORD_SET @@ -110,15 +112,15 @@ fi echo -e "\n\nCONFIGURATION NODE SETTINGS -Hostname: $HOSTNAME +Hostname: "$HOSTNAME" MESH SETTINGS -SSID: $MESH_NAME -Channel: $CHANNEL" +SSID: "$MESH_NAME" +Channel: "$CHANNEL"" if [ $MESH_PASSWORD ]; then echo -e "Encryption: yes -Password: $MESH_PASSWORD" +Password: "$MESH_PASSWORD"" else echo -e "Encryption: no" fi @@ -127,13 +129,13 @@ if [ $AP_NAME ]; then echo -e "\n ACCESS POINT SETTINGS -SSID: $AP_NAME -Channel: $CHANNEL" +SSID: "$AP_NAME" +Channel: "$CHANNEL"" fi if [ $AP_PASSWORD ]; then echo -e "Encryption: yes -Password: $AP_PASSWORD" +Password: "$AP_PASSWORD"" else echo -e "Encryption: no" fi @@ -160,39 +162,39 @@ set_config() { # wireless settings MESH_CONFIG=`uci add wireless wifi-iface` -uci rename wireless.$MESH_CONFIG=commotionMesh +uci rename wireless."$MESH_CONFIG"=commotionMesh uci set wireless.commotionMesh.mode=adhoc uci set wireless.commotionMesh.device=radio0 -uci set wireless.commotionMesh.ssid=$MESH_NAME -uci set wireless.commotionMesh.network=$MESH_NAME -uci set wireless.radio0.channel=$CHANNEL +uci set wireless.commotionMesh.ssid="$MESH_NAME" +uci set wireless.commotionMesh.network="$MESH_NAME" +uci set wireless.radio0.channel="$CHANNEL" uci set wireless.radio0.disabled=0 # network settings -uci set network.$MESH_NAME=interface -uci set network.$MESH_NAME.class=mesh -uci set network.$MESH_NAME.profile=$MESH_NAME -uci set network.$MESH_NAME.proto=commotion +uci set network."$MESH_NAME"=interface +uci set network."$MESH_NAME".class=mesh +uci set network."$MESH_NAME".profile="$MESH_NAME" +uci set network."$MESH_NAME".proto=commotion # firewall settings -uci add_list firewall.@zone[1].network=$MESH_NAME +uci add_list firewall.@zone[1].network="$MESH_NAME" # SET COMMOTION PROFILE VALUES -commotion new $MESH_NAME -commotion set $MESH_NAME ssid $MESH_NAME -commotion set $MESH_NAME channel $CHANNEL +commotion new "$MESH_NAME" +commotion set "$MESH_NAME" ssid "$MESH_NAME" +commotion set "$MESH_NAME" channel "$CHANNEL" # SET ENCRYPTION (if any) if [ $MESH_PASSWORD ]; then - commotion set $MESH_NAME key $MESH_PASSWORD; + commotion set "$MESH_NAME" key "$MESH_PASSWORD"; uci set wireless.commotionMesh.encryption=psk2; - uci set wireless.commotionMesh.key=$MESH_PASSWORD; + uci set wireless.commotionMesh.key="$MESH_PASSWORD"; else - commotion set $MESH_NAME encryption none + commotion set "$MESH_NAME" encryption none uci set wireless.commotionMesh.encryption=none fi @@ -201,18 +203,18 @@ fi if [ $AP_NAME ]; then # set AP uci values AP_CONFIG=`uci add wireless wifi-iface` - uci rename wireless.$AP_CONFIG=$AP_NAME + uci rename wireless."$AP_CONFIG"="$AP_NAME" - uci set wireless.$AP_NAME.network=lan - uci set wireless.$AP_NAME.mode=ap - uci set wireless.$AP_NAME.ssid=$AP_NAME - uci set wireless.$AP_NAME.device=radio0 + uci set wireless."$AP_NAME".network=lan + uci set wireless."$AP_NAME".mode=ap + uci set wireless."$AP_NAME".ssid="$AP_NAME" + uci set wireless."$AP_NAME".device=radio0 if [ $AP_PASSWORD ]; then - uci set wireless.$AP_NAME.encryption=psk2; - uci set wireless.$AP_NAME.key=$AP_PASSWORD; + uci set wireless."$AP_NAME".encryption=psk2; + uci set wireless."$AP_NAME".key="$AP_PASSWORD"; else - uci set wireless.$AP_NAME.encryption=none + uci set wireless."$AP_NAME".encryption=none fi fi @@ -222,7 +224,7 @@ uci set setup_wizard.settings.enabled=0 uci commit setup_wizard # commit profile changes -commotion save $MESH_NAME +commotion save "$MESH_NAME" # commit uci changes uci commit wireless @@ -239,6 +241,8 @@ echo -e "\n\nRestarting networking.\n\n" /etc/init.d/network reload } +# Check if settings have already been set + # RUN SETUP WIZARD get_config From c82a1a4e325bfe50ccbf0c2e931bd8a56c893daa Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 12 Jun 2014 12:14:00 -0400 Subject: [PATCH 40/63] added check for whether setup wizard has already been run --- default-files/usr/bin/setupwizard.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index 401c186..b8e13c5 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -241,7 +241,28 @@ echo -e "\n\nRestarting networking.\n\n" /etc/init.d/network reload } -# Check if settings have already been set +# # Check if settings have already been set +# if setup_wizard.settings.enabled=0 +# "Setup Wizard has already run. Set new configuration?" +# -- could also have 'show settings' option +# -- if yes, delete all wi-fi interfaces +# -- run get_config +# -- else, if keep configuration, exit 0 + +if [ `uci get setup_wizard.settings.enabled` == 0 ]; then + echo -e "Setup Wizard has already been run." +while true; do +echo -e "\n\nSet new configuration?" + read answer + case $answer in + [Yy]* ) echo -e "Reverting previous configuration."; + break;; + [Nn]* ) echo "Keeping settings. Closing Setup Wizard."; + exit 0;; + * ) echo "Please answer yes[y] or no[n]";; + esac + done +fi # RUN SETUP WIZARD get_config From 7cc114999363af043df0473064fbb01db08734f3 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 12 Jun 2014 15:50:22 -0400 Subject: [PATCH 41/63] setup wizard now re-runnable --- default-files/usr/bin/setupwizard.sh | 47 +++++++++++++--------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index b8e13c5..b9ab6cd 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -2,7 +2,13 @@ # check to see if setupwizard has already been run - +clear_previous_configuration() { + uci delete wireless.commotionMesh + uci delete wireless.commotionAP + uci delete network.commotionMesh + + uci commit wireless +} clear_values() { unset SETUP_RUN @@ -144,12 +150,10 @@ while true; do echo -e "\n\nKeep this configuration?" read answer case $answer in - [Yy]* ) return 0;; - #break;; + [Yy]* ) return 0;; [Nn]* ) echo "Reverting configuration settings."; clear_values; - return 1;; - #break;; + return 1;; * ) echo "Please answer yes[y] or no[n]";; esac done @@ -172,10 +176,10 @@ uci set wireless.radio0.channel="$CHANNEL" uci set wireless.radio0.disabled=0 # network settings -uci set network."$MESH_NAME"=interface -uci set network."$MESH_NAME".class=mesh -uci set network."$MESH_NAME".profile="$MESH_NAME" -uci set network."$MESH_NAME".proto=commotion +uci set network.commotionMesh=interface +uci set network.commotionMesh.class=mesh +uci set network.commotionMesh.profile="$MESH_NAME" +uci set network.commotionMesh.proto=commotion # firewall settings uci add_list firewall.@zone[1].network="$MESH_NAME" @@ -203,18 +207,18 @@ fi if [ $AP_NAME ]; then # set AP uci values AP_CONFIG=`uci add wireless wifi-iface` - uci rename wireless."$AP_CONFIG"="$AP_NAME" + uci rename wireless."$AP_CONFIG"=commotionAP - uci set wireless."$AP_NAME".network=lan - uci set wireless."$AP_NAME".mode=ap - uci set wireless."$AP_NAME".ssid="$AP_NAME" - uci set wireless."$AP_NAME".device=radio0 + uci set wireless.commotionAP.network=lan + uci set wireless.commotionAP.mode=ap + uci set wireless.commotionAP.ssid="$AP_NAME" + uci set wireless.commotionAP.device=radio0 if [ $AP_PASSWORD ]; then - uci set wireless."$AP_NAME".encryption=psk2; - uci set wireless."$AP_NAME".key="$AP_PASSWORD"; + uci set wireless.commotionAP.encryption=psk2; + uci set wireless.commotionAP.key="$AP_PASSWORD"; else - uci set wireless."$AP_NAME".encryption=none + uci set wireless.commotionAP.encryption=none fi fi @@ -241,14 +245,6 @@ echo -e "\n\nRestarting networking.\n\n" /etc/init.d/network reload } -# # Check if settings have already been set -# if setup_wizard.settings.enabled=0 -# "Setup Wizard has already run. Set new configuration?" -# -- could also have 'show settings' option -# -- if yes, delete all wi-fi interfaces -# -- run get_config -# -- else, if keep configuration, exit 0 - if [ `uci get setup_wizard.settings.enabled` == 0 ]; then echo -e "Setup Wizard has already been run." while true; do @@ -256,6 +252,7 @@ echo -e "\n\nSet new configuration?" read answer case $answer in [Yy]* ) echo -e "Reverting previous configuration."; + clear_previous_configuration; break;; [Nn]* ) echo "Keeping settings. Closing Setup Wizard."; exit 0;; From 4b2c27134314629408e3dd5afb6d13d312608905 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 12 Jun 2014 16:42:07 -0400 Subject: [PATCH 42/63] improved formatting --- default-files/usr/bin/setupwizard.sh | 52 ++++++++++++++-------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index b9ab6cd..735256d 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -1,11 +1,10 @@ #!/bin/ash -# check to see if setupwizard has already been run - clear_previous_configuration() { uci delete wireless.commotionMesh uci delete wireless.commotionAP uci delete network.commotionMesh + # commotion delete $profile uci commit wireless } @@ -38,7 +37,8 @@ if [[ ! -f /etc/config/setup_wizard ]]; then uci set setup_wizard.passwords.admin_pass=false fi -echo -e "\n\nWelcome to the configuration wizard.\n" +# BEGIN USER INTERACTION +echo -e "\n\nWelcome to the Setup Wizard.\n" # if password not set, require password set if [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ]; then @@ -115,35 +115,35 @@ if [ $AP_NAME ]; then done fi -echo -e "\n\nCONFIGURATION + echo -e "\n\nCONFIGURATION -NODE SETTINGS -Hostname: "$HOSTNAME" + NODE SETTINGS + Hostname: "$HOSTNAME" -MESH SETTINGS -SSID: "$MESH_NAME" -Channel: "$CHANNEL"" -if [ $MESH_PASSWORD ]; then - echo -e "Encryption: yes -Password: "$MESH_PASSWORD"" -else - echo -e "Encryption: no" -fi + MESH SETTINGS + SSID: "$MESH_NAME" + Channel: "$CHANNEL"" + if [ $MESH_PASSWORD ]; then + echo -e "Encryption: yes + Password: "$MESH_PASSWORD"" + else + echo -e "Encryption: no" + fi if [ $AP_NAME ]; then + echo -e "\n + ACCESS POINT SETTINGS + SSID: "$AP_NAME" + Channel: "$CHANNEL"" -echo -e "\n -ACCESS POINT SETTINGS -SSID: "$AP_NAME" -Channel: "$CHANNEL"" -fi - -if [ $AP_PASSWORD ]; then - echo -e "Encryption: yes -Password: "$AP_PASSWORD"" -else - echo -e "Encryption: no" + if [ $AP_PASSWORD ]; then + echo -e "Encryption: yes + Password: "$AP_PASSWORD"" + else + echo -e "Encryption: no" + fi + fi while true; do From 5afcb5283db2cbd514a6928fff0b8958fa8f31fc Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 12 Jun 2014 16:44:02 -0400 Subject: [PATCH 43/63] password mismatch now prompts retry --- default-files/usr/bin/setupwizard.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index 735256d..d162dcf 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -41,11 +41,12 @@ fi echo -e "\n\nWelcome to the Setup Wizard.\n" # if password not set, require password set -if [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ]; then +while [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ] +do echo "Please choose an administrator password: " passwd uci set setup_wizard.passwords.admin_pass=changed -fi +done # if hostname not changed, allow option to set hostname if [ !`grep -q \'commotion\' /etc/config/system` ]; then From d7925f7b128167df590e85d68d579588c6c2434d Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 12 Jun 2014 16:52:06 -0400 Subject: [PATCH 44/63] more formatting --- default-files/usr/bin/setupwizard.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index d162dcf..054404d 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -43,7 +43,7 @@ echo -e "\n\nWelcome to the Setup Wizard.\n" # if password not set, require password set while [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ] do - echo "Please choose an administrator password: " + echo -e "\nPlease choose an administrator password: \n" passwd uci set setup_wizard.passwords.admin_pass=changed done @@ -51,7 +51,7 @@ done # if hostname not changed, allow option to set hostname if [ !`grep -q \'commotion\' /etc/config/system` ]; then while true; do - echo -e "Set the hostname for this device?" + echo -e "\n\nSet the hostname for this device?" read answer case $answer in [Yy]* ) echo "Enter new hostname: "; @@ -64,15 +64,15 @@ if [ !`grep -q \'commotion\' /etc/config/system` ]; then done fi -echo "Please enter mesh network name: " +echo -e "\n\nPlease enter mesh network name: " read MESH_NAME -echo "Please select a valid channel: " +echo -e "\n\nPlease select a valid channel: " read CHANNEL -echo "Does this mesh network use encryption?" +echo -e "\nDoes this mesh network use encryption?" while true; do read answer case $answer in @@ -88,7 +88,7 @@ echo "Does this mesh network use encryption?" # ACCESS POINT -echo -e "Set up an access point?" +echo -e "\n\nSet up an access point?" while true; do read answer case $answer in @@ -103,11 +103,11 @@ done if [ $AP_NAME ]; then # access point encryption - echo "Would you like to use encryption for the access point?" + echo -e "\n\nWould you like to use encryption for the access point?" while true; do read answer case $answer in - [Yy]* ) echo "Please choose an encryption password for the AP: "; + [Yy]* ) echo -e "\nPlease choose an encryption password for the access point: "; read AP_PASSWORD; break;; [Nn]* ) break;; @@ -126,10 +126,10 @@ fi SSID: "$MESH_NAME" Channel: "$CHANNEL"" if [ $MESH_PASSWORD ]; then - echo -e "Encryption: yes + echo -e " Encryption: yes Password: "$MESH_PASSWORD"" else - echo -e "Encryption: no" + echo -e " Encryption: no" fi if [ $AP_NAME ]; then @@ -139,10 +139,10 @@ if [ $AP_NAME ]; then Channel: "$CHANNEL"" if [ $AP_PASSWORD ]; then - echo -e "Encryption: yes - Password: "$AP_PASSWORD"" + echo -e " Encryption: yes" + echo -e " Password: "$AP_PASSWORD"" else - echo -e "Encryption: no" + echo -e " Encryption: no" fi fi From b2e78ccf0d016c7e6f71ccfe72477940b72bc47a Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 12 Jun 2014 16:52:38 -0400 Subject: [PATCH 45/63] even more formatting --- default-files/usr/bin/setupwizard.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index 054404d..c4901ec 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -126,8 +126,8 @@ fi SSID: "$MESH_NAME" Channel: "$CHANNEL"" if [ $MESH_PASSWORD ]; then - echo -e " Encryption: yes - Password: "$MESH_PASSWORD"" + echo -e " Encryption: yes" + echo -e " Password: "$MESH_PASSWORD"" else echo -e " Encryption: no" fi From 0f097cda9b766ab0524fac659c29f162b6e36c7c Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 12 Jun 2014 17:01:13 -0400 Subject: [PATCH 46/63] MOAR FORMATTING --- default-files/usr/bin/setupwizard.sh | 42 ++++++++++++++++------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index c4901ec..cb10596 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -64,6 +64,8 @@ if [ !`grep -q \'commotion\' /etc/config/system` ]; then done fi + +# GET MESH SETTINGS echo -e "\n\nPlease enter mesh network name: " read MESH_NAME @@ -86,8 +88,7 @@ echo -e "\nDoes this mesh network use encryption?" done -# ACCESS POINT - +# GET ACCESS POINT SETTINGS echo -e "\n\nSet up an access point?" while true; do read answer @@ -103,11 +104,11 @@ done if [ $AP_NAME ]; then # access point encryption - echo -e "\n\nWould you like to use encryption for the access point?" + echo -e "\n\nUse encryption for the access point?" while true; do read answer case $answer in - [Yy]* ) echo -e "\nPlease choose an encryption password for the access point: "; + [Yy]* ) echo -e "\nPlease choose an encryption password: "; read AP_PASSWORD; break;; [Nn]* ) break;; @@ -116,6 +117,7 @@ if [ $AP_NAME ]; then done fi + # DISPLAY PROPOSED CONFIGURATION echo -e "\n\nCONFIGURATION NODE SETTINGS @@ -125,12 +127,13 @@ fi MESH SETTINGS SSID: "$MESH_NAME" Channel: "$CHANNEL"" - if [ $MESH_PASSWORD ]; then - echo -e " Encryption: yes" - echo -e " Password: "$MESH_PASSWORD"" - else - echo -e " Encryption: no" - fi + +if [ $MESH_PASSWORD ]; then + echo -e " Encryption: yes" + echo -e " Password: "$MESH_PASSWORD"" +else + echo -e " Encryption: no" +fi if [ $AP_NAME ]; then echo -e "\n @@ -147,6 +150,7 @@ if [ $AP_NAME ]; then fi +# save or reset configuration while true; do echo -e "\n\nKeep this configuration?" read answer @@ -186,14 +190,12 @@ uci set network.commotionMesh.proto=commotion uci add_list firewall.@zone[1].network="$MESH_NAME" -# SET COMMOTION PROFILE VALUES - +# set Commotion profile settings commotion new "$MESH_NAME" commotion set "$MESH_NAME" ssid "$MESH_NAME" commotion set "$MESH_NAME" channel "$CHANNEL" -# SET ENCRYPTION (if any) - +#set encryption settings if [ $MESH_PASSWORD ]; then commotion set "$MESH_NAME" key "$MESH_PASSWORD"; uci set wireless.commotionMesh.encryption=psk2; @@ -215,6 +217,7 @@ if [ $AP_NAME ]; then uci set wireless.commotionAP.ssid="$AP_NAME" uci set wireless.commotionAP.device=radio0 + # set AP encryption if [ $AP_PASSWORD ]; then uci set wireless.commotionAP.encryption=psk2; uci set wireless.commotionAP.key="$AP_PASSWORD"; @@ -224,11 +227,11 @@ if [ $AP_NAME ]; then fi -# mark changes in setup_wizard config +# mark changes in setup_wizard config file uci set setup_wizard.settings.enabled=0 uci commit setup_wizard -# commit profile changes +# commit Commotion profile changes commotion save "$MESH_NAME" # commit uci changes @@ -246,6 +249,8 @@ echo -e "\n\nRestarting networking.\n\n" /etc/init.d/network reload } + +# SCRIPT BEGINS HERE if [ `uci get setup_wizard.settings.enabled` == 0 ]; then echo -e "Setup Wizard has already been run." while true; do @@ -255,13 +260,14 @@ echo -e "\n\nSet new configuration?" [Yy]* ) echo -e "Reverting previous configuration."; clear_previous_configuration; break;; - [Nn]* ) echo "Keeping settings. Closing Setup Wizard."; + [Nn]* ) echo -e "Keeping settings. Closing Setup Wizard."; exit 0;; * ) echo "Please answer yes[y] or no[n]";; esac done fi + # RUN SETUP WIZARD get_config @@ -270,7 +276,7 @@ while [ $? -eq 1 ]; do get_config done -# if user accepts settings, set the configuration +# if user accepts settings, run set_config if [ $? -eq 0 ]; then set_config fi \ No newline at end of file From affef099d6c21137ae4104a907a60670befb75e7 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Fri, 13 Jun 2014 14:35:02 -0400 Subject: [PATCH 47/63] added input validation for mesh setup --- default-files/usr/bin/setupwizard.sh | 63 ++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index cb10596..a340531 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -1,5 +1,21 @@ #!/bin/ash +validate() { + +string="$1" + +length=${#string} +if [ $length -lt 2 -o $length -gt 63 ] ;then + echo "ERROR: Length invalid." + return 1; +fi + +case $string in + *[^a-zA-Z0-9]* ) echo "ERROR: Cannot assign non-ASCII characters.";return 1;; + * ) return 0;; +esac +} + clear_previous_configuration() { uci delete wireless.commotionMesh uci delete wireless.commotionAP @@ -54,10 +70,15 @@ if [ !`grep -q \'commotion\' /etc/config/system` ]; then echo -e "\n\nSet the hostname for this device?" read answer case $answer in - [Yy]* ) echo "Enter new hostname: "; - read HOSTNAME; - uci set system.@system[0].hostname="$HOSTNAME"; - break;; + [Yy]* ) while true; do + echo "Enter new hostname: "; + read HOSTNAME; + validate $HOSTNAME; + if [ $? == 0 ]; then + uci set system.@system[0].hostname="$HOSTNAME"; + break; + fi + done;; [Nn]* ) break;; * ) echo "Please answer yes[y] or no[n]";; esac @@ -66,21 +87,37 @@ fi # GET MESH SETTINGS -echo -e "\n\nPlease enter mesh network name: " - -read MESH_NAME - -echo -e "\n\nPlease select a valid channel: " +while true; do + echo -e "\n\nPlease enter mesh network name: " + read MESH_NAME + validate $MESH_NAME + if [ $? == 0 ]; then + break; + fi +done -read CHANNEL +while true; do + echo -e "\n\nPlease select a valid channel: " + read CHANNEL + if [ "$CHANNEL" != "0" ] && [ "$CHANNEL" -lt "13" ]; then + break; + else + echo -e "ERROR: Channel must be between 1-12"; + fi +done echo -e "\nDoes this mesh network use encryption?" while true; do read answer case $answer in - [Yy]* ) echo "Please choose an encryption password: "; - read MESH_PASSWORD; - break;; + [Yy]* ) while true; do + echo "Please choose an encryption password: "; + read MESH_PASSWORD; + validate $MESH_PASSWORD; + if [ $? == "0" ]; then + break; + fi + done;; [Nn]* ) break;; * ) echo "Please answer yes[y] or no[n]";; From cd1ae3b303c674eb0d1a5d51faf8169785b270d2 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Fri, 13 Jun 2014 16:00:03 -0400 Subject: [PATCH 48/63] fixed hostname loop --- default-files/usr/bin/setupwizard.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index a340531..ee97443 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -2,17 +2,22 @@ validate() { -string="$1" +INPUT_STRING="$1" +MIN_LENGTH="$2" +MAX_LENGTH="$3" -length=${#string} +length=${#INPUT_STRING} if [ $length -lt 2 -o $length -gt 63 ] ;then echo "ERROR: Length invalid." return 1; fi -case $string in - *[^a-zA-Z0-9]* ) echo "ERROR: Cannot assign non-ASCII characters.";return 1;; - * ) return 0;; +case $INPUT_STRING in + *[^a-zA-Z0-9]* ) + echo "ERROR: Cannot assign non-ASCII characters."; + return 1;; + * ) + return 0;; esac } @@ -78,7 +83,8 @@ if [ !`grep -q \'commotion\' /etc/config/system` ]; then uci set system.@system[0].hostname="$HOSTNAME"; break; fi - done;; + done; + break;; [Nn]* ) break;; * ) echo "Please answer yes[y] or no[n]";; esac From 1ff5dd0b2bdb2fc8c56e52bb33cd91b2428a0e83 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Fri, 13 Jun 2014 16:21:02 -0400 Subject: [PATCH 49/63] refactored validator function --- default-files/usr/bin/setupwizard.sh | 101 ++++++++++++++++----------- 1 file changed, 62 insertions(+), 39 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index ee97443..cc7f7c7 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -1,16 +1,23 @@ #!/bin/ash -validate() { +# PRESET VALUES +SSID_MIN=1 +SSID_MAX=31 +KEY_MIN=8 +KEY_MAX=63 -INPUT_STRING="$1" -MIN_LENGTH="$2" -MAX_LENGTH="$3" -length=${#INPUT_STRING} -if [ $length -lt 2 -o $length -gt 63 ] ;then - echo "ERROR: Length invalid." - return 1; -fi +# INPUT VALIDATOR +validate() { + INPUT_STRING="$1" + MIN_LENGTH="$2" + MAX_LENGTH="$3" + + length=${#INPUT_STRING} + if [ $length -lt $MIN_LENGTH -o $length -gt $MAX_LENGTH ] ;then + echo "ERROR: Length invalid. Value must be between $MIN_LENGTH and $MAX_LENGTH characters." + return 1; + fi case $INPUT_STRING in *[^a-zA-Z0-9]* ) @@ -21,6 +28,7 @@ case $INPUT_STRING in esac } +# RESET FUNCTION (for saved configurations) clear_previous_configuration() { uci delete wireless.commotionMesh uci delete wireless.commotionAP @@ -30,6 +38,7 @@ clear_previous_configuration() { uci commit wireless } +# RESET FUNCTION (for unsaved configurations) clear_values() { unset SETUP_RUN unset PASSWORD_SET @@ -42,7 +51,9 @@ clear_values() { commotion delete $MESH_NAME } +# GET CONFIGURATION VALUES FROM USER get_config() { + # if setup_wizard file does not exist, create it if [[ ! -f /etc/config/setup_wizard ]]; then touch /etc/config/setup_wizard @@ -58,6 +69,7 @@ if [[ ! -f /etc/config/setup_wizard ]]; then uci set setup_wizard.passwords.admin_pass=false fi + # BEGIN USER INTERACTION echo -e "\n\nWelcome to the Setup Wizard.\n" @@ -69,34 +81,33 @@ do uci set setup_wizard.passwords.admin_pass=changed done -# if hostname not changed, allow option to set hostname -if [ !`grep -q \'commotion\' /etc/config/system` ]; then - while true; do - echo -e "\n\nSet the hostname for this device?" - read answer - case $answer in - [Yy]* ) while true; do - echo "Enter new hostname: "; - read HOSTNAME; - validate $HOSTNAME; - if [ $? == 0 ]; then - uci set system.@system[0].hostname="$HOSTNAME"; - break; - fi - done; - break;; - [Nn]* ) break;; - * ) echo "Please answer yes[y] or no[n]";; - esac - done -fi + +while true; do + echo -e "\n\nSet the hostname for this device?" + read answer + case $answer in + [Yy]* ) while true; do + echo "Enter new hostname: "; + read HOSTNAME; + validate $HOSTNAME 2 24; + if [ $? == 0 ]; then + uci set system.@system[0].hostname="$HOSTNAME"; + break; + fi + done; + break;; + [Nn]* ) break;; + * ) echo "Please answer yes[y] or no[n]";; + esac +done + # GET MESH SETTINGS while true; do echo -e "\n\nPlease enter mesh network name: " read MESH_NAME - validate $MESH_NAME + validate $MESH_NAME $SSID_MIN $SSID_MAX if [ $? == 0 ]; then break; fi @@ -119,11 +130,12 @@ echo -e "\nDoes this mesh network use encryption?" [Yy]* ) while true; do echo "Please choose an encryption password: "; read MESH_PASSWORD; - validate $MESH_PASSWORD; + validate $MESH_PASSWORD $KEY_MIN $KEY_MAX; if [ $? == "0" ]; then break; fi - done;; + done; + break;; [Nn]* ) break;; * ) echo "Please answer yes[y] or no[n]";; @@ -136,8 +148,14 @@ echo -e "\n\nSet up an access point?" while true; do read answer case $answer in - [Yy]* ) echo -e "\nAccess point name: "; - read AP_NAME; + [Yy]* ) while true; do + echo -e "\nAccess point name: "; + read AP_NAME; + validate $AP_NAME $SSID_MIN $SSID_MAX; + if [ $? == "0" ]; then + break; + fi + done; break;; [Nn]* ) break;; * ) echo "Please answer yes[y] or no[n]";; @@ -145,15 +163,20 @@ echo -e "\n\nSet up an access point?" done if [ $AP_NAME ]; then - # access point encryption echo -e "\n\nUse encryption for the access point?" while true; do read answer case $answer in - [Yy]* ) echo -e "\nPlease choose an encryption password: "; - read AP_PASSWORD; - break;; + [Yy]* ) while true; do + echo -e "\nPlease choose an encryption password: "; + read AP_PASSWORD; + validate $AP_PASSWORD $SSID_MIN $SSID_MAX; + if [ $? == "0" ]; then + break; + fi + done; + break;; [Nn]* ) break;; * ) echo "Please answer yes[y] or no[n]";; esac From 142f0bdea9570358fda35112d91a5d506a504919 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Fri, 13 Jun 2014 16:28:35 -0400 Subject: [PATCH 50/63] added default channel limits and fixed AP_PASSWORD validation --- default-files/usr/bin/setupwizard.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index cc7f7c7..66bd4d7 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -5,6 +5,8 @@ SSID_MIN=1 SSID_MAX=31 KEY_MIN=8 KEY_MAX=63 +CHANNEL_MIN=1 +CHANNEL_MAX=12 # INPUT VALIDATOR @@ -116,10 +118,10 @@ done while true; do echo -e "\n\nPlease select a valid channel: " read CHANNEL - if [ "$CHANNEL" != "0" ] && [ "$CHANNEL" -lt "13" ]; then + if [ "$CHANNEL" -gt "$CHANNEL_MIN" ] && [ "$CHANNEL" -lt "$CHANNEL_MAX" ]; then break; else - echo -e "ERROR: Channel must be between 1-12"; + echo -e "ERROR: Channel must be between $CHANNEL_MIN and $CHANNEL_MAX"; fi done @@ -171,7 +173,7 @@ if [ $AP_NAME ]; then [Yy]* ) while true; do echo -e "\nPlease choose an encryption password: "; read AP_PASSWORD; - validate $AP_PASSWORD $SSID_MIN $SSID_MAX; + validate $AP_PASSWORD $KEY_MIN $KEY_MAX; if [ $? == "0" ]; then break; fi From 502ea846c7a889a7d26a88ade0d1e15dc7627010 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 17 Jun 2014 12:01:54 -0400 Subject: [PATCH 51/63] fixed interface name in /etc/config/network to match gui setup wizard --- default-files/usr/bin/setupwizard.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh index 66bd4d7..648ce90 100755 --- a/default-files/usr/bin/setupwizard.sh +++ b/default-files/usr/bin/setupwizard.sh @@ -249,10 +249,10 @@ uci set wireless.radio0.channel="$CHANNEL" uci set wireless.radio0.disabled=0 # network settings -uci set network.commotionMesh=interface -uci set network.commotionMesh.class=mesh -uci set network.commotionMesh.profile="$MESH_NAME" -uci set network.commotionMesh.proto=commotion +uci set network."$MESH_NAME"=interface +uci set network."$MESH_NAME".class=mesh +uci set network."$MESH_NAME".profile="$MESH_NAME" +uci set network."$MESH_NAME".proto=commotion # firewall settings uci add_list firewall.@zone[1].network="$MESH_NAME" From 22a3c06d5207176e815b1e473077784a10e73a6a Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Wed, 18 Jun 2014 10:34:23 -0400 Subject: [PATCH 52/63] renamed setupwizard.sh to setupwizard --- default-files/usr/bin/setupwizard | 350 ++++++++++++++++++++++++++++++ 1 file changed, 350 insertions(+) create mode 100755 default-files/usr/bin/setupwizard diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard new file mode 100755 index 0000000..648ce90 --- /dev/null +++ b/default-files/usr/bin/setupwizard @@ -0,0 +1,350 @@ +#!/bin/ash + +# PRESET VALUES +SSID_MIN=1 +SSID_MAX=31 +KEY_MIN=8 +KEY_MAX=63 +CHANNEL_MIN=1 +CHANNEL_MAX=12 + + +# INPUT VALIDATOR +validate() { + INPUT_STRING="$1" + MIN_LENGTH="$2" + MAX_LENGTH="$3" + + length=${#INPUT_STRING} + if [ $length -lt $MIN_LENGTH -o $length -gt $MAX_LENGTH ] ;then + echo "ERROR: Length invalid. Value must be between $MIN_LENGTH and $MAX_LENGTH characters." + return 1; + fi + +case $INPUT_STRING in + *[^a-zA-Z0-9]* ) + echo "ERROR: Cannot assign non-ASCII characters."; + return 1;; + * ) + return 0;; +esac +} + +# RESET FUNCTION (for saved configurations) +clear_previous_configuration() { + uci delete wireless.commotionMesh + uci delete wireless.commotionAP + uci delete network.commotionMesh + # commotion delete $profile + + uci commit wireless +} + +# RESET FUNCTION (for unsaved configurations) +clear_values() { + unset SETUP_RUN + unset PASSWORD_SET + unset HOSTNAME + unset MESH_NAME + unset CHANNEL + unset MESH_PASSWORD + unset AP_NAME + unset AP_PASSWORD + commotion delete $MESH_NAME +} + +# GET CONFIGURATION VALUES FROM USER +get_config() { + +# if setup_wizard file does not exist, create it +if [[ ! -f /etc/config/setup_wizard ]]; then + touch /etc/config/setup_wizard + + # indicator for whether setup wizard has already run + SETUP_RUN=`uci add setup_wizard settings` + uci rename setup_wizard.$SETUP_RUN=settings + uci set setup_wizard.settings.enabled=1 + + # indicator for whether password has been set + PASSWORD_SET=`uci add setup_wizard uci` + uci rename setup_wizard.$PASSWORD_SET=passwords + uci set setup_wizard.passwords.admin_pass=false +fi + + +# BEGIN USER INTERACTION +echo -e "\n\nWelcome to the Setup Wizard.\n" + +# if password not set, require password set +while [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ] +do + echo -e "\nPlease choose an administrator password: \n" + passwd + uci set setup_wizard.passwords.admin_pass=changed +done + + +while true; do + echo -e "\n\nSet the hostname for this device?" + read answer + case $answer in + [Yy]* ) while true; do + echo "Enter new hostname: "; + read HOSTNAME; + validate $HOSTNAME 2 24; + if [ $? == 0 ]; then + uci set system.@system[0].hostname="$HOSTNAME"; + break; + fi + done; + break;; + [Nn]* ) break;; + * ) echo "Please answer yes[y] or no[n]";; + esac +done + + + +# GET MESH SETTINGS +while true; do + echo -e "\n\nPlease enter mesh network name: " + read MESH_NAME + validate $MESH_NAME $SSID_MIN $SSID_MAX + if [ $? == 0 ]; then + break; + fi +done + +while true; do + echo -e "\n\nPlease select a valid channel: " + read CHANNEL + if [ "$CHANNEL" -gt "$CHANNEL_MIN" ] && [ "$CHANNEL" -lt "$CHANNEL_MAX" ]; then + break; + else + echo -e "ERROR: Channel must be between $CHANNEL_MIN and $CHANNEL_MAX"; + fi +done + +echo -e "\nDoes this mesh network use encryption?" + while true; do + read answer + case $answer in + [Yy]* ) while true; do + echo "Please choose an encryption password: "; + read MESH_PASSWORD; + validate $MESH_PASSWORD $KEY_MIN $KEY_MAX; + if [ $? == "0" ]; then + break; + fi + done; + break;; + [Nn]* ) + break;; + * ) echo "Please answer yes[y] or no[n]";; + esac + done + + +# GET ACCESS POINT SETTINGS +echo -e "\n\nSet up an access point?" + while true; do + read answer + case $answer in + [Yy]* ) while true; do + echo -e "\nAccess point name: "; + read AP_NAME; + validate $AP_NAME $SSID_MIN $SSID_MAX; + if [ $? == "0" ]; then + break; + fi + done; + break;; + [Nn]* ) break;; + * ) echo "Please answer yes[y] or no[n]";; + esac +done + +if [ $AP_NAME ]; then + # access point encryption + echo -e "\n\nUse encryption for the access point?" + while true; do + read answer + case $answer in + [Yy]* ) while true; do + echo -e "\nPlease choose an encryption password: "; + read AP_PASSWORD; + validate $AP_PASSWORD $KEY_MIN $KEY_MAX; + if [ $? == "0" ]; then + break; + fi + done; + break;; + [Nn]* ) break;; + * ) echo "Please answer yes[y] or no[n]";; + esac + done +fi + + # DISPLAY PROPOSED CONFIGURATION + echo -e "\n\nCONFIGURATION + + NODE SETTINGS + Hostname: "$HOSTNAME" + + + MESH SETTINGS + SSID: "$MESH_NAME" + Channel: "$CHANNEL"" + +if [ $MESH_PASSWORD ]; then + echo -e " Encryption: yes" + echo -e " Password: "$MESH_PASSWORD"" +else + echo -e " Encryption: no" +fi + +if [ $AP_NAME ]; then + echo -e "\n + ACCESS POINT SETTINGS + SSID: "$AP_NAME" + Channel: "$CHANNEL"" + + if [ $AP_PASSWORD ]; then + echo -e " Encryption: yes" + echo -e " Password: "$AP_PASSWORD"" + else + echo -e " Encryption: no" + fi + +fi + +# save or reset configuration +while true; do +echo -e "\n\nKeep this configuration?" + read answer + case $answer in + [Yy]* ) return 0;; + [Nn]* ) echo "Reverting configuration settings."; + clear_values; + return 1;; + * ) echo "Please answer yes[y] or no[n]";; + esac + done +} + + +set_config() { + +# SET MESH UCI VALUES + +# wireless settings +MESH_CONFIG=`uci add wireless wifi-iface` +uci rename wireless."$MESH_CONFIG"=commotionMesh + +uci set wireless.commotionMesh.mode=adhoc +uci set wireless.commotionMesh.device=radio0 +uci set wireless.commotionMesh.ssid="$MESH_NAME" +uci set wireless.commotionMesh.network="$MESH_NAME" +uci set wireless.radio0.channel="$CHANNEL" +uci set wireless.radio0.disabled=0 + +# network settings +uci set network."$MESH_NAME"=interface +uci set network."$MESH_NAME".class=mesh +uci set network."$MESH_NAME".profile="$MESH_NAME" +uci set network."$MESH_NAME".proto=commotion + +# firewall settings +uci add_list firewall.@zone[1].network="$MESH_NAME" + + +# set Commotion profile settings +commotion new "$MESH_NAME" +commotion set "$MESH_NAME" ssid "$MESH_NAME" +commotion set "$MESH_NAME" channel "$CHANNEL" + +#set encryption settings +if [ $MESH_PASSWORD ]; then + commotion set "$MESH_NAME" key "$MESH_PASSWORD"; + uci set wireless.commotionMesh.encryption=psk2; + uci set wireless.commotionMesh.key="$MESH_PASSWORD"; +else + commotion set "$MESH_NAME" encryption none + uci set wireless.commotionMesh.encryption=none +fi + + +# SET AP SETTINGS +if [ $AP_NAME ]; then + # set AP uci values + AP_CONFIG=`uci add wireless wifi-iface` + uci rename wireless."$AP_CONFIG"=commotionAP + + uci set wireless.commotionAP.network=lan + uci set wireless.commotionAP.mode=ap + uci set wireless.commotionAP.ssid="$AP_NAME" + uci set wireless.commotionAP.device=radio0 + + # set AP encryption + if [ $AP_PASSWORD ]; then + uci set wireless.commotionAP.encryption=psk2; + uci set wireless.commotionAP.key="$AP_PASSWORD"; + else + uci set wireless.commotionAP.encryption=none + fi +fi + + +# mark changes in setup_wizard config file +uci set setup_wizard.settings.enabled=0 +uci commit setup_wizard + +# commit Commotion profile changes +commotion save "$MESH_NAME" + +# commit uci changes +uci commit wireless +uci commit network +uci commit system +uci commit firewall + +echo -e "\n\nSettings saved." + +echo -e "\n\nRestarting networking.\n\n" + +# restart networking +/etc/init.d/commotiond restart +/etc/init.d/network reload +} + + +# SCRIPT BEGINS HERE +if [ `uci get setup_wizard.settings.enabled` == 0 ]; then + echo -e "Setup Wizard has already been run." +while true; do +echo -e "\n\nSet new configuration?" + read answer + case $answer in + [Yy]* ) echo -e "Reverting previous configuration."; + clear_previous_configuration; + break;; + [Nn]* ) echo -e "Keeping settings. Closing Setup Wizard."; + exit 0;; + * ) echo "Please answer yes[y] or no[n]";; + esac + done +fi + + +# RUN SETUP WIZARD +get_config + +# if user rejects settings, rerun get_config +while [ $? -eq 1 ]; do + get_config +done + +# if user accepts settings, run set_config +if [ $? -eq 0 ]; then + set_config +fi \ No newline at end of file From 832b3e8c8afa5aa300b0c4934067f908694b48e4 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 1 Jul 2014 11:47:51 -0400 Subject: [PATCH 53/63] fixed bug allowing users to input empty config values --- default-files/usr/bin/setupwizard | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 648ce90..2bc7389 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -11,12 +11,19 @@ CHANNEL_MAX=12 # INPUT VALIDATOR validate() { + + # check that user has not input empty string + if [ -z "$3" ]; then + echo "Invalid option." + return 1; + fi + INPUT_STRING="$1" MIN_LENGTH="$2" MAX_LENGTH="$3" - + length=${#INPUT_STRING} - if [ $length -lt $MIN_LENGTH -o $length -gt $MAX_LENGTH ] ;then + if [ $length -lt $MIN_LENGTH -o $length -gt $MAX_LENGTH ]; then echo "ERROR: Length invalid. Value must be between $MIN_LENGTH and $MAX_LENGTH characters." return 1; fi From adfa48b412834c6f752b58fdef36c3dcd01b3ba8 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 1 Jul 2014 11:56:23 -0400 Subject: [PATCH 54/63] added [y/n] answer prompts and added hostname min and max values --- default-files/usr/bin/setupwizard | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 2bc7389..6506b2c 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -7,7 +7,8 @@ KEY_MIN=8 KEY_MAX=63 CHANNEL_MIN=1 CHANNEL_MAX=12 - +HOSTNAME_MIN=2 +HOSTNAME_MAX=24 # INPUT VALIDATOR validate() { @@ -92,13 +93,13 @@ done while true; do - echo -e "\n\nSet the hostname for this device?" + echo -e "\n\nSet the hostname for this device? [y/n]" read answer case $answer in [Yy]* ) while true; do echo "Enter new hostname: "; read HOSTNAME; - validate $HOSTNAME 2 24; + validate $HOSTNAME $HOSTNAME_MIN $HOSTNAME_MAX; if [ $? == 0 ]; then uci set system.@system[0].hostname="$HOSTNAME"; break; @@ -132,7 +133,7 @@ while true; do fi done -echo -e "\nDoes this mesh network use encryption?" +echo -e "\nSet mesh network use encryption? [y/n]" while true; do read answer case $answer in @@ -153,7 +154,7 @@ echo -e "\nDoes this mesh network use encryption?" # GET ACCESS POINT SETTINGS -echo -e "\n\nSet up an access point?" +echo -e "\n\nSet up an access point? [y/n]" while true; do read answer case $answer in @@ -173,7 +174,7 @@ done if [ $AP_NAME ]; then # access point encryption - echo -e "\n\nUse encryption for the access point?" + echo -e "\n\nSet encryption for the access point? [y/n]" while true; do read answer case $answer in @@ -227,7 +228,7 @@ fi # save or reset configuration while true; do -echo -e "\n\nKeep this configuration?" +echo -e "\n\nKeep this configuration? [y/n]" read answer case $answer in [Yy]* ) return 0;; @@ -329,7 +330,7 @@ echo -e "\n\nRestarting networking.\n\n" if [ `uci get setup_wizard.settings.enabled` == 0 ]; then echo -e "Setup Wizard has already been run." while true; do -echo -e "\n\nSet new configuration?" +echo -e "\n\nSet new configuration? [y/n]" read answer case $answer in [Yy]* ) echo -e "Reverting previous configuration."; From a60eec959b8f1795fd2114b765916c9bca181ad6 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 1 Jul 2014 13:50:44 -0400 Subject: [PATCH 55/63] added password verification --- default-files/usr/bin/setupwizard | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 6506b2c..2c3ee58 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -138,11 +138,17 @@ echo -e "\nSet mesh network use encryption? [y/n]" read answer case $answer in [Yy]* ) while true; do - echo "Please choose an encryption password: "; - read MESH_PASSWORD; + echo -e "\nPlease choose an encryption password: "; + read -s MESH_PASSWORD; validate $MESH_PASSWORD $KEY_MIN $KEY_MAX; if [ $? == "0" ]; then - break; + echo "Repeat password: "; + read -s MESH_CONFIRM; + if [ "$MESH_PASSWORD" == "$MESH_CONFIRM" ]; then + break; + else + echo -e "Passwords do not match."; + fi fi done; break;; @@ -180,13 +186,19 @@ if [ $AP_NAME ]; then case $answer in [Yy]* ) while true; do echo -e "\nPlease choose an encryption password: "; - read AP_PASSWORD; + read -s AP_PASSWORD; validate $AP_PASSWORD $KEY_MIN $KEY_MAX; if [ $? == "0" ]; then - break; + echo "Repeat password: "; + read -s AP_CONFIRM; + if [ "$AP_PASSWORD" == "$AP_CONFIRM" ]; then + break; + else + echo -e "Passwords do not match.\n"; + fi fi done; - break;; + break;; [Nn]* ) break;; * ) echo "Please answer yes[y] or no[n]";; esac @@ -206,7 +218,7 @@ fi if [ $MESH_PASSWORD ]; then echo -e " Encryption: yes" - echo -e " Password: "$MESH_PASSWORD"" +# echo -e " Password: "$MESH_PASSWORD"" else echo -e " Encryption: no" fi @@ -219,7 +231,7 @@ if [ $AP_NAME ]; then if [ $AP_PASSWORD ]; then echo -e " Encryption: yes" - echo -e " Password: "$AP_PASSWORD"" +# echo -e " Password: "$AP_PASSWORD"" else echo -e " Encryption: no" fi @@ -323,6 +335,9 @@ echo -e "\n\nRestarting networking.\n\n" # restart networking /etc/init.d/commotiond restart /etc/init.d/network reload + +# clear all values (precaution) +clear_values } From 4cebe5b71cc647e725c5f43a11cfe82149426dbb Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 1 Jul 2014 13:52:01 -0400 Subject: [PATCH 56/63] removed validation of hostname to allow non-ascii values --- default-files/usr/bin/setupwizard | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 2c3ee58..96a0600 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -99,11 +99,13 @@ while true; do [Yy]* ) while true; do echo "Enter new hostname: "; read HOSTNAME; - validate $HOSTNAME $HOSTNAME_MIN $HOSTNAME_MAX; - if [ $? == 0 ]; then - uci set system.@system[0].hostname="$HOSTNAME"; - break; - fi + uci set system.@system[0].hostname="$HOSTNAME"; + + #validate $HOSTNAME $HOSTNAME_MIN $HOSTNAME_MAX; + #if [ $? == 0 ]; then + # uci set system.@system[0].hostname="$HOSTNAME"; + # break; + #fi done; break;; [Nn]* ) break;; From bafa974df76c1d2defd795e8197894f632363a55 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 29 Jul 2014 11:13:00 -0400 Subject: [PATCH 57/63] fixed hostname loop --- default-files/usr/bin/setupwizard | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 96a0600..fde5754 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -101,11 +101,11 @@ while true; do read HOSTNAME; uci set system.@system[0].hostname="$HOSTNAME"; - #validate $HOSTNAME $HOSTNAME_MIN $HOSTNAME_MAX; - #if [ $? == 0 ]; then - # uci set system.@system[0].hostname="$HOSTNAME"; - # break; - #fi + validate $HOSTNAME $HOSTNAME_MIN $HOSTNAME_MAX; + if [ $? == 0 ]; then + uci set system.@system[0].hostname="$HOSTNAME"; + break; + fi done; break;; [Nn]* ) break;; From 516b2b231e91387426d63afe8fda364820f9c5d0 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 29 Jul 2014 11:13:18 -0400 Subject: [PATCH 58/63] SSIDs and passwords now allow dashes --- default-files/usr/bin/setupwizard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index fde5754..6efce08 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -30,7 +30,7 @@ validate() { fi case $INPUT_STRING in - *[^a-zA-Z0-9]* ) + *[^a-zA-Z0-9-]* ) echo "ERROR: Cannot assign non-ASCII characters."; return 1;; * ) From 7bd9bf123d9bc942b67599e3890e49e3e5f19cce Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Tue, 29 Jul 2014 15:27:37 -0400 Subject: [PATCH 59/63] removed unncessary files --- default-files/etc/cli | 11 - default-files/usr/bin/setupwizard.sh | 350 --------------------------- 2 files changed, 361 deletions(-) delete mode 100644 default-files/etc/cli delete mode 100755 default-files/usr/bin/setupwizard.sh diff --git a/default-files/etc/cli b/default-files/etc/cli deleted file mode 100644 index 2d6d513..0000000 --- a/default-files/etc/cli +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -<<'COMMENT' - -Plan of Attack: -* Stub out required functions -* Set up 'main' interface -* Set up helper functions - -COMMENT - diff --git a/default-files/usr/bin/setupwizard.sh b/default-files/usr/bin/setupwizard.sh deleted file mode 100755 index 648ce90..0000000 --- a/default-files/usr/bin/setupwizard.sh +++ /dev/null @@ -1,350 +0,0 @@ -#!/bin/ash - -# PRESET VALUES -SSID_MIN=1 -SSID_MAX=31 -KEY_MIN=8 -KEY_MAX=63 -CHANNEL_MIN=1 -CHANNEL_MAX=12 - - -# INPUT VALIDATOR -validate() { - INPUT_STRING="$1" - MIN_LENGTH="$2" - MAX_LENGTH="$3" - - length=${#INPUT_STRING} - if [ $length -lt $MIN_LENGTH -o $length -gt $MAX_LENGTH ] ;then - echo "ERROR: Length invalid. Value must be between $MIN_LENGTH and $MAX_LENGTH characters." - return 1; - fi - -case $INPUT_STRING in - *[^a-zA-Z0-9]* ) - echo "ERROR: Cannot assign non-ASCII characters."; - return 1;; - * ) - return 0;; -esac -} - -# RESET FUNCTION (for saved configurations) -clear_previous_configuration() { - uci delete wireless.commotionMesh - uci delete wireless.commotionAP - uci delete network.commotionMesh - # commotion delete $profile - - uci commit wireless -} - -# RESET FUNCTION (for unsaved configurations) -clear_values() { - unset SETUP_RUN - unset PASSWORD_SET - unset HOSTNAME - unset MESH_NAME - unset CHANNEL - unset MESH_PASSWORD - unset AP_NAME - unset AP_PASSWORD - commotion delete $MESH_NAME -} - -# GET CONFIGURATION VALUES FROM USER -get_config() { - -# if setup_wizard file does not exist, create it -if [[ ! -f /etc/config/setup_wizard ]]; then - touch /etc/config/setup_wizard - - # indicator for whether setup wizard has already run - SETUP_RUN=`uci add setup_wizard settings` - uci rename setup_wizard.$SETUP_RUN=settings - uci set setup_wizard.settings.enabled=1 - - # indicator for whether password has been set - PASSWORD_SET=`uci add setup_wizard uci` - uci rename setup_wizard.$PASSWORD_SET=passwords - uci set setup_wizard.passwords.admin_pass=false -fi - - -# BEGIN USER INTERACTION -echo -e "\n\nWelcome to the Setup Wizard.\n" - -# if password not set, require password set -while [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ] -do - echo -e "\nPlease choose an administrator password: \n" - passwd - uci set setup_wizard.passwords.admin_pass=changed -done - - -while true; do - echo -e "\n\nSet the hostname for this device?" - read answer - case $answer in - [Yy]* ) while true; do - echo "Enter new hostname: "; - read HOSTNAME; - validate $HOSTNAME 2 24; - if [ $? == 0 ]; then - uci set system.@system[0].hostname="$HOSTNAME"; - break; - fi - done; - break;; - [Nn]* ) break;; - * ) echo "Please answer yes[y] or no[n]";; - esac -done - - - -# GET MESH SETTINGS -while true; do - echo -e "\n\nPlease enter mesh network name: " - read MESH_NAME - validate $MESH_NAME $SSID_MIN $SSID_MAX - if [ $? == 0 ]; then - break; - fi -done - -while true; do - echo -e "\n\nPlease select a valid channel: " - read CHANNEL - if [ "$CHANNEL" -gt "$CHANNEL_MIN" ] && [ "$CHANNEL" -lt "$CHANNEL_MAX" ]; then - break; - else - echo -e "ERROR: Channel must be between $CHANNEL_MIN and $CHANNEL_MAX"; - fi -done - -echo -e "\nDoes this mesh network use encryption?" - while true; do - read answer - case $answer in - [Yy]* ) while true; do - echo "Please choose an encryption password: "; - read MESH_PASSWORD; - validate $MESH_PASSWORD $KEY_MIN $KEY_MAX; - if [ $? == "0" ]; then - break; - fi - done; - break;; - [Nn]* ) - break;; - * ) echo "Please answer yes[y] or no[n]";; - esac - done - - -# GET ACCESS POINT SETTINGS -echo -e "\n\nSet up an access point?" - while true; do - read answer - case $answer in - [Yy]* ) while true; do - echo -e "\nAccess point name: "; - read AP_NAME; - validate $AP_NAME $SSID_MIN $SSID_MAX; - if [ $? == "0" ]; then - break; - fi - done; - break;; - [Nn]* ) break;; - * ) echo "Please answer yes[y] or no[n]";; - esac -done - -if [ $AP_NAME ]; then - # access point encryption - echo -e "\n\nUse encryption for the access point?" - while true; do - read answer - case $answer in - [Yy]* ) while true; do - echo -e "\nPlease choose an encryption password: "; - read AP_PASSWORD; - validate $AP_PASSWORD $KEY_MIN $KEY_MAX; - if [ $? == "0" ]; then - break; - fi - done; - break;; - [Nn]* ) break;; - * ) echo "Please answer yes[y] or no[n]";; - esac - done -fi - - # DISPLAY PROPOSED CONFIGURATION - echo -e "\n\nCONFIGURATION - - NODE SETTINGS - Hostname: "$HOSTNAME" - - - MESH SETTINGS - SSID: "$MESH_NAME" - Channel: "$CHANNEL"" - -if [ $MESH_PASSWORD ]; then - echo -e " Encryption: yes" - echo -e " Password: "$MESH_PASSWORD"" -else - echo -e " Encryption: no" -fi - -if [ $AP_NAME ]; then - echo -e "\n - ACCESS POINT SETTINGS - SSID: "$AP_NAME" - Channel: "$CHANNEL"" - - if [ $AP_PASSWORD ]; then - echo -e " Encryption: yes" - echo -e " Password: "$AP_PASSWORD"" - else - echo -e " Encryption: no" - fi - -fi - -# save or reset configuration -while true; do -echo -e "\n\nKeep this configuration?" - read answer - case $answer in - [Yy]* ) return 0;; - [Nn]* ) echo "Reverting configuration settings."; - clear_values; - return 1;; - * ) echo "Please answer yes[y] or no[n]";; - esac - done -} - - -set_config() { - -# SET MESH UCI VALUES - -# wireless settings -MESH_CONFIG=`uci add wireless wifi-iface` -uci rename wireless."$MESH_CONFIG"=commotionMesh - -uci set wireless.commotionMesh.mode=adhoc -uci set wireless.commotionMesh.device=radio0 -uci set wireless.commotionMesh.ssid="$MESH_NAME" -uci set wireless.commotionMesh.network="$MESH_NAME" -uci set wireless.radio0.channel="$CHANNEL" -uci set wireless.radio0.disabled=0 - -# network settings -uci set network."$MESH_NAME"=interface -uci set network."$MESH_NAME".class=mesh -uci set network."$MESH_NAME".profile="$MESH_NAME" -uci set network."$MESH_NAME".proto=commotion - -# firewall settings -uci add_list firewall.@zone[1].network="$MESH_NAME" - - -# set Commotion profile settings -commotion new "$MESH_NAME" -commotion set "$MESH_NAME" ssid "$MESH_NAME" -commotion set "$MESH_NAME" channel "$CHANNEL" - -#set encryption settings -if [ $MESH_PASSWORD ]; then - commotion set "$MESH_NAME" key "$MESH_PASSWORD"; - uci set wireless.commotionMesh.encryption=psk2; - uci set wireless.commotionMesh.key="$MESH_PASSWORD"; -else - commotion set "$MESH_NAME" encryption none - uci set wireless.commotionMesh.encryption=none -fi - - -# SET AP SETTINGS -if [ $AP_NAME ]; then - # set AP uci values - AP_CONFIG=`uci add wireless wifi-iface` - uci rename wireless."$AP_CONFIG"=commotionAP - - uci set wireless.commotionAP.network=lan - uci set wireless.commotionAP.mode=ap - uci set wireless.commotionAP.ssid="$AP_NAME" - uci set wireless.commotionAP.device=radio0 - - # set AP encryption - if [ $AP_PASSWORD ]; then - uci set wireless.commotionAP.encryption=psk2; - uci set wireless.commotionAP.key="$AP_PASSWORD"; - else - uci set wireless.commotionAP.encryption=none - fi -fi - - -# mark changes in setup_wizard config file -uci set setup_wizard.settings.enabled=0 -uci commit setup_wizard - -# commit Commotion profile changes -commotion save "$MESH_NAME" - -# commit uci changes -uci commit wireless -uci commit network -uci commit system -uci commit firewall - -echo -e "\n\nSettings saved." - -echo -e "\n\nRestarting networking.\n\n" - -# restart networking -/etc/init.d/commotiond restart -/etc/init.d/network reload -} - - -# SCRIPT BEGINS HERE -if [ `uci get setup_wizard.settings.enabled` == 0 ]; then - echo -e "Setup Wizard has already been run." -while true; do -echo -e "\n\nSet new configuration?" - read answer - case $answer in - [Yy]* ) echo -e "Reverting previous configuration."; - clear_previous_configuration; - break;; - [Nn]* ) echo -e "Keeping settings. Closing Setup Wizard."; - exit 0;; - * ) echo "Please answer yes[y] or no[n]";; - esac - done -fi - - -# RUN SETUP WIZARD -get_config - -# if user rejects settings, rerun get_config -while [ $? -eq 1 ]; do - get_config -done - -# if user accepts settings, run set_config -if [ $? -eq 0 ]; then - set_config -fi \ No newline at end of file From ad781de5d9311de53bb63b8d664ebd9d0a502033 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Thu, 6 Nov 2014 11:20:21 -0500 Subject: [PATCH 60/63] added multiradio support --- default-files/usr/bin/setupwizard | 703 ++++++++++++++++-------------- 1 file changed, 384 insertions(+), 319 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 6efce08..ee67517 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -1,4 +1,4 @@ -#!/bin/ash +#!/bin/ash # PRESET VALUES SSID_MIN=1 @@ -13,363 +13,428 @@ HOSTNAME_MAX=24 # INPUT VALIDATOR validate() { - # check that user has not input empty string - if [ -z "$3" ]; then - echo "Invalid option." - return 1; - fi - - INPUT_STRING="$1" - MIN_LENGTH="$2" - MAX_LENGTH="$3" - - length=${#INPUT_STRING} - if [ $length -lt $MIN_LENGTH -o $length -gt $MAX_LENGTH ]; then - echo "ERROR: Length invalid. Value must be between $MIN_LENGTH and $MAX_LENGTH characters." - return 1; - fi + # check that user has not input empty string + if [ -z "$3" ]; then + echo "Invalid option." + return 1; + fi + + INPUT_STRING="$1" + MIN_LENGTH="$2" + MAX_LENGTH="$3" + + length=${#INPUT_STRING} + if [ $length -lt $MIN_LENGTH -o $length -gt $MAX_LENGTH ]; then + echo "ERROR: Length invalid. Value must be between $MIN_LENGTH and $MAX_LENGTH characters." + return 1; + fi -case $INPUT_STRING in - *[^a-zA-Z0-9-]* ) - echo "ERROR: Cannot assign non-ASCII characters."; - return 1;; - * ) - return 0;; -esac -} + case $INPUT_STRING in + *[^a-zA-Z0-9-]* ) + echo "ERROR: Cannot assign non-ASCII characters."; + return 1;; + * ) + return 0;; + esac + } # RESET FUNCTION (for saved configurations) clear_previous_configuration() { - uci delete wireless.commotionMesh - uci delete wireless.commotionAP - uci delete network.commotionMesh - # commotion delete $profile - - uci commit wireless + LOOP=0 + while [ $LOOP -lt $NUM_RADIOS ]; do + + uci delete wireless.commotionMesh$LOOP + uci delete wireless.commotionAP$LOOP + uci delete network.commotionMesh$LOOP + + uci commit wireless + + LOOP=$((LOOP+1)) + done } # RESET FUNCTION (for unsaved configurations) clear_values() { - unset SETUP_RUN - unset PASSWORD_SET - unset HOSTNAME - unset MESH_NAME - unset CHANNEL - unset MESH_PASSWORD - unset AP_NAME - unset AP_PASSWORD - commotion delete $MESH_NAME + unset SETUP_RUN + unset PASSWORD_SET + unset HOSTNAME + unset MESH_NAME + unset CHANNEL + unset MESH_PASSWORD + unset AP_NAME + unset AP_PASSWORD } # GET CONFIGURATION VALUES FROM USER get_config() { -# if setup_wizard file does not exist, create it -if [[ ! -f /etc/config/setup_wizard ]]; then - touch /etc/config/setup_wizard - - # indicator for whether setup wizard has already run - SETUP_RUN=`uci add setup_wizard settings` - uci rename setup_wizard.$SETUP_RUN=settings - uci set setup_wizard.settings.enabled=1 - - # indicator for whether password has been set - PASSWORD_SET=`uci add setup_wizard uci` - uci rename setup_wizard.$PASSWORD_SET=passwords - uci set setup_wizard.passwords.admin_pass=false -fi - - -# BEGIN USER INTERACTION -echo -e "\n\nWelcome to the Setup Wizard.\n" - -# if password not set, require password set -while [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ] -do - echo -e "\nPlease choose an administrator password: \n" - passwd - uci set setup_wizard.passwords.admin_pass=changed -done - - -while true; do - echo -e "\n\nSet the hostname for this device? [y/n]" - read answer - case $answer in - [Yy]* ) while true; do - echo "Enter new hostname: "; - read HOSTNAME; - uci set system.@system[0].hostname="$HOSTNAME"; - - validate $HOSTNAME $HOSTNAME_MIN $HOSTNAME_MAX; - if [ $? == 0 ]; then - uci set system.@system[0].hostname="$HOSTNAME"; - break; - fi - done; - break;; - [Nn]* ) break;; - * ) echo "Please answer yes[y] or no[n]";; - esac -done - - - -# GET MESH SETTINGS -while true; do - echo -e "\n\nPlease enter mesh network name: " - read MESH_NAME - validate $MESH_NAME $SSID_MIN $SSID_MAX - if [ $? == 0 ]; then - break; - fi -done - -while true; do - echo -e "\n\nPlease select a valid channel: " - read CHANNEL - if [ "$CHANNEL" -gt "$CHANNEL_MIN" ] && [ "$CHANNEL" -lt "$CHANNEL_MAX" ]; then - break; - else - echo -e "ERROR: Channel must be between $CHANNEL_MIN and $CHANNEL_MAX"; - fi -done - -echo -e "\nSet mesh network use encryption? [y/n]" - while true; do - read answer - case $answer in - [Yy]* ) while true; do - echo -e "\nPlease choose an encryption password: "; - read -s MESH_PASSWORD; - validate $MESH_PASSWORD $KEY_MIN $KEY_MAX; - if [ $? == "0" ]; then - echo "Repeat password: "; - read -s MESH_CONFIRM; - if [ "$MESH_PASSWORD" == "$MESH_CONFIRM" ]; then - break; - else - echo -e "Passwords do not match."; - fi - fi - done; - break;; - [Nn]* ) - break;; - * ) echo "Please answer yes[y] or no[n]";; - esac - done - - -# GET ACCESS POINT SETTINGS -echo -e "\n\nSet up an access point? [y/n]" - while true; do - read answer - case $answer in - [Yy]* ) while true; do - echo -e "\nAccess point name: "; - read AP_NAME; - validate $AP_NAME $SSID_MIN $SSID_MAX; - if [ $? == "0" ]; then - break; - fi - done; - break;; - [Nn]* ) break;; - * ) echo "Please answer yes[y] or no[n]";; - esac -done - -if [ $AP_NAME ]; then - # access point encryption - echo -e "\n\nSet encryption for the access point? [y/n]" + # GET MESH SETTINGS while true; do - read answer - case $answer in - [Yy]* ) while true; do - echo -e "\nPlease choose an encryption password: "; - read -s AP_PASSWORD; - validate $AP_PASSWORD $KEY_MIN $KEY_MAX; - if [ $? == "0" ]; then - echo "Repeat password: "; - read -s AP_CONFIRM; - if [ "$AP_PASSWORD" == "$AP_CONFIRM" ]; then - break; - else - echo -e "Passwords do not match.\n"; - fi - fi - done; - break;; - [Nn]* ) break;; - * ) echo "Please answer yes[y] or no[n]";; - esac + echo -e "\n\nPlease enter mesh network name for radio$iterator: " + read MESH_NAME + validate $MESH_NAME $SSID_MIN $SSID_MAX + if [ $? == 0 ]; then + break; + fi done -fi - - # DISPLAY PROPOSED CONFIGURATION - echo -e "\n\nCONFIGURATION - - NODE SETTINGS - Hostname: "$HOSTNAME" + while true; do + echo -e "\n\nPlease select a valid channel: " + + read CHANNEL + + # if radio is 2.4 GHz + if [ "$FREQUENCY" == "2.4" ] && [ "$CHANNEL" -gt "$CHANNEL_MIN" ] && [ "$CHANNEL" -lt "$CHANNEL_MAX" ]; then + break; + else if [ "$FREQUENCY" == "2.4" ]; then + echo -e "ERROR: Channel must be between $CHANNEL_MIN and $CHANNEL_MAX"; + fi + fi + + #if radio is 5 GHz + if [ "$FREQUENCY" == "5" ]; then + case $CHANNEL in + 36|40|44|48|149|153|157|161|165 ) + break;; + * ) echo -e "ERROR: Invalid channel. Valid options are: 36|40|44|48|149|153|157|161|165";; + esac + fi + done - MESH SETTINGS - SSID: "$MESH_NAME" - Channel: "$CHANNEL"" - -if [ $MESH_PASSWORD ]; then - echo -e " Encryption: yes" -# echo -e " Password: "$MESH_PASSWORD"" -else - echo -e " Encryption: no" -fi + echo -e "\nSet mesh network encryption? [y/n]" + + while true; do + read answer + case $answer in + [Yy]* ) + while true; do + echo -e "\nPlease choose an encryption password: "; + read -s MESH_PASSWORD; + validate $MESH_PASSWORD $KEY_MIN $KEY_MAX; + + if [ $? == "0" ]; then + echo "Repeat password: "; + read -s MESH_CONFIRM; + + if [ "$MESH_PASSWORD" == "$MESH_CONFIRM" ]; then + break; + else + echo -e "Passwords do not match."; + fi + fi + done; + break;; + [Nn]* ) + break;; + * ) + echo "Please answer yes[y] or no[n]";; + esac + done -if [ $AP_NAME ]; then - echo -e "\n - ACCESS POINT SETTINGS - SSID: "$AP_NAME" - Channel: "$CHANNEL"" - - if [ $AP_PASSWORD ]; then - echo -e " Encryption: yes" -# echo -e " Password: "$AP_PASSWORD"" - else - echo -e " Encryption: no" - fi - -fi + # GET ACCESS POINT SETTINGS + + echo -e "\n\nSet up an access point? [y/n]" + + while true; do + read answer + case $answer in + [Yy]* ) + while true; do + echo -e "\nAccess point name: "; + read AP_NAME; + validate $AP_NAME $SSID_MIN $SSID_MAX; + if [ $? == "0" ]; then + break; + fi + done; + break;; + [Nn]* ) + break;; + * ) + echo "Please answer yes[y] or no[n]";; + esac + done -# save or reset configuration -while true; do -echo -e "\n\nKeep this configuration? [y/n]" - read answer - case $answer in - [Yy]* ) return 0;; - [Nn]* ) echo "Reverting configuration settings."; - clear_values; - return 1;; - * ) echo "Please answer yes[y] or no[n]";; - esac - done + if [ $AP_NAME ]; then + # access point encryption + echo -e "\n\nSet encryption for the access point? [y/n]" + + while true; do + read answer + case $answer in + [Yy]* ) + while true; do + echo -e "\nPlease choose an encryption password: "; + read -s AP_PASSWORD; + validate $AP_PASSWORD $KEY_MIN $KEY_MAX; + + if [ $? == "0" ]; then + echo "Repeat password: "; + read -s AP_CONFIRM; + + if [ "$AP_PASSWORD" == "$AP_CONFIRM" ]; then + break; + else + echo -e "Passwords do not match.\n"; + fi + fi + done; + break;; + [Nn]* ) + break;; + * ) + echo "Please answer yes[y] or no[n]";; + esac + done + fi + + # DISPLAY PROPOSED CONFIGURATION + echo -e "\n\n + CONFIGURATION + + NODE SETTINGS + Hostname: "$HOSTNAME" + + + MESH SETTINGS + SSID: "$MESH_NAME" + Channel: "$CHANNEL"" + + if [ $MESH_PASSWORD ]; then + echo -e " + Encryption: yes" + else + echo -e " + Encryption: no" + fi + + if [ $AP_NAME ]; then + echo -e "\n + ACCESS POINT SETTINGS + SSID: "$AP_NAME" + Channel: "$CHANNEL"" + + if [ $AP_PASSWORD ]; then + echo -e " + Encryption: yes" + else + echo -e " + Encryption: no" + fi + fi + + # save or reset configuration + while true; do + echo -e "\n\nKeep this configuration? [y/n]" + read answer + case $answer in + [Yy]* ) + set_config; + return 0;; + [Nn]* ) + echo "Reverting configuration settings."; + clear_values; + return 1;; + * ) echo "Please answer yes[y] or no[n]";; + esac + done } set_config() { + # SET MESH UCI VALUES + + # wireless settings + MESH_CONFIG=`uci add wireless wifi-iface` + uci rename wireless."$MESH_CONFIG"=commotionMesh$iterator + + uci set wireless.commotionMesh$iterator.mode=adhoc + uci set wireless.commotionMesh$iterator.device=radio$iterator + uci set wireless.commotionMesh$iterator.ssid="$MESH_NAME" + uci set wireless.commotionMesh$iterator.network="$MESH_NAME" + uci set wireless.radio$iterator.channel="$CHANNEL" + uci set wireless.radio$iterator.disabled=0 + + # network settings + uci set network.commotionMesh$iterator=interface + uci set network.commotionMesh$iterator.class=mesh + uci set network.commotionMesh$iterator.profile="$MESH_NAME" + uci set network.commotionMesh$iterator.proto=commotion + uci set network.commotionMesh$iterator.name="$MESH_NAME" + + # firewall settings + uci add_list firewall.@zone[1].network="commotionMesh$iterator" + + + # set Commotion profile settings + commotion new "$MESH_NAME" + commotion set "$MESH_NAME" ssid "$MESH_NAME" + commotion set "$MESH_NAME" channel "$CHANNEL" + + #set encryption settings + if [ $MESH_PASSWORD ]; then + commotion set "$MESH_NAME" key "$MESH_PASSWORD"; + uci set wireless.commotionMesh$iterator.encryption=psk2; + uci set wireless.commotionMesh$iterator.key="$MESH_PASSWORD"; + else + commotion set "$MESH_NAME" encryption none + uci set wireless.commotionMesh$iterator.encryption=none + fi + + + # SET AP SETTINGS + if [ $AP_NAME ]; then + # set AP uci values + AP_CONFIG=`uci add wireless wifi-iface` + uci rename wireless."$AP_CONFIG"=commotionAP$iterator + + uci set wireless.commotionAP$iterator.network=lan + uci set wireless.commotionAP$iterator.mode=ap + uci set wireless.commotionAP$iterator.ssid="$AP_NAME" + uci set wireless.commotionAP$iterator.device=radio$iterator + + # set AP encryption + if [ $AP_PASSWORD ]; then + uci set wireless.commotionAP$iterator.encryption=psk2; + uci set wireless.commotionAP$iterator.key="$AP_PASSWORD"; + else + uci set wireless.commotionAP$iterator.encryption=none + fi + fi + + # mark changes in setup_wizard config file + uci set setup_wizard.settings.enabled=0 + uci commit setup_wizard + + # commit Commotion profile changes + commotion save "$MESH_NAME" + + echo -e "\n\nNew settings applied." + + # clear all values (precaution) + clear_values +} -# SET MESH UCI VALUES - -# wireless settings -MESH_CONFIG=`uci add wireless wifi-iface` -uci rename wireless."$MESH_CONFIG"=commotionMesh - -uci set wireless.commotionMesh.mode=adhoc -uci set wireless.commotionMesh.device=radio0 -uci set wireless.commotionMesh.ssid="$MESH_NAME" -uci set wireless.commotionMesh.network="$MESH_NAME" -uci set wireless.radio0.channel="$CHANNEL" -uci set wireless.radio0.disabled=0 - -# network settings -uci set network."$MESH_NAME"=interface -uci set network."$MESH_NAME".class=mesh -uci set network."$MESH_NAME".profile="$MESH_NAME" -uci set network."$MESH_NAME".proto=commotion - -# firewall settings -uci add_list firewall.@zone[1].network="$MESH_NAME" - - -# set Commotion profile settings -commotion new "$MESH_NAME" -commotion set "$MESH_NAME" ssid "$MESH_NAME" -commotion set "$MESH_NAME" channel "$CHANNEL" - -#set encryption settings -if [ $MESH_PASSWORD ]; then - commotion set "$MESH_NAME" key "$MESH_PASSWORD"; - uci set wireless.commotionMesh.encryption=psk2; - uci set wireless.commotionMesh.key="$MESH_PASSWORD"; -else - commotion set "$MESH_NAME" encryption none - uci set wireless.commotionMesh.encryption=none -fi - - -# SET AP SETTINGS -if [ $AP_NAME ]; then - # set AP uci values - AP_CONFIG=`uci add wireless wifi-iface` - uci rename wireless."$AP_CONFIG"=commotionAP - - uci set wireless.commotionAP.network=lan - uci set wireless.commotionAP.mode=ap - uci set wireless.commotionAP.ssid="$AP_NAME" - uci set wireless.commotionAP.device=radio0 - - # set AP encryption - if [ $AP_PASSWORD ]; then - uci set wireless.commotionAP.encryption=psk2; - uci set wireless.commotionAP.key="$AP_PASSWORD"; - else - uci set wireless.commotionAP.encryption=none - fi -fi +save_config() +{ + # commit uci changes + uci commit wireless + uci commit network + uci commit system + uci commit firewall - -# mark changes in setup_wizard config file -uci set setup_wizard.settings.enabled=0 -uci commit setup_wizard + echo -e "\n\nAll settings saved." -# commit Commotion profile changes -commotion save "$MESH_NAME" + echo -e "\n\nRestarting networking.\n\n" -# commit uci changes -uci commit wireless -uci commit network -uci commit system -uci commit firewall + # restart networking + /etc/init.d/commotiond restart + /etc/init.d/network reload +} -echo -e "\n\nSettings saved." -echo -e "\n\nRestarting networking.\n\n" +# SCRIPT BEGINS HERE -# restart networking -/etc/init.d/commotiond restart -/etc/init.d/network reload +# DETERMINE NUMBER OF RADIOS +NUM_RADIOS=`less /etc/config/wireless | grep -c "wifi-device"` -# clear all values (precaution) -clear_values -} +# BEGIN USER INTERACTION +echo -e "\n\nWelcome to the Setup Wizard.\n" +# if password not set, require password set +while [ `grep root /etc/shadow | cut -d ":" -f 2` == "x" ]; do + echo -e "\nPlease choose an administrator password: \n" + passwd + uci set setup_wizard.passwords.admin_pass=changed +done -# SCRIPT BEGINS HERE if [ `uci get setup_wizard.settings.enabled` == 0 ]; then - echo -e "Setup Wizard has already been run." + echo -e "Setup Wizard has already been run." + while true; do + echo -e "\nSet new configuration? [y/n]" + read answer + case $answer in + [Yy]* ) echo -e "Reverting previous configuration."; + clear_previous_configuration; + break;; + [Nn]* ) echo -e "Keeping settings. Closing Setup Wizard."; + exit 0;; + * ) echo "Please answer yes[y] or no[n]";; + esac + done +fi + while true; do -echo -e "\n\nSet new configuration? [y/n]" + echo -e "\n\nSet the hostname for this device? [y/n]" read answer case $answer in - [Yy]* ) echo -e "Reverting previous configuration."; - clear_previous_configuration; - break;; - [Nn]* ) echo -e "Keeping settings. Closing Setup Wizard."; - exit 0;; - * ) echo "Please answer yes[y] or no[n]";; + [Yy]* ) while true; do + echo "Enter new hostname: "; + read HOSTNAME; + uci set system.@system[0].hostname="$HOSTNAME"; + + validate $HOSTNAME $HOSTNAME_MIN $HOSTNAME_MAX; + if [ $? == 0 ]; then + uci set system.@system[0].hostname="$HOSTNAME"; + break; + fi + done; + break;; + [Nn]* ) break;; + * ) echo "Please answer yes[y] or no[n]";; esac - done -fi +done + +# if setup_wizard file does not exist, create it +if [[ ! -f /etc/config/setup_wizard ]]; then + touch /etc/config/setup_wizard + # indicator for whether setup wizard has already run + SETUP_RUN=`uci add setup_wizard settings` + uci rename setup_wizard.$SETUP_RUN=settings + uci set setup_wizard.settings.enabled=1 -# RUN SETUP WIZARD -get_config + # indicator for whether password has been set + PASSWORD_SET=`uci add setup_wizard uci` + uci rename setup_wizard.$PASSWORD_SET=passwords + uci set setup_wizard.passwords.admin_pass=false +fi -# if user rejects settings, rerun get_config -while [ $? -eq 1 ]; do - get_config -done +# CONFIGURE EACH RADIO FOR MESH AND AP SETTINGS +iterator=0 +while [ $iterator -lt $NUM_RADIOS ]; do + # Get wireless protocol + PROTOCOL=$(uci get wireless.radio$iterator.hwmode) + + if [ "$PROTOCOL" == "11b" ] || [ "$PROTOCOL" == "11g" ] || [ "$PROTOCOL" == "11ng" ]; then + # protocol uses 2.4 GHz frequency range + FREQUENCY=2.4 + + else if [ "$PROTOCOL" == "11a" ] || [ "$PROTOCOL" == "11na" ]; then + # protocol uses 5 GHz frequency range + FREQUENCY=5 + fi + fi + + # GET PERMISSION TO CONFIGURE DEVICE + echo -e "\n\nConfigure radio$iterator ($FREQUENCY GHz)? [y/n]" + while true; do + read answer + case $answer in + [Yy]* ) echo -e "\nConfiguring radio$iterator ($FREQUENCY GHz)"; + get_config; + # if user rejects settings, rerun get_config + while [ $? -eq 1 ]; do + get_config; + done; + break;; + + [Nn]* ) break;; + * ) echo "Please answer yes[y] or no[n]";; + esac + done + + iterator=$((iterator+1)) +done -# if user accepts settings, run set_config -if [ $? -eq 0 ]; then - set_config -fi \ No newline at end of file +save_config \ No newline at end of file From f2cc2f62b72d1fbaa7264415434a4a77b6dacaf9 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Wed, 19 Nov 2014 15:59:00 -0500 Subject: [PATCH 61/63] rewrote clear_previous_configuration function to use config_cb callback --- default-files/usr/bin/setupwizard | 36 ++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index ee67517..73c415c 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -1,5 +1,7 @@ #!/bin/ash +source /lib/functions.sh + # PRESET VALUES SSID_MIN=1 SSID_MAX=31 @@ -40,17 +42,31 @@ validate() { # RESET FUNCTION (for saved configurations) clear_previous_configuration() { - LOOP=0 - while [ $LOOP -lt $NUM_RADIOS ]; do - uci delete wireless.commotionMesh$LOOP - uci delete wireless.commotionAP$LOOP - uci delete network.commotionMesh$LOOP - - uci commit wireless - - LOOP=$((LOOP+1)) - done + config_cb() { + echo "running config_cb" + local TYPE="$1" + local NAME="$2" + + # if type == iface, delete + if [ $TYPE == "wifi-iface" ] ; then + + # get ssid + SSID=$(uci get wireless.$NAME.ssid) + + # if this is a mesh interface, delete profile and network config + if [ $(uci get wireless.$NAME.mode) == "adhoc" ]; then + uci delete network.$SSID + commotion delete $SSID + fi + + uci delete wireless.$NAME + fi +} + +config_load wireless +uci commit +config_reset } # RESET FUNCTION (for unsaved configurations) From 8234b0ac860c5aa21d2d85ec73e66684d8d58fb5 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Fri, 23 Jan 2015 10:00:45 -0500 Subject: [PATCH 62/63] fixed mesh protocol bug --- default-files/usr/bin/setupwizard | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 73c415c..9338034 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -272,11 +272,10 @@ set_config() { uci set wireless.radio$iterator.disabled=0 # network settings - uci set network.commotionMesh$iterator=interface - uci set network.commotionMesh$iterator.class=mesh - uci set network.commotionMesh$iterator.profile="$MESH_NAME" - uci set network.commotionMesh$iterator.proto=commotion - uci set network.commotionMesh$iterator.name="$MESH_NAME" + uci set network."$MESH_NAME"=interface + uci set network."$MESH_NAME".class=mesh + uci set network."$MESH_NAME"="$MESH_NAME" + uci set network."$MESH_NAME".proto=commotion # firewall settings uci add_list firewall.@zone[1].network="commotionMesh$iterator" @@ -453,4 +452,4 @@ while [ $iterator -lt $NUM_RADIOS ]; do iterator=$((iterator+1)) done -save_config \ No newline at end of file +save_config From ae2de535c38212f84d33cfffa6cf4be1d58421a7 Mon Sep 17 00:00:00 2001 From: Grady Johnson Date: Fri, 23 Jan 2015 10:28:34 -0500 Subject: [PATCH 63/63] fixed profile interface bug --- default-files/usr/bin/setupwizard | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/default-files/usr/bin/setupwizard b/default-files/usr/bin/setupwizard index 9338034..b34bf0a 100755 --- a/default-files/usr/bin/setupwizard +++ b/default-files/usr/bin/setupwizard @@ -274,7 +274,7 @@ set_config() { # network settings uci set network."$MESH_NAME"=interface uci set network."$MESH_NAME".class=mesh - uci set network."$MESH_NAME"="$MESH_NAME" + uci set network."$MESH_NAME".profile="$MESH_NAME" uci set network."$MESH_NAME".proto=commotion # firewall settings