nsbin/sync-all-repos

82 lines
1.7 KiB
Text
Raw Normal View History

2017-11-25 20:08:58 +01:00
#!/bin/sh
onlystatic="yes"
2021-05-26 11:44:44 +02:00
if [ $# -ge 1 ]; then
onlystatic=""
2021-05-26 11:44:44 +02:00
fi
2017-11-25 20:08:58 +01:00
set -e
pullpush_repo() {
repo=$1
echo $repo
if [ ! -d $repo ]; then echo "Repo $repo does not exist, skipping"; return; fi
cd $repo
git pull
git push
}
update_repo() {
repo=$1
2017-11-25 23:03:30 +01:00
echo $repo
2017-11-25 20:08:58 +01:00
cd $repo
2021-03-16 15:10:24 +01:00
case $repo in
~/.password-store)
git checkout master
git add .
git commit -m "updated by $0" || true
git pull
git checkout nico-privat
;;
~/vcs/cdist-workdir)
mr update
;;
esac
2017-11-25 20:08:58 +01:00
git add .
2021-01-25 16:04:59 +01:00
git commit -m "updated by $0 on $(hostname)" || true
2017-11-25 20:08:58 +01:00
git pull
git push
}
REPOLIST="$HOME/.ctt $HOME/bin $HOME/vcs/notes $HOME/vcs/nico-dot-cdist $HOME/vcs/cdist-workdir/dot-cdist $HOME/vcs/ansible-main"
REPOLIST2="$REPOLIST $HOME/.password-store"
PULL_PUSH_REPOS="$HOME/vcs/k8s-config/ $HOME/vcs/ansible-main/"
# First in parallel, then en sequence to spot errors
for repo in ${REPOLIST}; do ( update_repo $repo & ) ; done
for repo in ${PULL_PUSH_REPOS}; do ( pull_push_repo $repo & ) ; done
echo "Waiting for async process to finish ..."
wait
exit 0
################################################################################
# Old stuff skipped atm
echo "Starting for sync process ..."
for repo in ${REPOLIST}; do update_repo $repo ; done
for repo in ${PULL_PUSH_REPOS}; do pull_push_repo $repo ; done
2024-03-22 10:13:25 +01:00
# Step 2: pull/push all other repos in ~/vcs/
# We cannot commit as we do not know the state, but we
# can ensure everything committed before is pushed out
2021-05-26 11:44:44 +02:00
if [ $onlystatic ]; then
exit 0
fi
set +e
for repo in ~/vcs/*; do
echo "$repo"
cd ${repo}
git pull
git push
done