aboutsummaryrefslogtreecommitdiff
path: root/regen.cgi
diff options
context:
space:
mode:
authorB Stack <bgstack15@gmail.com>2021-02-01 09:07:23 -0500
committerB Stack <bgstack15@gmail.com>2021-02-01 09:07:23 -0500
commita4481dc007ff202882b783ed4b36e03a8b4c1d05 (patch)
tree0f8b5ccb6ea5e966e8d517b07936479ef49b3516 /regen.cgi
downloadgallery-a4481dc007ff202882b783ed4b36e03a8b4c1d05.tar.gz
gallery-a4481dc007ff202882b783ed4b36e03a8b4c1d05.tar.bz2
gallery-a4481dc007ff202882b783ed4b36e03a8b4c1d05.zip
initial commit
Diffstat (limited to 'regen.cgi')
-rwxr-xr-xregen.cgi44
1 files changed, 44 insertions, 0 deletions
diff --git a/regen.cgi b/regen.cgi
new file mode 100755
index 0000000..8bdbc23
--- /dev/null
+++ b/regen.cgi
@@ -0,0 +1,44 @@
+#!/bin/sh
+# File: /mnt/public/www/cgi-bin/gallery/regen.cgi
+# Author: bgstack15@gmail.com
+# Startdate: 2021-01-24
+# SPDX-License-Identifier: GPL-3.0
+# Title: Regenerate static pages
+# Package: gallery
+# Purpose: run sigal.bin on web request
+# History:
+# Usage: visit this to run the static site generator
+# Reference:
+# ip-address.cgi
+# Improve:
+# Documentation:
+# Dependencies:
+# sudoers rules from 60_regen_gallery_sudo
+# selinux rules from gallery.te
+# sigal.bin
+# Reverse dependencies:
+# custom sigal theme
+DEBUG=0
+export meta="<meta" # for turning off the automatic reloads
+
+printf "%s\n\n" "Content-type: text/html"
+echo "<html><head><title>Regenerating...</title>"
+echo "</head><body>"
+test -n "${DEBUG}" && test "${DEBUG}" -ge 1 2>/dev/null && {
+ echo "<pre>"
+ env
+ echo "</pre>"
+}
+
+# find gallery_id from query string
+echo "${QUERY_STRING}" | grep -qE "(^|\&|\?)id=[^\&]+" && {
+ export gallery_id="$( echo "${QUERY_STRING}" | grep -oE "(^|\&|\?)id=[^\&]+" | awk -F'=' '{$1="";print;}' | sed -r -e 's:^ ::' )"
+}
+
+sudo /usr/local/bin/sigal.bin "${gallery_id}"
+result=$?
+test $result -eq 0 && {
+ echo "Success! Redirecting..."
+ echo "${meta} http-equiv=\"Refresh\" content=\"1; url='${HTTP_REFERER}'\" />"
+}
+printf '%s' "</body></html>"
bgstack15