summaryrefslogtreecommitdiffstats
path: root/mirror
blob: 3a9fd13787abafc22645f6f21223797b6d18d6d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash

cd $(dirname $0)

case "$1" in

help) echo -e "\nOptions: save resto diff add on off status https\n"
	;;

add) if [ -z "$2" ]; then
		echo "Missing mirror path"
		exit 1
	fi
	for fic in */{6,7,8,??}/*/mirror */{?,??}/*/*/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|https://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 */{6,7,8,??}/*/mirror */{?,??}/*/*/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 */{6,7,8,??}/*/mirror */{?,??}/*/*/mirror
	do
		if grep -q "^http.*$2" $fic
		then
			echo "Fix in $fic"
			sed -e "\@$2@s/^/## /" -i $fic
		fi
	done
	;;

del) if [ -z "$2" ]; then
		echo "Missing mirror path"
		exit 1
	fi
	for fic in */{6,7,8,??}/*/mirror */{?,??}/*/*/mirror
	do
		if grep -q "$2" $fic
		then
			echo "Removed from $fic"
			sed -e "\@$2@d" -i $fic
		fi
	done
	;;

status) if [ -z "$2" ]; then
		echo "Missing mirror path"
		exit 1
	fi
	grep -- "$2" */{6,7,8,??}/*/mirror */{?,??}/*/*/mirror
	;;

https)
	echo "Generating https mirror list"
	for i in enterprise/{6,7}/*/mirror */{?,??}/*/*/mirror
	do
		j=$(dirname $i)/httpsmirror
		grep '^https' $i >$j
		grep 'remirepo.net' $i | sed -e 's/^http:/https:/' >>$j
	done
	;;

*) 	echo -e "\nMirror list:\n"
	cat enterprise/7/remi/mirror
	;;

esac