diff options
Diffstat (limited to 'networking/wifi/device-files/networks/add_network.sh')
-rw-r--r-- | networking/wifi/device-files/networks/add_network.sh | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/networking/wifi/device-files/networks/add_network.sh b/networking/wifi/device-files/networks/add_network.sh index 230be42..04c93da 100644 --- a/networking/wifi/device-files/networks/add_network.sh +++ b/networking/wifi/device-files/networks/add_network.sh @@ -21,19 +21,26 @@ if [ $? -ne 0 ]; then exit 1 fi -# parse arguments <ssid> <password> -if [ $# -eq 0 ]; then - echo "Missing arguments <ssid> <password> " - exit 1 -fi -if [ $# -ne 2 ]; then - echo "Wrong argument count!" - exit 1 +# parse arguments <ssid> [<password>] +# If no <password>, then assume no authentication +if [ $# -eq 0 ]; then + echo "Usage: bash add_network.sh <ssid> [<password>] " + exit 1 +elif [ $# -eq 1 ]; then + # If no password, we assume that no authentication is necessary + curnet=$1 + NO_PASSWORD=1 +elif [ $# -eq 2 ]; then + #If a a password is passed, we assume WPA-Personal + curnet=$1 + pass=$2 + NO_PASSWORD=0 +else + echo "Usage: bash add_network.sh <ssid> [<password>]" + exit 1 fi -curnet=$1 -pass=$2 foundnet=$(bash "$knets_get" "$curnet") if ! [ -z "$foundnet" ]; then # the network is already a known one, @@ -45,4 +52,8 @@ if ! [ -e "$knets_file" ]; then echo -n "" > "$knets_file" fi -echo -e "$curnet""\t""$pass" >> $knets_file +if [$NO_PASSWORD -eq 1]; then + echo -e "$curnet" >> $knets_file +else + echo -e "$curnet""\t""$pass" >> $knets_file +fi |