summaryrefslogtreecommitdiff
path: root/mirror.sh
blob: 4ded04215c178b3c6adcb339d24a1c9ce235acc4 (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
#!/bin/sh
_path() {
	local path="$(url %h%p $1)"
	case "${path}" in
		*.git) echo "${path}";;
		*) echo "${path}.git";;
	esac
}


_update() {
	local repo="$1"
	local path="$(_path ${repo})"
	test -d "${path}" || git clone -q --mirror "${repo}" "${path}"
	git -C "${path}" fetch -q && echo "Updated ${path}" || echo "Failed to update ${path}"
}


list="${1:-repositories.list}"
test -f "${list}" || exit 1
while read repo; do
	_update "${repo}" &
done <"${list}"
wait