diff options
author | Ctibor Brančík <ctibor@brancik.cz> | 2017-06-18 17:34:53 +0200 |
---|---|---|
committer | Ctibor Brančík <ctibor@brancik.cz> | 2017-06-18 17:34:53 +0200 |
commit | 9d0341b2a262fcc364a9a4dc2bb0a5872b86f21c (patch) | |
tree | 19c812e95077171946b7708be030954b87e0d8d5 | |
parent | ffb59a852274db5a9686671239ca0b51bd9f8796 (diff) | |
download | rpi-config-9d0341b2a262fcc364a9a4dc2bb0a5872b86f21c.tar.gz rpi-config-9d0341b2a262fcc364a9a4dc2bb0a5872b86f21c.tar.bz2 |
Add script for syncying configuration on host machine
-rw-r--r-- | tools/sync-conf.sh | 15 | ||||
-rw-r--r-- | tools/sync-rpi-config.sh | 52 |
2 files changed, 60 insertions, 7 deletions
diff --git a/tools/sync-conf.sh b/tools/sync-conf.sh index 6b1a934..561b993 100644 --- a/tools/sync-conf.sh +++ b/tools/sync-conf.sh @@ -1,6 +1,7 @@ #!/bin/bash dir="/var/tmp/portage/config/conf/$(hostname)" +username="ctibor" root=/ repo="ssh://git@git.brancik.cz/rpi-config.git" @@ -13,25 +14,25 @@ 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" + chown ${username}:${username} /var/tmp/portage + /bin/su ${username} --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" + /bin/su ${username} --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";; + /bin/su ${username} --command="/usr/bin/git add ." + /bin/su ${username} --command="/usr/bin/git commit -a -m \"Update portage config for mizar $(date +%Y%m%d-%H%M%S)\"" + /bin/su ${username} --command="/usr/bin/git push";; pull) check_repo cd ${dir} - /bin/su ctibor --command="/usr/bin/git pull" + /bin/su ${username} --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} --;; *) diff --git a/tools/sync-rpi-config.sh b/tools/sync-rpi-config.sh new file mode 100644 index 0000000..f09b170 --- /dev/null +++ b/tools/sync-rpi-config.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +repo=/tmp/rpi-config +device=${1} + +if [ ! -d /tmp/rpi-config/.git ]; then + cd /tmp + su ctibor --command "/usr/bin/git clone --depth 1 ssh://git@git.brancik.cz/rpi-config.git" + su ctibor --command "/usr/bin/git config --global user.name \"Ctibor Brančík\"" + su ctibor --command "/usr/bin/git config --global user.email \"ctibor@brancik.cz\"" +fi + +if [ $# != 2 ]; then + echo "Usage sync-rpi-config <device> <action>. Action can be either push or pull." + exit 1; +fi + +case $1 in + alcor-01|alcor-02|alcor-03) + root="/usr/armv6j-hardfloat-linux-gnueabi/";; + mizar) + root="/usr/armv7a-hardfloat-linux-gnueabi/";; + alioth) + root="/usr/aarch64-unknown-linux-gnu/";; + *) + echo "Usage sync-rpi-config <device> <action>." + exit 1;; +esac + +case $2 in + push) + echo "Pushing config files to overlay folder ..." + /usr/bin/rsync -v --files-from ${root}/etc/portage/filelist_sync --recursive ${root} ${repo}/conf/${device} -- + cd ${repo} + su ctibor --command "/usr/bin/git pull" + su ctibor --command "/usr/bin/git commit -a -m \"Update portage config for ${device} $(date +%Y%m%d-%H%M%S)\"" + su ctibor --command "/usr/bin/git push";; + pull) + echo "Pulling config files from overlay folder ..." + cd ${repo} + su ctibor --command "/usr/bin/git pull" + /usr/bin/rsync -v --files-from ${root}/etc/portage/filelist_sync --recursive ${repo}/conf/${device} ${root} --;; + *) + echo "Usage sync-rpi-config <device> <action>." + exit 1;; +esac + +function cleanup { + rm -r /tmp/rpi-config +} + +trap cleanup EXIT; |