summaryrefslogtreecommitdiffstats
path: root/mirror
diff options
context:
space:
mode:
authorRemi Collet <fedora@famillecollet.com>2015-12-18 10:33:16 +0100
committerRemi Collet <fedora@famillecollet.com>2015-12-18 10:33:16 +0100
commit4638f990ceb4b314ce15ddfcfeeb638432273c95 (patch)
tree8acbc0379ef0919d13c85483dd3e5a517b6f8473 /mirror
parentdaef766c2a953e4db3e9a69cbff8bf7a67788f85 (diff)
initial import
Diffstat (limited to 'mirror')
-rwxr-xr-xmirror95
1 files changed, 95 insertions, 0 deletions
diff --git a/mirror b/mirror
new file mode 100755
index 00000000..dd8d8011
--- /dev/null
+++ b/mirror
@@ -0,0 +1,95 @@
+#!/bin/bash
+
+cd $(dirname $0)
+
+case "$1" in
+
+help) echo -e "\nOptions: save resto diff add on off status\n"
+ ;;
+
+save) echo -n "Saving mirror definition..."
+ tar cf - */{?,??}/*/mirror | tar xvf - -C save/
+ echo " Done"
+ ;;
+
+resto) echo -n "Restoring mirror definition..."
+ tar cf - -C save */{?,??}/*/mirror | tar xvf -
+ echo " Done"
+ ;;
+
+diff) echo "Pending changes in mirror definition:"
+ n=0
+ for fic in */{?,??}/*/mirror
+ do
+ if ! diff -q save/$fic $fic >/dev/null; then
+ echo "=== $fic"
+ colordiff -a save/$fic $fic
+ n=$(expr $n + 1)
+ fi
+ done
+ [ $n -eq 0 ] && echo "None"
+ ;;
+
+add) if [ -z "$2" ]; then
+ echo "Missing mirror path"
+ exit 1
+ fi
+ for fic in fedora/??/*/mirror enterprise/{5,6,7}/*/mirror
+ do
+ n=0
+ if grep -q "/archives/" $fic
+ then
+ continue
+ fi
+ if ! grep -q "^$2" $fic
+ then
+ grep remirepo.net $fic | \
+ sed -e "s|http://rpms.remirepo.net|$2|" >>$fic
+ if grep $2 $fic
+ then
+ echo "Add in $fic"
+ n=$(expr $n + 1)
+ fi
+ fi
+ done
+ [ $n -eq 0 ] && echo "None"
+ ;;
+
+on) if [ -z "$2" ]; then
+ echo "Missing mirror path"
+ exit 1
+ fi
+ for fic in */{?,??}/*/mirror
+ do
+ if grep -q "^## .*$2" $fic
+ then
+ echo "Fix in $fic"
+ sed -e "\@$2@s/^## //" -i $fic
+ fi
+ done
+ ;;
+
+off) if [ -z "$2" ]; then
+ echo "Missing mirror path"
+ exit 1
+ fi
+ for fic in */{?,??}/*/mirror
+ do
+ if grep -q "^http.*$2" $fic
+ then
+ echo "Fix in $fic"
+ sed -e "\@$2@s/^/## /" -i $fic
+ fi
+ done
+ ;;
+
+status) if [ -z "$2" ]; then
+ echo "Missing mirror path"
+ exit 1
+ fi
+ grep -- "$2" */{?,??}/*/mirror
+ ;;
+ *) echo -e "\nMirror list:\n"
+ cat enterprise/7/remi/mirror
+ ;;
+esac