2017-01-30 09:39:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
__DIR__=$(dirname $(realpath $0));
|
|
|
|
|
|
|
|
source $__DIR__/lib/include/bash/const;
|
|
|
|
source $__DIR__/lib/include/bash/func;
|
2017-01-26 13:23:50 +00:00
|
|
|
|
2017-07-21 10:44:45 +00:00
|
|
|
# (1) Check if synchronization done #
|
2017-05-08 14:25:09 +00:00
|
|
|
if [ ! -e /target/sync ]; then
|
2017-07-21 10:44:45 +00:00
|
|
|
slog "not synchronized yet, aborting" - "update" && exit 127;
|
2017-03-10 14:18:52 +00:00
|
|
|
fi;
|
|
|
|
|
2017-07-21 14:06:49 +00:00
|
|
|
# (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;
|
|
|
|
|
2017-07-21 10:44:45 +00:00
|
|
|
# (2) Send data + fetch configuration
|
|
|
|
test "$($SOURCE_DIR/lib/api/update)" = "127" && slog "update failed" - "update" && exit 127;
|
|
|
|
|
2017-03-10 14:18:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2017-01-26 13:23:50 +00:00
|
|
|
|
2017-01-28 18:26:19 +00:00
|
|
|
|
2017-07-21 10:44:45 +00:00
|
|
|
# (3) Update source
|
2017-01-30 09:39:45 +00:00
|
|
|
BRANCH=$(cat $BRANCH_CONF);
|
2017-01-26 13:23:50 +00:00
|
|
|
|
2017-01-30 09:39:45 +00:00
|
|
|
cd $SOURCE_DIR
|
2017-01-26 13:23:50 +00:00
|
|
|
git checkout $BRANCH;
|
2017-01-28 18:26:19 +00:00
|
|
|
test $? -ne 0 && exit 127;
|
2017-01-26 13:23:50 +00:00
|
|
|
git pull origin $BRANCH;
|
2017-01-28 18:26:19 +00:00
|
|
|
test $? -ne 0 && exit 127;
|