LibrePortal/scripts/menu/menu_main.sh
librelad 52e0227bb6 chore(cleanup): retire appGenerate — dead-on-arrival app-skeleton wizard
`libreportal app generate <name>` (and the menu's "g. Generate App" entry)
was broken three independent ways and incompatible with the per-app
architecture the project actually uses now:

  1. Copies from $install_containers_dir/template/ which doesn't exist —
     the only template/ in the tree was in scripts/unused/OLD_CONTAINERS/
     and was never installed into the live tree. cp -r would just fail.

  2. Every sed call used BSD/macOS syntax `sed -i '' -e …`. On Linux
     (every distro this targets) the empty '' becomes a positional file
     argument, so the substitutions never ran. 8 calls, all broken.

  3. Even if it had run, the produced skeleton would have been a
     pre-modular-tools / pre-per-port-subdomain app shape: no tools/,
     no scripts/ subdir, HOST_NAME=test in the .config. Every active
     containers/<app>/ today carries the modular layout the rest of the
     framework expects.

Plus the recent cleanups (the prompt loop fix in 9ffc8e4, the per-port
subdomain refactor in 2e4f420) had been peeling pieces off it without
the root question — does the function still belong? — getting asked.

Delete the whole surface:
  - scripts/app/app_generate.sh (157 lines, the function body)
  - scripts/unused/OLD_CONTAINERS/template/ (the never-installed source
    files appGenerate would have copied — stale enough to still carry
    HOST_NAME=test, CFG_<X>_HOST_NAME, and 248 lines of compose template)
  - menu entry "g. Generate App" + its dispatch in menu_main.sh
  - "generate" case branch in cli_app_commands.sh
  - `libreportal app generate` line in cli_app_header.sh
  - The corresponding entries auto-drop from files_app.sh +
    function_manifest.sh via regen.

New apps are added the way the catalog already grew — by hand-crafting
containers/<app>/{<app>.sh, <app>.config, docker-compose.yml,
tools/<app>.tools.json, scripts/<app>_*.sh}. Copying an existing app's
folder + renaming is the closest thing to a "generator" and it's a one-
command operation.

Net: -556 lines, no behaviour lost (the function never worked).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Signed-off-by: librelad <librelad@digitalangels.vip>
2026-05-26 23:48:35 +01:00

186 lines
4.3 KiB
Bash
Executable File

#!/bin/bash
mainMenu()
{
createSuccessfulRunFile;
# We will not show the menu if we are installing LibrePortal via the CLI install command
if [ "$install_via_cli" != "true" ]; then
# Enable input
stty echo
# Auto-fire the Setup Wizard on first entry so the menu never shows
# against a half-configured install.
if ! isSetupWizardComplete; then
setupWizardTerminal
fi
while true; do
isHeader "Install Menu"
isOption "i. Install Apps"
isOption "u. Uninstall Apps"
isHeader "Backup/Restore/Migrate"
isOption "b. Backup"
isOption "r. Restore"
isOption "m. Migrate"
isHeader "Tools/Other"
isOption "c. Configs"
isOption "d. Database"
isOption "s. Setup Wizard (re-run)"
status=$(dockerCheckAppInstalled "ufw" "linux")
if [ "$status" == "installed" ]; then
isOption "f. Firewall"
fi
isOption "h. Headscale"
isOption "l. Logs"
isOption "t. Tools"
isOption "y. YML Editor"
echo ""
isOption "x. Exit"
echo ""
isQuestion "What is your choice: "
read -rp "" choice
case $choice in
i)
appInstallMenu;
;;
u)
appUninstallMenu;
;;
s)
setupWizardReset;
setupWizardTerminal;
;;
b)
isHeader "Backup"
isOptionMenu "Single App Backup - Docker Container Folder (y/n): "
read -rp "" backupsingle
startOther;
;;
r)
isHeader "Restore"
echo "Please select 'l' for local restore."
echo "Please select 'r' for remote restore."
echo ""
isOptionMenu "Restore - App (l/r): "
read -rp "" restoresingle
startOther;
;;
m)
isHeader "Migrate"
echo "Migration is now handled by the restic engine."
echo "Available commands:"
echo " libreportal restore migrate discover [repo]"
echo " libreportal restore migrate app <app_name> <source_host> [repo]"
echo " libreportal restore migrate system <source_host> [repo]"
echo ""
;;
c)
viewConfigs;
;;
d)
isHeader "Database"
isOptionMenu "View Database Tables & Data? (y/n): "
read -rp "" toollistalltables
isOptionMenu "List all apps database? (y/n): "
read -rp "" toollistallapps
isOptionMenu "List all installed apps? (y/n): "
read -rp "" toollistinstalledapps
isOptionMenu "Update database with installed apps? (y/n): "
read -rp "" toolupdatedb
isOptionMenu "Empty a Database Tables? (y/n): "
read -rp "" toolemptytable
isOptionMenu "Delete database file? (y/n): "
read -rp "" tooldeletedb
startOther;
;;
h)
isHeader "Headscale"
isOptionMenu "Setup Tailscale Client for Localhost? (y/n): "
read -rp "" headscaleclientlocal
isOptionMenu "Setup Tailscale Client for a Specific App? (y/n): "
read -rp "" headscaleclientapp
isOptionMenu "Create User $CFG_INSTALL_NAME? (y/n): "
read -rp "" headscaleusercreate
isOptionMenu "Create API Key for $CFG_INSTALL_NAME? (y/n): "
read -rp "" headscaleapikeyscreate
isOptionMenu "List all API Keys? (y/n): "
read -rp "" headscaleapikeyslist
isOptionMenu "List all Nodes? (y/n): "
read -rp "" headscalenodeslist
isOptionMenu "List all Users? (y/n): "
read -rp "" headscaleuserlist
isOptionMenu "View Headscale Version? (y/n): "
read -rp "" headscaleversion
isOptionMenu "View/Edit Headscale Config File? (y/n): "
read -rp "" headscaleconfigfile
startOther;
;;
f)
isHeader "Firewall"
isOptionMenu "Allow specific port through the firewall? (y/n): "
read -rp "" firewallallowport
isOptionMenu "Block specific port through the firewall? (y/n): "
read -rp "" firewallblockport
isOptionMenu "Block port 22 (SSH)? (y/n): "
read -rp "" firewallblock22
isOptionMenu "Allow port 22 (SSH)? (y/n): "
read -rp "" firewallallow22
isOptionMenu "Update logging type for UFW based on Config? (y/n): "
read -rp "" firewallchangelogging
startOther;
;;
l)
viewLogs;
;;
t)
toolsMenu;
;;
y)
viewComposeFiles;
;;
i)
endStart;
;;
x)
exitScript;
;;
*)
isNotice "Invalid choice. Please select a valid option."
;;
esac
done
else
isSuccessful "LibrePortal successfully ran."
fi
}