From c72d8fe796c9d968ed09b9832ddaaaae2bd69200 Mon Sep 17 00:00:00 2001 From: baldnerd Date: Sun, 10 Aug 2025 12:09:07 -0400 Subject: [PATCH] Prep for appliance builder --- data.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100755 data.sh diff --git a/data.sh b/data.sh new file mode 100755 index 0000000..5ebbadf --- /dev/null +++ b/data.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bash +# data.sh - per‑appliance metadata & post‑install actions +# For Baldnerd's Appliance Builder +# +# Usage: +# ./data.sh description # print short About text (plain text) +# ./data.sh post-install # optional: run post‑install helpers (may use whiptail) +# ./data.sh help # show available commands +# +# Notes: +# - Keep output plain text (no ANSI) so TUI callers can display it cleanly. +# - If whiptail is available, as it is in Baldnerd's Appliance Builder, this +# script will use it automatically for menus/messages. +# - Post-install should be safe to re-run. Avoid destructive actions. + +set -Eeuo pipefail + +APPLIANCE_NAME="LiteSpeed Server Appliance" +APPLIANCE_DESC="The LiteSpeed Server Appliance is a fast, modern web server environment. It's perfect for hosting high-performance websites and apps, including but not limited to WordPress." + +has_cmd(){ command -v "$1" >/dev/null 2>&1; } +msg() { + if has_cmd whiptail && [[ -t 1 ]]; then + whiptail --title "${APPLIANCE_NAME}" --msgbox "$*" 14 78 + else + printf "%s\n" "$*" + fi +} + +post_install_tasks() { + # Offer to set the WebAdmin password + if [[ -x /usr/local/lsws/admin/misc/admpass.sh ]]; then + if has_cmd whiptail && [[ -t 1 ]]; then + if whiptail --yesno "Set the WebAdmin password now?" 10 60; then + /usr/local/lsws/admin/misc/admpass.sh || true + msg "WebAdmin password updated.\nOpen: https://:7080/" + else + msg "You can set it later by running: /usr/local/lsws/admin/misc/admpass.sh" + fi + else + # Non-interactive fallback + echo "To set WebAdmin password, run: /usr/local/lsws/admin/misc/admpass.sh" + fi + fi + + # Show quick info + cat <:7080/ +Site root: /var/www/html +Service: lsws (systemctl status lsws) +INFO +} + +case "${1:-}" in + description) + cat <