diff options
author | Ctibor Brančík <ctibor@brancik.cz> | 2017-06-18 17:21:11 +0200 |
---|---|---|
committer | Ctibor Brančík <ctibor@brancik.cz> | 2017-06-18 17:21:11 +0200 |
commit | ffb59a852274db5a9686671239ca0b51bd9f8796 (patch) | |
tree | ff54ac1739d8bba0202ec24c103d94a77b75d46d /tools/sync-conf.sh | |
parent | 0996f26be8d1f23676804c14d6ce374432489e24 (diff) | |
download | rpi-config-ffb59a852274db5a9686671239ca0b51bd9f8796.tar.gz rpi-config-ffb59a852274db5a9686671239ca0b51bd9f8796.tar.bz2 |
Replace python scripts with simple bash solution
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 |