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-01-28 10:45:09 +00:00
|
|
|
# [1] Send data + fetch configuration
|
2017-05-08 14:25:09 +00:00
|
|
|
if [ ! -e /target/sync ]; then
|
2017-03-10 14:18:52 +00:00
|
|
|
|
2017-05-09 11:54:35 +00:00
|
|
|
$SOURCE_DIR/lib/api/init;
|
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
slog "init failed" - "update";
|
|
|
|
exit 127;
|
|
|
|
fi;
|
2017-03-10 14:18:52 +00:00
|
|
|
|
2017-05-08 14:25:09 +00:00
|
|
|
touch /target/sync;
|
2017-03-10 14:18:52 +00:00
|
|
|
else
|
|
|
|
|
2017-05-09 11:54:35 +00:00
|
|
|
test "$($SOURCE_DIR/lib/api/sync)" = "127"; && slog "sync failed" - "update" && exit;
|
2017-03-10 14:18:52 +00:00
|
|
|
test $? -ne 0 && exit 127;
|
|
|
|
fi;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-01-26 13:23:50 +00:00
|
|
|
|
2017-01-28 18:26:19 +00:00
|
|
|
|
2017-01-26 13:23:50 +00:00
|
|
|
# [2] 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;
|