From 75db6d795d689e28560aa7e6b3d471c89983191a Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Tue, 18 Aug 2026 08:44:12 +0800 Subject: CGI deploy script. --- deploy.cgi.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 deploy.cgi.sh (limited to 'deploy.cgi.sh') diff --git a/deploy.cgi.sh b/deploy.cgi.sh new file mode 100644 index 0000000..4ccd5de --- /dev/null +++ b/deploy.cgi.sh @@ -0,0 +1,60 @@ +#!/bin/sh +# +# Sets up /var/www/cgi-bin/lex.cgi and its supporting directory tree +# under /var/www/var/lex. + +set -eu + +# source location: current directory +SRCDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) + +if [ "$(id -u)" -ne 0 ]; then + echo "ERROR: operation not permitted" >&2 + exit 1 +fi + +if [ ! -d "/var/www/cgi-bin" ]; then + echo "ERROR: /var/www/cgi-bin does not exist." >&2 + exit 1 +fi + +if [ ! -f "$SRCDIR/lex.cgi" ]; then + echo "ERROR: source file not found: $SRCDIR/lex.cgi" >&2 + exit 1 +fi + +if [ ! -f "$SRCDIR/pubring.gpg" ]; then + echo "ERROR: source file not found: $SRCDIR/pubring.gpg" >&2 + exit 1 +fi + +# directory tree +mkdir -p "/var/www/var" +chmod 755 "/var/www/var" +chown root:daemon "/var/www/var" + +mkdir -p "/var/www/var/lex" +chmod 710 "/var/www/var/lex" +chown www:tool "/var/www/var/lex" + +mkdir -p "/var/www/var/log" +chmod 1770 "/var/www/var/log" +chown www:tool "/var/www/var/log" + +mkdir -p "/var/www/var/lex/locks" +chmod 750 "/var/www/var/lex/locks" +chown www:www "/var/www/var/lex/locks" + +# pubring.gpg +cp -f "$SRCDIR/pubring.gpg" "/var/www/var/lex/pubring.gpg" +chmod 440 "/var/www/var/lex/pubring.gpg" +chown www:tool "/var/www/var/lex/pubring.gpg" +echo "copied: $SRCDIR/pubring.gpg -> /var/www/var/lex/pubring.gpg" + +# lex.cgi +cp -f "$SRCDIR/lex.cgi" "/var/www/cgi-bin/lex.cgi" +chmod 755 "/var/www/cgi-bin/lex.cgi" +chown root:daemon "/var/www/cgi-bin/lex.cgi" +echo "copied: $SRCDIR/lex.cgi -> /var/www/cgi-bin/lex.cgi" + +echo "done." -- cgit v1.2.3