Run on clone AND update

This commit is contained in:
southerntofu 2020-04-18 11:30:57 -04:00
parent 89628d2b43
commit 2092f45303
1 changed files with 10 additions and 4 deletions

View File

@ -8,6 +8,13 @@
BASEDIR="$HOME/.git-build"
run() {
p_name="$1"
echo "[$p_name] RUN"
# Run in background and redirect output to $p_name.log
(GITBUILDDIR="$BASEDIR" nohup $BASEDIR/$p_name $p_name > $BASEDIR/$p_name.log 2> $BASEDIR/$p_name.err) &
}
# So scripts can know we're still running (for autoupdater)
touch $BASEDIR/.LOCK
@ -22,12 +29,13 @@ for project in $BASEDIR/*.source; do
# Don't forget the git submodules!
git clone --recursive "$source" "$p_dir"
[[ $? != 0 ]] && echo "[$p_name] CLONE FAILED" && exit 1
cd $p_dir
if [[ "$p_branch" != "master" ]]; then
cd $p_dir
echo "[$p_name] CHECKOUT BRANCH $p_branch"
git checkout "$p_branch"
[[ $? != 0 ]] && echo "[$p_name] CHECKOUT FAILED" && exit 1
fi
run $p_name
fi
cd "$p_dir"
# Refresh remote before comparing with local
@ -38,10 +46,8 @@ for project in $BASEDIR/*.source; do
# Update all submodules, for now only when the main repo changed (TODO)
git pull --quiet --recurse-submodules
[[ $? != 0 ]] && echo "[$p_name] PULL FAILED" && exit 1
echo "[$p_name] RUN"
run $p_name
fi
# Run in background and redirect output to $p_name.log
(GITBUILDDIR="$BASEDIR" nohup $BASEDIR/$p_name $p_name > $BASEDIR/$p_name.log 2> $BASEDIR/$p_name.err) &
done
rm $BASEDIR/.LOCK