create.sh (1891B)
1 #!/bin/sh 2 # Makes static pages for each repository directory 3 # https://codemadness.org/git/stagit/file/example_create.sh.html 4 5 # path must be absolute. 6 stagitsrc="/opt/stagit" 7 reposdir="/srv/git" 8 stagitdir="/var/www/localhost/htdocs" 9 10 # copy style files. 11 cp "${stagitsrc}/favicon.png" "${stagitdir}/" 12 cp "${stagitsrc}/style.css" "${stagitdir}/" 13 cp "${stagitsrc}/logo.png" "${stagitdir}/" 14 15 cd "${stagitdir}" 16 17 # make index. 18 stagit-index "${reposdir}/"*/ > "${stagitdir}/index.html" 19 20 # make files per repo. 21 for dir in "${reposdir}/"*/; do 22 # strip .git suffix. 23 r=$(basename "${dir}") 24 d=$(basename "${dir}" ".git") 25 printf "%s... " "${d}" 26 27 if [ -f "${reposdir}/${r}/git-daemon-export-ok" ]; then 28 # create stagit static repo files for published repos. 29 mkdir -p "${stagitdir}/${d}" 30 cd "${stagitdir}/${d}" || continue 31 32 # set post-recieve hook, owner and description 33 cp -f "${stagitsrc}/example_post-receive.sh" "${reposdir}/${r}/hooks/post-receive" 34 chmod +x "${reposdir}/${r}/hooks/post-receive" 35 if [ ! -f "${reposdir}/${r}/owner" ]; then echo "in0rdr" > "${reposdir}/${r}/owner"; fi 36 if [ ! -f "${reposdir}/${r}/description" ]; then echo "No description." > "${reposdir}/${r}/description"; fi 37 if [ ! -f "${reposdir}/${r}/url" ]; then echo "https://git.in0rdr.ch/${r}" > "${reposdir}/${r}/url"; fi 38 39 stagit -c ".cache" -u "https://git.in0rdr.ch/$d/" "${reposdir}/${r}" 40 41 # symlinks 42 ln -sf log.html index.html 43 ln -sf ../style.css style.css 44 ln -sf ../logo.png logo.png 45 ln -sf ../favicon.png favicon.png 46 else 47 # unpublish repos. 48 rm -rf "${stagitdir}/${d}" 49 fi 50 51 echo "done" 52 done 53 54 # ensure webserver permissions. 55 chown -R apache: "${stagitdir}" 56 chown -R apache: "${reposdir}"