summaryrefslogtreecommitdiff
path: root/tools/sync-rpi-config.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tools/sync-rpi-config.sh')
-rw-r--r--tools/sync-rpi-config.sh52
1 files changed, 52 insertions, 0 deletions
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;