[minupd] Added timestamp to dwc log

This commit is contained in:
xdrm-brackets 2017-07-25 15:57:04 +02:00
parent 389eee90ce
commit 751bd4b23e
1 changed files with 18 additions and 18 deletions

View File

@ -7,13 +7,13 @@ slog(){
} }
failexit(){ failexit(){
slog " > failed"; slog "[`date +%s`] > failed";
exit 127; exit 127;
} }
connectedexit(){ connectedexit(){
slog " > connected"; slog "[`date +%s`] > connected";
slog "<<< Finished\n"; slog "[`date +%s`] <<< Finished\n";
exit 0; exit 0;
} }
@ -23,15 +23,15 @@ HSALT="***SALT***";
HPEPPER="***PEPPER***"; HPEPPER="***PEPPER***";
slog ">>> Dynamic Wireless Credentials"; slog "[`date +%s`] >>> Dynamic Wireless Credentials";
# [1] Checking connectivity # [1] Checking connectivity
#========================================================# #========================================================#
slog " * 1. Checking connectivity" slog "[`date +%s`] * 1. Checking connectivity"
[ -z "`ping xdrm.io -q -c 1 -i 1 2>&1 > /dev/null`" ] \ [ -z "`ping xdrm.io -q -c 1 -i 1 2>&1 > /dev/null`" ] \
&& connectedexit \ && connectedexit \
|| slog " > offline"; || slog "[`date +%s`] > offline";
@ -39,31 +39,31 @@ slog " * 1. Checking connectivity"
#========================================================# #========================================================#
# (1) Get interface name # # (1) Get interface name #
slog " * 2. Looking for wireless interface"; slog "[`date +%s`] * 2. Looking for wireless interface";
IFACE=`sudo ifconfig -a | grep -P "^w" | awk '{print $1}' | head -n 1`; IFACE=`sudo ifconfig -a | grep -P "^w" | awk '{print $1}' | head -n 1`;
sudo ifconfig $IFACE up; sudo ifconfig $IFACE up;
# (2) Manage no IFACE found # # (2) Manage no IFACE found #
test -z "$IFACE" && failexit; test -z "$IFACE" && failexit;
slog " > done (got '$IFACE')"; slog "[`date +%s`] > done (got '$IFACE')";
# (3) Get nearest AP matching "SATS_*" and extract HASH # # (3) Get nearest AP matching "SATS_*" and extract HASH #
slog " * 3. Looking for nearest AP matching 'SATS_.+'"; slog "[`date +%s`] * 3. 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`; AP_HASH=`sudo iwlist $IFACE scan | grep -P "^\s*ESSID:\"SATS_.+\"\s*$" | sed 's/^[ \t]*ESSID:"SATS_//' | sed 's/"[ \t]*$//' | head -n 1`;
# (4) Manage no AP found # # (4) Manage no AP found #
test -z "$AP_HASH" && failexit; test -z "$AP_HASH" && failexit;
slog " > done (got 'SATS_$AP_HASH')"; slog "[`date +%s`] > done (got 'SATS_$AP_HASH')";
# [3] Calculate WIFI PASS from SSID hash # [3] Calculate WIFI PASS from SSID hash
#========================================================# #========================================================#
slog " * 4. Processing WPA2 passphrase" slog "[`date +%s`] * 4. Processing WPA2 passphrase"
PASS=`echo -ne "$HPEPPER$(echo -ne "${HSALT}${AP_HASH}" | sha512sum | sed 's/[ \t]*-$//')" | sha512sum | sed 's/[ \t]*-//' | cut -b 1-63`; PASS=`echo -ne "$HPEPPER$(echo -ne "${HSALT}${AP_HASH}" | sha512sum | sed 's/[ \t]*-$//')" | sha512sum | sed 's/[ \t]*-//' | cut -b 1-63`;
slog " > done"; slog "[`date +%s`] > done";
# [4] Update 'wpa_supplicant' configuration # [4] Update 'wpa_supplicant' configuration
@ -74,22 +74,22 @@ echo -e "network={\n\tssid=\"SATS_$AP_HASH\"\n\tpsk=\"$PASS\"\n}" | sudo tee /et
# [5] Restart connection # [5] Restart connection
#========================================================# #========================================================#
# (1) Starting wpa_supplicant # # (1) Starting wpa_supplicant #
slog " * 5. Starting wpa_supplicant" slog "[`date +%s`] * 5. Starting wpa_supplicant"
sudo pkill wpa_supplicant; sudo pkill wpa_supplicant;
sudo wpa_supplicant -B -Dwext -i$IFACE -c/etc/wpa_supplicant/$IFACE.conf \ sudo wpa_supplicant -B -Dwext -i$IFACE -c/etc/wpa_supplicant/$IFACE.conf \
&& slog " > done" \ && slog "[`date +%s`] > done" \
|| failexit; || failexit;
# (2) Starting dhclient # # (2) Starting dhclient #
slog " * 6. Starting dhclient" slog "[`date +%s`] * 6. Starting dhclient"
if [ ! -z "`pgrep dhclient`" ]; then if [ ! -z "`pgrep dhclient`" ]; then
slog " > already running"; slog "[`date +%s`] > already running";
else else
sudo dhclient $IFACE \ sudo dhclient $IFACE \
&& slog " > done" \ && slog "[`date +%s`] > done" \
|| failexit; || failexit;
fi; fi;
slog "<<< Finished\n"; slog "[`date +%s`] <<< Finished\n";