diff options
Diffstat (limited to 'mirror.sh')
-rw-r--r-- | mirror.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/mirror.sh b/mirror.sh new file mode 100644 index 0000000..4ded042 --- /dev/null +++ b/mirror.sh @@ -0,0 +1,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 |