38 lines
618 B
Bash
Executable File
38 lines
618 B
Bash
Executable File
#!/bin/bash
|
|
|
|
__DIR__=$(dirname $(realpath $0));
|
|
|
|
source $__DIR__/lib/include/bash/const;
|
|
source $__DIR__/lib/include/bash/func;
|
|
|
|
# [1] Send data + fetch configuration
|
|
if [ ! -e /target/sync ]; then
|
|
|
|
$SOURCE_DIR/lib/api/init;
|
|
|
|
if [ $? -ne 0 ]; then
|
|
slog "init failed" - "update";
|
|
exit 127;
|
|
fi;
|
|
|
|
touch /target/sync;
|
|
else
|
|
|
|
test "$($SOURCE_DIR/lib/api/sync)" = "127"; && slog "sync failed" - "update" && exit;
|
|
test $? -ne 0 && exit 127;
|
|
fi;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# [2] Update source
|
|
BRANCH=$(cat $BRANCH_CONF);
|
|
|
|
cd $SOURCE_DIR
|
|
git checkout $BRANCH;
|
|
test $? -ne 0 && exit 127;
|
|
git pull origin $BRANCH;
|
|
test $? -ne 0 && exit 127;
|