stagit- static git page generator |
git clone git://git.acid.vegas/stagit.git |
Log | Files | Refs | Archive | README | LICENSE |
helper (1967B)
1 #!/bin/sh 2 # stagit setup helper - developed by acidevegas (https://git.acid.vegas/stagit) 3 # debian : sudo apt-get install libgit2-1.1 libmd4c* 4 # arch : sudo pacman -S libgit2 md4c 5 6 URL="git.acid.vegas" 7 PROTO="https" 8 CLONE_URL="git://$URL" 9 COMMIT_LIMIT=100 10 HTML_DIR="/srv/http" 11 REPOS_DIR="/srv/git" 12 13 prepair() { 14 [ -d $HTML_DIR ] && rm -rf $HTML_DIR/* 15 mkdir -p $HTML_DIR/assets 16 echo "[~] populating custom assets..." 17 cp acidvegas.png favicon.png logo.png mostdangerous.png style.css $HTML_DIR/assets 18 } 19 20 make_index() { 21 echo "[~] creating index..." 22 args="" 23 for category in $(cat /srv/git/*/owner | xargs -n1 | sort -u | xargs); do 24 echo "[~] indexing '$category' repositories..." 25 REPOS=$(grep -rl "$category" /srv/git/*/owner | xargs -I{} dirname {} | sort -f | tr '\n' ' ') 26 args="$args -c \"$category\" $REPOS" 27 done 28 echo "$args" | xargs stagit-index > $HTML_DIR/index.html 29 } 30 31 make_repo() { 32 REPO=$(basename "$(echo "$1" | sed 's/\.git$//')") 33 if [ -f $1/description ]; then 34 if [ "$(cat $1/description)" = "Unnamed repository; edit this file 'description' to name the repository." ]; then 35 read -p "description for '$REPO':" desc 36 echo "$desc" > $1/description 37 echo "[+] updated default 'description' file for '$REPO'" 38 fi 39 else 40 read -p "description for '$REPO':" desc 41 echo "$desc" > $1/description 42 echo "[+] added missing 'description' file for '$REPO'" 43 fi 44 if [ ! -f $1/url ]; then 45 echo "$CLONE_URL/$REPO.git" > $1/url 46 echo "[+] added missing 'url' file for '$REPO'" 47 fi 48 echo "[~] processing '$REPO' repository..." 49 mkdir -p $HTML_DIR/$REPO && cd $HTML_DIR/$REPO && stagit -l $COMMIT_LIMIT -u "$PROTO://$URL/$REPO" $1 50 ln -sf log.html index.html 51 git --git-dir $1 archive --format=tar.gz -o "$HTML_DIR/$REPO/archive.tar.gz" --prefix="$REPO/" HEAD 52 } 53 54 make_all_repos() { 55 for dir in $(find $REPOS_DIR -type d -name "*.git" | sort); do 56 make_repo $dir 57 done 58 } 59 60 # Main 61 prepair 62 make_all_repos 63 make_index