Added network identity to post-data when sats-update

This commit is contained in:
xdrm-brackets 2017-07-21 16:06:49 +02:00
parent 6ea77ddd9f
commit ca25a414fc
2 changed files with 19 additions and 6 deletions

View File

@ -9,8 +9,12 @@
/* (1) Initialize dataset /* (1) Initialize dataset
---------------------------------------------------------*/ ---------------------------------------------------------*/
$data = [ $data = [
'default' => [], 'default' => [],
'feature' => [] 'feature' => [],
'identity' => [
'ap' => preg_replace('/\s+/', '', file_get_contents(TMP_DIR.'/net.ap')),
'ip' => preg_replace('/\s+/', '', file_get_contents(TMP_DIR.'/net.ip'))
]
]; ];
@ -78,13 +82,13 @@
} }
return json_encode($data); return json_encode($data);
} }
echo api_fetch(); echo api_fetch();
?> ?>

9
update
View File

@ -10,6 +10,15 @@ if [ ! -e /target/sync ]; then
slog "not synchronized yet, aborting" - "update" && exit 127; slog "not synchronized yet, aborting" - "update" && exit 127;
fi; fi;
# (2) Get wireless IFACE #
IFACE=`sudo ifconfig | grep -o -P "^w\w+"`;
# (3) Get network identity #
AP_ID=`sudo iwconfig $IFACE | grep -o -P "ESSID:\"SATS_.+\"" | sed 's/ESSID:"SATS_//' | sed 's/"$//'`;
IP_AD=`sudo ifconfig $IFACE | grep -o -P "inet addr:\d+\.\d+\.\d+\.\d+" | sed 's/inet addr://'`
echo $AP_ID | sudo -u sats tee $TMP_DIR/net.ap;
echo $IP_AD | sudo -u sats tee $TMP_DIR/net.ip;
# (2) Send data + fetch configuration # (2) Send data + fetch configuration
test "$($SOURCE_DIR/lib/api/update)" = "127" && slog "update failed" - "update" && exit 127; test "$($SOURCE_DIR/lib/api/update)" = "127" && slog "update failed" - "update" && exit 127;