diff --git a/clone/clone b/clone/clone index 162f7f2..563f22d 100755 --- a/clone/clone +++ b/clone/clone @@ -281,11 +281,6 @@ step7(){ echo " - /lib/systemd/system"; sudo cp ./utility/sats-update.service /mnt/lib/systemd/system/sats-update.service; - # (4) Install sats-pre-update service # - echo " (.) Create sats-pre-update service"; - echo " - /lib/systemd/system"; - sudo cp ./utility/sats-pre-update.service /mnt/lib/systemd/system/sats-pre-update.service; - # (5) Install sats-loop service # echo " (.) Create sats-loop service"; echo " - /lib/systemd/system"; @@ -304,9 +299,9 @@ step7(){ echo " (.) Create sats-update script"; cat ./utility/sats-update | sudo tee /mnt/service/sats-update > /dev/null; - # (9) Create sats-pre-update script # - echo " (.) Create sats-pre-update script"; - cat ./utility/sats-pre-update | sed "s/\*\*\*SALT\*\*\*/$WIFI_SALT/" | sed "s/\*\*\*PEPPER\*\*\*/$WIFI_PEPPER/" | sudo tee /mnt/service/sats-pre-update > /dev/null; + # (9) Create sats-wpa script # + echo " (.) Create sats-wpa script"; + cat ./utility/sats-wpa | sed "s/\*\*\*SALT\*\*\*/$WIFI_SALT/" | sed "s/\*\*\*PEPPER\*\*\*/$WIFI_PEPPER/" | sudo tee /mnt/service/sats-wpa > /dev/null; # (10) Create sats-loop script # echo " (.) Create sats-loop script"; @@ -327,9 +322,9 @@ step7(){ echo " - sats-update @sats"; sudo chown 666:666 /mnt/service/sats-update; sudo chmod 770 /mnt/service/sats-update; - echo " - sats-pre-update @pi"; - sudo chown 1000:1000 /mnt/service/sats-pre-update; - sudo chmod 770 /mnt/service/sats-pre-update; + echo " - sats-wpa @pi"; + sudo chown 1000:1000 /mnt/service/sats-wpa; + sudo chmod 770 /mnt/service/sats-wpa; echo " - sats-loop @sats"; sudo chown 666:666 /mnt/service/sats-loop; sudo chmod 770 /mnt/service/sats-loop; diff --git a/clone/utility/sats-wpa b/clone/utility/sats-wpa index f670172..24e8bcc 100644 --- a/clone/utility/sats-wpa +++ b/clone/utility/sats-wpa @@ -13,19 +13,26 @@ slog ">>> Dynamic Wireless Credentials"; #========================================================# # (1) Get interface name # -IFACE=`ifconfig | grep -P "^w" | awk '{print $1}'`; +slog "(1) Looking for wireless interface"; +IFACE=`sudo ifconfig -a | grep -P "^w" | awk '{print $1}' | head -n 1`; +sudo ifconfig $IFACE up; +slog " > got '$IFACE'"; # (2) Get nearest AP matching "SATS_*" and extract HASH # -AP_HASH=`sudo iwlist wlan0 scan | grep -P "^\s*ESSID:\"SATS_.+\"\s*$" | sed 's/^[ \t]*ESSID:"SATS_//' | sed 's/"[ \t]*$//'`; +slog "(2) Looking for nearest AP matching 'SATS_.+'"; +AP_HASH=`sudo iwlist $IFACE scan | grep -P "^\s*ESSID:\"SATS_.+\"\s*$" | sed 's/^[ \t]*ESSID:"SATS_//' | sed 's/"[ \t]*$//' | head -n 1`; +slog " > got 'SATS_$AP_HASH'"; # (3) Manage no AP found # -test `echo -ne $AP_HASH | wc -l` -eq 0 && slog "no AP found" && exit; +test -z "$AP_HASH" && slog "no AP found" && exit; # [2] Calculate WIFI PASS from SSID hash #========================================================# -PASS=`echo -ne "$HPEPPER$(echo -n "${HSALT}${AP_HASH}" | sha512sum | sed 's/[ \t]*-$//')" | sha512sum | sed 's/[ \t]*-//'`; +slog "(3) Processing WPA2 passphrase" +PASS=`echo -ne "$HPEPPER$(echo -ne "${HSALT}${AP_HASH}" | sha512sum | sed 's/[ \t]*-$//')" | sha512sum | sed 's/[ \t]*-//' | cut -b 1-63`; +slog " > done"; # [3] Update 'wpa_supplicant.conf' @@ -40,4 +47,9 @@ sudo cat /etc/wpa_supplicant/wpa_supplicant.tmp | sed "s/^[ \t]*psk=.*$/\tpsk=\ # (3) Remove tmp file # sudo rm /etc/wpa_supplicant/wpa_supplicant.tmp; -slog "<<< Done"; \ No newline at end of file + +slog "(4) Trying to connect"; +sudo wpa_supplicant -B -Dwext -i$IFACE -c/etc/wpa_supplicant/wpa_supplicant.conf; +sudo dhclient $IFACE; + +slog "<<< Done"; diff --git a/clone/utility/sats-wpa.service b/clone/utility/sats-wpa.service deleted file mode 100644 index 67c5b55..0000000 --- a/clone/utility/sats-wpa.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=SATS DWC (Dynamic Wireless Credentials) Process - -[Service] -Type=oneshot -User=pi -Group=pi -ExecStart=/bin/bash /service/sats-wpa - -[Install] -WantedBy=network.target \ No newline at end of file