From 9d0341b2a262fcc364a9a4dc2bb0a5872b86f21c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ctibor=20Bran=C4=8D=C3=ADk?= Date: Sun, 18 Jun 2017 17:34:53 +0200 Subject: Add script for syncying configuration on host machine --- tools/sync-conf.sh | 15 +++++++------- tools/sync-rpi-config.sh | 52 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 tools/sync-rpi-config.sh (limited to 'tools') 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 . 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 ." + 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 ." + exit 1;; +esac + +function cleanup { + rm -r /tmp/rpi-config +} + +trap cleanup EXIT; -- cgit v1.2.3