From ccef612f894308f8b3480ca05114e35f34e76a40 Mon Sep 17 00:00:00 2001 From: Slack Coder Date: Mon, 8 Apr 2024 15:29:11 -0500 Subject: Initial commit --- mirror.sh | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 mirror.sh 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 + -- cgit v1.2.3