From a5e984df5ed5ec7a04558cd7b33bae43c0547f7a Mon Sep 17 00:00:00 2001 From: turret Date: Mon, 2 Oct 2023 19:44:54 -0500 Subject: add current hooks --- github-mirror | 24 ++++++++++++++++++++++++ github-ssh-wrapper | 11 +++++++++++ website-maker | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100755 github-mirror create mode 100755 github-ssh-wrapper create mode 100755 website-maker diff --git a/github-mirror b/github-mirror new file mode 100755 index 0000000..9223975 --- /dev/null +++ b/github-mirror @@ -0,0 +1,24 @@ +#!/bin/sh +# based on https://cgit.gentoo.org/infra/githooks.git/plain/github-mirror/github-mirror + +# simple gitolite mirroring + +# flush STDIN coming from git, because gitolite's own post-receive.mirrorpush +# script does the same thing +[ -t 0 ] || cat >/dev/null + +if [ -z "${GL_REPO}" ]; then + echo "GL_REPO not set" >&2 + exit 1 +fi + +targets=$(git config --get mirror.url) +[ -z "${targets}" ] && exit 0 + +[ -z "${GIT_SSH_KEY}" ] && export GIT_SSH_KEY=$(git config --get mirror.pubkey) +export GIT_SSH=$(dirname "$(readlink -f "$0")")/github-ssh-wrapper + +for target in ${targets}; do + # --force because someone may accidentally push into the mirror + git push --mirror --force ${target} +done diff --git a/github-ssh-wrapper b/github-ssh-wrapper new file mode 100755 index 0000000..b05ff4f --- /dev/null +++ b/github-ssh-wrapper @@ -0,0 +1,11 @@ +#!/bin/sh +# also ripped from gentoo's githooks (they're simply awesome) + +# Use via GIT_SSH +# OBSOLETE!!! Github is terrible and requires old ciphers/kex/macs +#CIPHERS='-o Ciphers=chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc' +#KEX='-o KexAlgorithms=curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1' +#MACS='-o MACs=hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,hmac-sha1' + +# Now run it +exec ssh ${GIT_SSH_KEY:+-i} ${GIT_SSH_KEY} $CIPHERS $KEX $MACS "$@" diff --git a/website-maker b/website-maker new file mode 100755 index 0000000..9137c21 --- /dev/null +++ b/website-maker @@ -0,0 +1,44 @@ +#!/bin/sh +# this one i made myself +# website.dir - directory to output to +# website.standalone - used to inform pandoc that we are standalone mode +# (used with template.html in project /) +# .wbignore follows grep syntax +# you can see www/www.turret.cyou for an example project structure + +[ -t 0 ] || cat >/dev/null + +if [ -z "${GL_REPO}" ]; then + echo "GL_REPO not set" >&2 + exit 1 +fi + +target=$(git config --get website.dir) +[ -z "${target}" ] && exit 0 + +TMPDIR=$(mktemp -d) +chmod 755 "${TMPDIR}" + +cp . "${TMPDIR}/.git" -R + +cd "${TMPDIR}" +unset GIT_DIR +unset GIT_WORK_TREE +git config --unset core.bare +git checkout master -f +echo "WEBSITEBUILDER: generating html files" +files=$(find * -type f || exit 1) +[ -f .wbignore ] && files=$(echo -n "${files}" | grep -vf .wbignore) +for file in ${files}; do + outputfile="$(echo -n $file | rev | cut -d '.' -f2- | rev).html" + pandoc "${file}" $([ $(git config --get website.standalone || echo -n 0) -gt 0 ] && echo -n "--standalone $([ -f template.html ] && echo -n "--template template.html")") --ascii -o "${outputfile}" + rm "${file}" +done + +echo "WEBSITEBUILDER: deploying" +rm -Rf "${target}" || (echo "WEBSITEBUILDER: couldnt remove old website" && exit 1) +rm -Rf "${TMPDIR}/.git" +mv "${TMPDIR}" "${target}" || (echo "WEBSITEBUILDER: couldnt update website" && exit 1) +chmod -R a+rX "${target}" + +cd -- cgit v1.2.3