Files
litespeed-server-appliance/data.sh
2025-08-10 12:09:07 -04:00

68 lines
2.1 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env bash
# data.sh - perappliance metadata & postinstall actions
# For Baldnerd's Appliance Builder
#
# Usage:
# ./data.sh description # print short About text (plain text)
# ./data.sh post-install # optional: run postinstall 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://<your-host>: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 <<INFO
Admin UI: https://<your-host>:7080/
Site root: /var/www/html
Service: lsws (systemctl status lsws)
INFO
}
case "${1:-}" in
description)
cat <<DESC
${APPLIANCE_NAME}
${APPLIANCE_DESC}
DESC
;;
post-install) post_install_tasks ;;
help|--help|-h)
echo "Usage: $0 {description|post-install|help}"
;;
*) echo "Usage: $0 {description|post-install|help}"; exit 2 ;;
esac