diff options
Diffstat (limited to 'mirror.sh')
-rw-r--r-- | mirror.sh | 40 |
1 files changed, 31 insertions, 9 deletions
@@ -6,11 +6,39 @@ _version() { _usage() { - echo "Usage: $0 [-v] [list]" + echo "Usage: $0 [-v] [repositories]" exit 1 } >&2 +_interpret() { + while read type_ source_; do + case "${type_}" in + gitolite) _gitolite "${source_}" ;; + repo) echo "${source_}" ;; + '#'*) : ;; + *) { echo -n "${type_}"; [ -n "${source_}" ] && echo -n " ${source_}"; echo; } ;; + esac + done +} + + +_gitolite() { + { ssh -n "$1" info -p || return 1; } | awk -F'\t' '/^\s*R/{ print "'"$1"'/"$2 }' +} + + +_mirror() { + local failed=0 + while read repo; do + if ! _update "${repo}"; then + failed=1 + fi + done + return ${failed} +} + + _path() { local path="$(url %h%p $1)" case "${path}" in @@ -40,12 +68,6 @@ while getopts :v opt; do esac done shift $(( ${OPTIND} - 1 )) -list="${1:-repositories.list}" +list="${1:-repositories.mirror}" test -f "${list}" || exit 1 -failed=0 -while read repo; do - if ! _update "${repo}"; then # TODO: Parallelize this without DDOSing the hosts - failed=1 - fi -done <"${list}" -exit ${failed} +_interpret <"${list}" | _mirror |