aboutsummaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-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