aboutsummaryrefslogtreecommitdiffsponsor
diff options
context:
space:
mode:
-rwxr-xr-xmirror.sh58
1 files changed, 58 insertions, 0 deletions
diff --git a/mirror.sh b/mirror.sh
new file mode 100755
index 0000000..2463115
--- /dev/null
+++ b/mirror.sh
@@ -0,0 +1,58 @@
+#!/bin/bash
+#
+# TODO: Make this work with data only.
+# TODO: Restrict permissions to git from the home user.
+# TODO: Work both remotely and locally.
+# TODO: Ability to add / remove repositories
+# TODO: Support key verification.
+# TODO: Support keyrings for different projects.
+
+mirror_files() {
+ TARGET=/mnt/hd/mirror
+
+ RSYNC_OPTS="\
+ --delete-excluded \
+ --hard-links \
+ --links \
+ --perms \
+ --recursive \
+ --safe-links \
+ --sparse \
+ --times \
+ "
+
+ # Slackware
+ rsync $RSYNC_OPTS rsync://mirrors.kernel.org/slackware/slackware-15.0 "$TARGET/slackware/."
+ rsync $RSYNC_OPTS rsync://mirrors.kernel.org/slackware/slackware-15.0-iso "$TARGET/slackware/."
+ rsync $RSYNC_OPTS rsync://mirrors.kernel.org/slackware/slackware-current "$TARGET/slackware/."
+ rsync $RSYNC_OPTS rsync://mirrors.kernel.org/slackware/slackware64-15.0 "$TARGET/slackware/."
+ rsync $RSYNC_OPTS rsync://mirrors.kernel.org/slackware/slackware64-15.0-iso "$TARGET/slackware/."
+ rsync $RSYNC_OPTS rsync://mirrors.kernel.org/slackware/slackware64-current "$TARGET/slackware/."
+
+ # Taler
+ rsync $RSYNC_OPTS rsync://mirror.cedia.org.ec/gnu/gnunet "$TARGET/."
+ rsync $RSYNC_OPTS rsync://mirror.cedia.org.ec/gnu/taler "$TARGET/."
+}
+
+mirror_git() {
+ TARGET=/srv/git/slackcoder
+
+ for fp in $(find $TARGET -name 'description' | xargs grep -l 'Mirror of' | xargs -n1 dirname); do
+ (cd $fp && \
+ echo $fp && \
+ git fetch origin "$(git branch --show-current)"
+ )
+ done
+}
+
+case "$1" in
+'files')
+ mirror_files
+ ;;
+'git')
+ mirror_git
+ ;;
+*)
+ echo "usage $0 files|git"
+esac
+