From c960b60cc150a5abfe1b9f9eccfc5684adfd8a6b Mon Sep 17 00:00:00 2001 From: Michael Murtaugh Date: Wed, 27 May 2020 10:54:17 +0200 Subject: [PATCH] webhook --- webhook.cgi | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 webhook.cgi diff --git a/webhook.cgi b/webhook.cgi new file mode 100755 index 0000000..92b9cee --- /dev/null +++ b/webhook.cgi @@ -0,0 +1,32 @@ +#!/bin/bash + +echo "Content-type: text/html" +echo +if [ "$REQUEST_METHOD" = "POST" ]; then +if [ "$CONTENT_TYPE" = "application/json" ]; then +SECRET=$(jq -r ".secret") +if [ $SECRET = "SECRET" ]; then + +cd /var/www/html/12 +git pull +make +# cat > /usr/lib/cgi-bin/webhook.json +# read -n "$CONTENT_LENGTH" QUERY_STRING_POST + +else +echo BAD SECRET +fi +else +echo NOT JSON +fi +else +echo NOT POST +fi +echo "done" + +# Example: Using backslashes to do multiline... +# src: https://riptutorial.com/bash/example/29665/request-method--post--w-json +# echo "
Script Error:"\ +# "
Usage error, cannot complete request, REQUEST_METHOD!=GET."\ +# "
Check your FORM declaration and be sure to use METHOD=\"GET\".
" +# exit 1