mirrorer

:)
git clone https://git.sr.ht/~ashymad/mirrorer
Log | Files | Refs | LICENSE

mirror.sh (966B)


      1 #!/bin/sh
      2 
      3 set -e
      4 
      5 while read line; do
      6     srepo="$(echo "$line" | cut -d' ' -f1)"
      7 
      8     if [ -d "$srepo" ]; then
      9         srepourl="$(git -C "$srepo" remote get-url origin)"
     10     else
     11         srepourl="$srepo"
     12     fi
     13 
     14     reponame="$(echo "$srepourl" |  sed 's@.*/@@')"
     15     owner="$(echo "$srepourl" | sed 's@.*/\(.*\)/.*@\1@')"
     16     srepodir="$PWD/git/$reponame"
     17     wrepodir="$PWD/web/$reponame"
     18 
     19     if [ -d "$srepodir" ]; then
     20         git -C "$srepodir" remote update
     21     else
     22         git clone --mirror "$srepo" "$srepodir"
     23     fi
     24 
     25     for drepo in $(echo "$line" | cut -d' ' -f2-); do
     26         git -C "$srepodir" push --mirror "$drepo"
     27     done
     28 
     29     echo "$owner" > "$srepodir/owner"
     30     echo "$srepourl" > "$srepodir/url"
     31     echo ":)" > "$srepodir/description"
     32 
     33     mkdir -p "$wrepodir"
     34     cp style.css logo.png "$wrepodir"
     35     ( cd "$wrepodir"; stagit "$srepodir"; )
     36 done < mirrorlist
     37 
     38 cp favicon.png style.css logo.png web
     39 stagit-index git/* > web/index.html