From e0ed7833a1af403913b34b5fdb33fcb017961c2f Mon Sep 17 00:00:00 2001 From: casjay Date: Sun, 30 Nov 2025 18:26:28 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Update=20codebase=20?= =?UTF-8?q?=F0=9F=97=83=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rootfs/usr/local/bin/update-httpd-files rootfs/usr/share/httpd/default/index.php --- rootfs/usr/local/bin/update-httpd-files | 116 +++++++++++++++++++++++ rootfs/usr/share/httpd/default/index.php | 2 + 2 files changed, 118 insertions(+) create mode 100755 rootfs/usr/local/bin/update-httpd-files diff --git a/rootfs/usr/local/bin/update-httpd-files b/rootfs/usr/local/bin/update-httpd-files new file mode 100755 index 0000000..6ec8150 --- /dev/null +++ b/rootfs/usr/local/bin/update-httpd-files @@ -0,0 +1,116 @@ +#!/usr/bin/env bash +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +##@Version : 202511300100-git +# @@Author : Jason Hempstead +# @@Contact : jason@casjaysdev.pro +# @@License : WTFPL +# @@ReadME : update-httpd-files --help +# @@Copyright : Copyright: (c) 2025 Jason Hempstead, Casjays Developments +# @@Created : Sunday, Nov 30, 2025 01:00 EST +# @@File : update-httpd-files +# @@Description : Update httpd files with last updated timestamp and DNS server status +# @@Changelog : New script +# @@TODO : Better documentation +# @@Other : +# @@Resource : +# @@Terminal App : no +# @@sudo/root : no +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# shellcheck shell=bash +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +# Default directories to process +DEFAULT_DIRS="/usr/share/httpd/default /data/htdocs/www" + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Show help +__show_help() { + cat </dev/null 2>&1 || [ -f "/run/init.d/named.pid" ]; then + dns_status_text="😺 DNS Server Status: Running 😺" + else + dns_status_text="🛑 DNS Server Status: Stopped 🛑" + fi + + # Replace placeholders in all files under httpd directory + [ -d "$httpd_dir" ] || return 0 + find "$httpd_dir" -type f \( -name "*.html" -o -name "*.htm" -o -name "*.php" -o -name "*.md" -o -name "*.txt" \) \ + -exec sed -i "s|REPLACE_LAST_UPDATED_ON|$last_updated|g" {} \; \ + -exec sed -i "s|Last updated on:.*|Last updated on: $last_updated|g" {} \; \ + -exec sed -i "s|REPLACE_DNS_SERVER_STATUS|$dns_status_text|g" {} \; \ + -exec sed -i "s|😺 DNS Server Status:.*😺|$dns_status_text|g" {} \; \ + -exec sed -i "s|🛑 DNS Server Status:.*🛑|$dns_status_text|g" {} \; 2>/dev/null + + [ "$QUIET" != "true" ] && echo "Processed directory: $httpd_dir" + return 0 +} + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +# Main +QUIET="false" +DIRS=() + +# Parse arguments +while [ $# -gt 0 ]; do + case "$1" in + -h|--help) + __show_help + ;; + -q|--quiet) + QUIET="true" + shift + ;; + -*) + echo "Unknown option: $1" >&2 + exit 1 + ;; + *) + DIRS+=("$1") + shift + ;; + esac +done + +# Use default directories if none specified +if [ ${#DIRS[@]} -eq 0 ]; then + for dir in $DEFAULT_DIRS; do + DIRS+=("$dir") + done +fi + +# Process each directory +for dir in "${DIRS[@]}"; do + __update_httpd_files "$dir" +done + +exit 0 diff --git a/rootfs/usr/share/httpd/default/index.php b/rootfs/usr/share/httpd/default/index.php index bea273b..7f5aafb 100644 --- a/rootfs/usr/share/httpd/default/index.php +++ b/rootfs/usr/share/httpd/default/index.php @@ -67,6 +67,8 @@ SERVER Address:
+

REPLACE_DNS_SERVER_STATUS

+

Last updated on: REPLACE_LAST_UPDATED_ON