aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2021-11-09 19:20:27 +0100
committerMichał Górny <mgorny@gentoo.org>2021-11-09 19:20:27 +0100
commit76ef821a35c6ac43665c4909b298a67cc9237bb1 (patch)
tree06a049aaffd7db8b0c986e85c828c69a3cb98e93
parenthtdocs/index.html: add "(orphaned)" to maintainer-needed caption (diff)
downloadqa-scripts-master.tar.gz
qa-scripts-master.tar.bz2
qa-scripts-master.zip
Add a cgi script to trigger git pulls remotelyHEADmaster
Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rwxr-xr-xcgi-bin/trigger-pull.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/cgi-bin/trigger-pull.sh b/cgi-bin/trigger-pull.sh
new file mode 100755
index 0000000..89aff7a
--- /dev/null
+++ b/cgi-bin/trigger-pull.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+
+if [[ ! ${QUERY_STRING} ]]; then
+ echo "Script must be run through CGI" >&2
+ exit 1
+fi
+
+main() {
+ local repo=${QUERY_STRING}
+ if [[ ${repo} == */* ]]; then
+ echo "DANGER! DANGER! DON'T TALK TO STRANGERS!" >&2
+ exit 1
+ fi
+
+ local topdir=$(dirname "${0}")/..
+
+ if ! cd "${topdir}/htdocs/output/${repo}" 2>/dev/null; then
+ echo "Status: 404 Not Found"
+ echo
+ echo "404 Not Found"
+ exit 0
+ fi
+
+ local output=$(git pull -q 2>&1)
+ if [ $? -eq 0 ]; then
+ echo "Status: 200 OK"
+ echo
+ echo "Done."
+ else
+ echo "Status: 500 Failed"
+ echo
+ echo "${output}"
+ fi
+}
+
+main