diff options
Diffstat (limited to 'tools/sync-conf.sh')
-rw-r--r-- | tools/sync-conf.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tools/sync-conf.sh b/tools/sync-conf.sh new file mode 100644 index 0000000..6b1a934 --- /dev/null +++ b/tools/sync-conf.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +dir="/var/tmp/portage/config/conf/$(hostname)" +root=/ +repo="ssh://git@git.brancik.cz/rpi-config.git" + +if [ $# != 1 ]; then + echo "Usage: sync-config <action>. Action can be either pull or push" + exit 1 +fi + +function check_repo { + if [ ! -d /var/tmp/portage/config/.git ]; then + echo "Cloning repository with config files." + mkdir -p /var/tmp/portage + chown ctibor:ctibor /var/tmp/portage + /bin/su ctibor --command="/usr/bin/git clone --depth=1 ${repo} /var/tmp/portage/config" + fi +} + +case $1 in + push) + check_repo + /bin/su ctibor --command="/usr/bin/git pull" + echo "Pushing config files to overlay folder ..." + /usr/bin/rsync -v --files-from /etc/portage/filelist_sync --recursive ${root} ${dir} -- + cd ${dir} + /bin/su ctibor --command="/usr/bin/git add ." + /bin/su ctibor --command="/usr/bin/git commit -a -m \"Update portage config for mizar $(date +%Y%m%d-%H%M%S)\"" + /bin/su ctibor --command="/usr/bin/git push";; + pull) + check_repo + cd ${dir} + /bin/su ctibor --command="/usr/bin/git pull" + echo "Pulling config files from overlay folder ..." + /usr/bin/rsync -v --files-from /etc/portage/filelist_sync --recursive ${dir} ${root} --;; + *) + echo "Usage: sync-config <action>. Action can be either pull or push" + exit 1 +esac |