]> git.armaanb.net Git - bin.git/blobdiff - git-mirror
signal-finder: add script
[bin.git] / git-mirror
index 6457db6c27eeb29bc672bcff33aa5f1db3f240c8..6d3f00cad6a7e6810d7b72deefd9834796909630 100755 (executable)
@@ -1,9 +1,10 @@
-#!/usr/bin/sh
+#!/usr/bin/env sh
 # Mirror some Git repos
 
 usage() {
   echo 'Usage: git-mirror [command] [arguments]
   git-mirror run [path to repos] [path to log file] [html directory]
+      optional: [sleep duration]
   git-mirror gen-url [path to repo] -- generate url file in repo
   git-mirror help -- show this message
 
@@ -19,50 +20,52 @@ run() {
   cd ${1}
 
   [ -d ${3} ] || mkdir ${3}
-  cd ${3} && stagit-index
-  cp /usr/share/doc/stagit/style.css ${3}
+  cd ${3}
 
   while :; do
-      for dir in "${1}/*.git"; do
+    stagit-index ${1}/*
+    find "$1" -name '*.git' -type d | \
+      while read dir; do
         newdir=${3}/$(basename ${dir} .git)
         [ -d ${newdir} ] || mkdir ${newdir}
         cd ${newdir}
         stagit ${dir}
+        cp "$1/logo.png" .
+        ln -s logo.png favicon.png
         find . -type f \( -name '*.html' -or -name '*.xml' \) | \
           while read i ; do
             minify ${i} > ${i}.tmp
             mv ${i}.tmp ${i}
           done
-        cp /usr/share/doc/stagit/style.css .
-        git -C ${dir} fetch --tags
-        echo $(date -Iseconds) ' | ' ${dir} | tee -a ${2}
-        echo $(tail -n 1500 ${2}) > ${2}
+          git -C ${dir} fetch --tags
+          echo $(date -Iseconds) ' | ' ${dir} | tee -a ${2}
+          echo $(tail -n 1500 ${2}) > ${2}
+        done
+        sleep ${4:-600}
       done
-    sleep 600
-  done
-}
+    }
 
-gen_url() {
-  find ${1} -maxdepth 2 -name '*.git' | \
-    while read dir; do
-      $(git -C $dir remote get-url origin) > $dir/url
-    done
-}
+  gen_url() {
+    find ${1} -maxdepth 2 -name '*.git' | \
+      while read dir; do
+        $(git -C $dir remote get-url origin) > $dir/url
+      done
+    }
 
-case ${1} in
-  -h | --help | help)
-    usage
-    ;;
-  run)
-    shift 1
-    run $@
-    ;;
-  gen-url)
-    shift 1
-    gen_url $@
-    ;;
-  *)
-    usage
-    exit 1
-    ;;
-esac
+  case ${1} in
+    -h | --help | help)
+      usage
+      ;;
+    run)
+      shift 1
+      run $@
+      ;;
+    gen-url)
+      shift 1
+      gen_url $@
+      ;;
+    *)
+      usage
+      exit 1
+      ;;
+  esac