aboutsummaryrefslogtreecommitdiff
path: root/share/hydractl
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-11-08 15:06:43 -0200
committerSilvio Rhatto <rhatto@riseup.net>2016-11-08 15:06:43 -0200
commit2d3a2cd3d01e43c6e3c1a6eebad26bdf2a422d5a (patch)
tree03e05bd4354d27af213c722647b78f427b4a6a33 /share/hydractl
parent5fda688cf3676d64ee2cfa65902d4523e52c6eeb (diff)
downloadhydra-2d3a2cd3d01e43c6e3c1a6eebad26bdf2a422d5a.tar.gz
hydra-2d3a2cd3d01e43c6e3c1a6eebad26bdf2a422d5a.tar.bz2
Initial logic for a sync-media-remotes
Diffstat (limited to 'share/hydractl')
-rwxr-xr-xshare/hydractl/sync-media-remotes51
-rwxr-xr-xshare/hydractl/sync-tpc4
2 files changed, 55 insertions, 0 deletions
diff --git a/share/hydractl/sync-media-remotes b/share/hydractl/sync-media-remotes
new file mode 100755
index 0000000..fd69708
--- /dev/null
+++ b/share/hydractl/sync-media-remotes
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# Keep git remotes in sync among media archives.
+#
+
+# Parameters
+BASENAME="$0"
+DEST="$1"
+MEDIA="/var/cache/media"
+
+# Syntax
+if [ -z "$DEST" ]; then
+ echo "usage: $BASENAME <dest>"
+ exit 1
+elif [ ! -d "$DEST/$MEDIA" ]; then
+ echo "folder $DEST/$MEDIA does not exist."
+ exit 1
+fi
+
+# TODO
+echo "Needs work!"
+exit
+
+# Run
+for folder in `ls $MEDIA`; do
+ if [ -d "$DEST/$MEDIA/$folder/.git" ]; then
+ git -C $MEDIA/$folder remote -v | grep "(fetch)" | sed -e 's/(fetch)//' | while read remote; do
+ (
+ cd $DEST/$MEDIA/$folder
+ name="`echo $remote | cut -d ' ' -f 1`"
+ url="`echo $remote | cut -d ' ' -f 2`"
+
+ # Add and update
+ if [ "$name" != "all" ]; then
+ if ! git remote | grep -q "^$name$" ]; then
+ git remote add $remote
+ else
+ oldurl="`git remote -v | grep "^$name$" | grep "(fetch)" | cut -d ' ' -f 2`"
+
+ if [ "$url" != "$oldurl" ]; then
+ git remote set-url $name --delete $oldurl
+ git remote set-url $name --add $url
+ fi
+ fi
+ fi
+
+ # Remove dangling remotes
+ )
+ done
+ fi
+done
diff --git a/share/hydractl/sync-tpc b/share/hydractl/sync-tpc
index ae1cd0b..bdedf35 100755
--- a/share/hydractl/sync-tpc
+++ b/share/hydractl/sync-tpc
@@ -6,6 +6,7 @@
# Parameters
BASENAME="$0"
DEST="$1"
+MEDIA="/var/cache/media"
# Syntax
if [ -z "$DEST" ]; then
@@ -40,3 +41,6 @@ $SUDO rsync -av --delete /var/lib/wicd/ $DEST/var/lib/wicd/
$SUDO cp -a /etc/network/interfaces $DEST/etc/network/interfaces
$SUDO cp -a /etc/wicd/manager-settings.conf $DEST/etc/wicd/manager-settings.conf
$SUDO cp -a /etc/udev/rules.d/70-persistent-net.rules $DEST/etc/udev/rules.d/70-persistent-net.rules
+
+# Sync media remotes
+hydractl sync-media-remotes $DEST