Merge claude/2
This commit is contained in:
commit
e46c619d82
@ -1,118 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Category : Knowledge Management
|
||||
# Description : Linkding - Bookmark Manager (c/u/s/r/i):
|
||||
|
||||
installLinkding()
|
||||
{
|
||||
local config_variables="$1"
|
||||
|
||||
if [[ "$linkding" == *[cCtTuUsSrRiI]* ]]; then
|
||||
dockerConfigSetupToContainer silent linkding;
|
||||
local app_name=$CFG_LINKDING_APP_NAME
|
||||
initializeAppVariables $app_name;
|
||||
fi
|
||||
|
||||
if [[ "$linkding" == *[cC]* ]]; then
|
||||
editAppConfig $app_name;
|
||||
fi
|
||||
|
||||
if [[ "$linkding" == *[uU]* ]]; then
|
||||
dockerUninstallApp $app_name;
|
||||
fi
|
||||
|
||||
if [[ "$linkding" == *[sS]* ]]; then
|
||||
dockerComposeDown $app_name;
|
||||
fi
|
||||
|
||||
if [[ "$linkding" == *[rR]* ]]; then
|
||||
dockerComposeRestart $app_name;
|
||||
fi
|
||||
|
||||
if [[ "$linkding" == *[iI]* ]]; then
|
||||
isHeader "Install $app_name"
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
echo "---- $menu_number. Setting up install folder and config file for $app_name."
|
||||
echo ""
|
||||
|
||||
dockerConfigSetupToContainer "loud" "$app_name" "install" "$config_variables";
|
||||
isSuccessful "Install folders and Config files have been setup for $app_name."
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
echo "---- $menu_number. Setting up the $app_name docker-compose.yml file."
|
||||
echo ""
|
||||
|
||||
dockerComposeSetupFile $app_name;
|
||||
|
||||
local result=$(copyResource "$app_name" ".env" "")
|
||||
checkSuccess "Copying the .env for $app_name"
|
||||
|
||||
configSetupFileWithData $app_name ".env";
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
echo "---- $menu_number. Updating file permissions before starting."
|
||||
echo ""
|
||||
|
||||
fixPermissionsBeforeStart $app_name;
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
echo "---- $menu_number. Running the docker-compose.yml to install and start $app_name"
|
||||
echo ""
|
||||
|
||||
dockerComposeUpdateAndStartApp $app_name install;
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
echo "---- $menu_number. Running Application specific updates (if required)"
|
||||
echo ""
|
||||
|
||||
appUpdateSpecifics $app_name;
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
echo "---- $menu_number. Running Headscale setup (if required)"
|
||||
echo ""
|
||||
|
||||
setupHeadscale $app_name;
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
echo "---- $menu_number. Adding $app_name to the Apps Database table."
|
||||
echo ""
|
||||
|
||||
databaseInstallApp $app_name;
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
echo "---- $menu_number. Updating WebUI config file."
|
||||
echo ""
|
||||
|
||||
webuiContainerSetup $app_name install;
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
echo "---- $menu_number. You can find $app_name files at $containers_dir$app_name"
|
||||
echo ""
|
||||
echo " You can now navigate to your new service using one of the options below : "
|
||||
echo ""
|
||||
|
||||
LD_SUPERUSER_NAME=$(appGetKeyData "$app_name" ".env" "LD_SUPERUSER_NAME")
|
||||
LD_SUPERUSER_PASSWORD=$(appGetKeyData "$app_name" ".env" "LD_SUPERUSER_PASSWORD")
|
||||
|
||||
menuShowFinalMessages $app_name $LD_SUPERUSER_NAME $LD_SUPERUSER_PASSWORD;
|
||||
|
||||
menu_number=0
|
||||
#sleep 3s
|
||||
cd
|
||||
fi
|
||||
linkding=n
|
||||
}
|
||||
180
scripts/app/install/app_install.sh
Normal file
180
scripts/app/install/app_install.sh
Normal file
@ -0,0 +1,180 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Generic per-app install/uninstall/start/stop/restart/edit driver.
|
||||
#
|
||||
# The 31 containers/<app>/<app>.sh files used to each define their own
|
||||
# install<App>() with the SAME 10-step sequence. ~4,000 lines of duplicated
|
||||
# boilerplate. This is the one place that sequence lives now; per-app
|
||||
# customisation lands in declarative hooks in containers/<app>/tools/
|
||||
# <app>_tools.sh (or wherever the app's tools.sh lives — auto-sourced).
|
||||
#
|
||||
# Dispatch is driven by the `$<slug>` global variable (set by dockerInstallApp
|
||||
# in scripts/docker/app/functions/function_install_app.sh — `declare $app=i`).
|
||||
# Same convention the per-app .sh files used; nothing changes for the caller.
|
||||
# Actions are letters: c (config edit), u (uninstall), s (stop), r (restart),
|
||||
# i (install), t (treated like c — legacy alias).
|
||||
#
|
||||
# Hook surface — all are `declare -f`-gated, silent no-op when absent:
|
||||
#
|
||||
# <slug>_install_pre before any install work
|
||||
# <slug>_install_post_setup after dockerConfigSetupToContainer
|
||||
# (install folder + .config exist; compose
|
||||
# file not yet written)
|
||||
# <slug>_install_post_compose after dockerComposeSetupFile
|
||||
# (docker-compose.yml has been written +
|
||||
# tag-substituted; container not yet up)
|
||||
# <slug>_install_post_start after dockerComposeUpdateAndStartApp
|
||||
# (container is up; the place for
|
||||
# wait-for-ready + post-up API calls)
|
||||
# <slug>_install_message_data echoes extra args for menuShowFinalMessages
|
||||
# (typically credentials / URLs)
|
||||
# <slug>_install_post very last thing, after the final message
|
||||
#
|
||||
# <slug>_uninstall_pre / _post around dockerUninstallApp
|
||||
# <slug>_stop_post after dockerComposeDown
|
||||
# <slug>_restart_post after dockerComposeRestart
|
||||
#
|
||||
# Hooks receive $app_name as $1 (and stay un-namespaced — they're already
|
||||
# slug-prefixed). Return code is ignored unless they isError; the install
|
||||
# continues regardless. Use that escape hatch for non-fatal app-specific
|
||||
# refinements (rotate a key, patch a yaml after start, etc.).
|
||||
|
||||
_appCallHook()
|
||||
{
|
||||
local hook_name="$1"; shift
|
||||
if declare -F "$hook_name" >/dev/null 2>&1; then
|
||||
"$hook_name" "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# Standard "post-start integration" steps. Same for every app. Lives in a
|
||||
# helper so the generic install body stays readable; safe for apps that
|
||||
# don't tag for monitoring (the helpers no-op gracefully).
|
||||
_appPostStartIntegrations()
|
||||
{
|
||||
local app_name="$1"
|
||||
appUpdateSpecifics "$app_name"
|
||||
setupHeadscale "$app_name"
|
||||
databaseInstallApp "$app_name"
|
||||
webuiContainerSetup "$app_name" install
|
||||
|
||||
# Monitoring registration — 6 of the 31 apps used to call these inline.
|
||||
# Idempotent + no-op-safe for apps without monitoring tags, so we run
|
||||
# them unconditionally now and let each function handle its own gating.
|
||||
if declare -F monitoringToggleAppConfig >/dev/null 2>&1; then
|
||||
monitoringToggleAppConfig "$app_name" "docker-compose.yml" 2>/dev/null || true
|
||||
fi
|
||||
if declare -F monitoringRefreshAll >/dev/null 2>&1; then
|
||||
monitoringRefreshAll 2>/dev/null || true
|
||||
fi
|
||||
}
|
||||
|
||||
installApp()
|
||||
{
|
||||
local app_slug="$1"
|
||||
local config_variables="$2"
|
||||
|
||||
# APP_NAME comes from the app's CFG_<APP>_APP_NAME (the user's chosen
|
||||
# subdomain / install name). Fall back to the slug if unset.
|
||||
local app_name_var="CFG_${app_slug^^}_APP_NAME"
|
||||
local app_name="${!app_name_var:-$app_slug}"
|
||||
|
||||
# Dispatch flags live in the $<slug> global, e.g. linkding=i. Default to
|
||||
# install if nothing set — installApp called directly without flag = install.
|
||||
local actions="${!app_slug:-i}"
|
||||
|
||||
# Setup phase shared by every action (folder + variables).
|
||||
if [[ "$actions" == *[cCtTuUsSrRiI]* ]]; then
|
||||
dockerConfigSetupToContainer silent "$app_slug"
|
||||
initializeAppVariables "$app_name"
|
||||
fi
|
||||
|
||||
if [[ "$actions" == *[cCtT]* ]]; then
|
||||
editAppConfig "$app_name"
|
||||
fi
|
||||
|
||||
if [[ "$actions" == *[uU]* ]]; then
|
||||
_appCallHook "${app_slug}_uninstall_pre" "$app_name"
|
||||
dockerUninstallApp "$app_name"
|
||||
_appCallHook "${app_slug}_uninstall_post" "$app_name"
|
||||
fi
|
||||
|
||||
if [[ "$actions" == *[sS]* ]]; then
|
||||
dockerComposeDown "$app_name"
|
||||
_appCallHook "${app_slug}_stop_post" "$app_name"
|
||||
fi
|
||||
|
||||
if [[ "$actions" == *[rR]* ]]; then
|
||||
dockerComposeRestart "$app_name"
|
||||
_appCallHook "${app_slug}_restart_post" "$app_name"
|
||||
fi
|
||||
|
||||
if [[ "$actions" == *[iI]* ]]; then
|
||||
isHeader "Install $app_name"
|
||||
_appCallHook "${app_slug}_install_pre" "$app_name"
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
echo "---- $menu_number. Setting up install folder and config for $app_name."
|
||||
echo ""
|
||||
dockerConfigSetupToContainer "loud" "$app_name" "install" "$config_variables"
|
||||
isSuccessful "Install folders and Config files set up for $app_name."
|
||||
_appCallHook "${app_slug}_install_post_setup" "$app_name"
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
echo "---- $menu_number. Setting up the $app_name docker-compose.yml."
|
||||
echo ""
|
||||
dockerComposeSetupFile "$app_name"
|
||||
_appCallHook "${app_slug}_install_post_compose" "$app_name"
|
||||
|
||||
# Optional .env handling — apps that ship a .env in their template
|
||||
# dir get it copied + tag-substituted. No-op for apps without one.
|
||||
if [[ -f "${install_containers_dir}${app_slug}/.env" ]]; then
|
||||
local result
|
||||
result=$(copyResource "$app_name" ".env" "")
|
||||
checkSuccess "Copying .env for $app_name"
|
||||
configSetupFileWithData "$app_name" ".env"
|
||||
fi
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
echo "---- $menu_number. Updating file permissions before starting."
|
||||
echo ""
|
||||
fixPermissionsBeforeStart "$app_name"
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
echo "---- $menu_number. Running docker-compose to install + start $app_name."
|
||||
echo ""
|
||||
dockerComposeUpdateAndStartApp "$app_name" install
|
||||
_appCallHook "${app_slug}_install_post_start" "$app_name"
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
echo "---- $menu_number. Running post-install integrations."
|
||||
echo ""
|
||||
_appPostStartIntegrations "$app_name"
|
||||
|
||||
((menu_number++))
|
||||
echo ""
|
||||
echo "---- $menu_number. You can find $app_name files at $containers_dir$app_name"
|
||||
echo ""
|
||||
|
||||
# Final-message data — apps that want extra args (creds, URLs, etc.)
|
||||
# printed in the menu output echo them from their hook. Word-split is
|
||||
# intentional: each space-separated token becomes a positional arg.
|
||||
local msg_data=""
|
||||
if declare -F "${app_slug}_install_message_data" >/dev/null 2>&1; then
|
||||
msg_data=$("${app_slug}_install_message_data" "$app_name")
|
||||
fi
|
||||
# shellcheck disable=SC2086 # intentional split — hook returns "u p" etc.
|
||||
menuShowFinalMessages "$app_name" $msg_data
|
||||
|
||||
_appCallHook "${app_slug}_install_post" "$app_name"
|
||||
menu_number=0
|
||||
fi
|
||||
|
||||
# Reset the dispatch flag so a stale value doesn't trip a later call.
|
||||
eval "$app_slug=n"
|
||||
}
|
||||
@ -21,7 +21,17 @@ dockerInstallApp()
|
||||
fi
|
||||
|
||||
if ! declare -F "$installFuncName" >/dev/null 2>&1; then
|
||||
isError "No installer function found for app '${app_name}' (looked for ${installFuncName})."
|
||||
# No per-app install function (no containers/<app>/<app>.sh defining
|
||||
# one). Fall through to the generic installApp driver — it does the
|
||||
# standard 10-step sequence and picks up any <slug>_install_* hooks
|
||||
# the app declares in tools/<slug>_tools.sh. This is the path taken
|
||||
# by every app that doesn't need bespoke install code: their
|
||||
# <app>.sh has been deleted and the dispatcher routes them here.
|
||||
if declare -F installApp >/dev/null 2>&1; then
|
||||
installApp "$app_name" "$config_variables"
|
||||
return $?
|
||||
fi
|
||||
isError "No installer function found for app '${app_name}' (looked for ${installFuncName}; installApp fallback unavailable)."
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
@ -9,5 +9,6 @@ app_scripts=(
|
||||
"app/app_status.sh"
|
||||
"app/app_update_specifics.sh"
|
||||
"app/auth_adapter.sh"
|
||||
"app/install/app_install.sh"
|
||||
|
||||
)
|
||||
|
||||
@ -20,6 +20,7 @@ declare -gA LP_FN_MAP=(
|
||||
[appBookstackListUsers]="bookstack/tools/bookstack_list_users.sh"
|
||||
[appBookstackResetPassword]="bookstack/tools/bookstack_reset_password.sh"
|
||||
[appBookstackSetAdmin]="bookstack/tools/bookstack_set_admin.sh"
|
||||
[_appCallHook]="app/install/app_install.sh"
|
||||
[appCrowdSecAlertsList]="crowdsec/scripts/crowdsec_alerts_list.sh"
|
||||
[appCrowdSecConsoleDisable]="crowdsec/scripts/crowdsec_console_disable.sh"
|
||||
[appCrowdSecConsoleEnroll]="crowdsec/scripts/crowdsec_console_enroll.sh"
|
||||
@ -72,6 +73,7 @@ declare -gA LP_FN_MAP=(
|
||||
[appNextcloudToggleMaintenance]="nextcloud/tools/nextcloud_toggle_maintenance.sh"
|
||||
[appOwnCloudSetupConfig]="owncloud/scripts/owncloud_setup_config.sh"
|
||||
[appPiholeApplyDnsUpdater]="pihole/tools/pihole_apply_dns_updater.sh"
|
||||
[_appPostStartIntegrations]="app/install/app_install.sh"
|
||||
[_appReqHasDomain]="checks/requirements/check_app_install.sh"
|
||||
[_appReqServiceInstalled]="checks/requirements/check_app_install.sh"
|
||||
[_appReqServiceMsg]="checks/requirements/check_app_install.sh"
|
||||
@ -447,6 +449,7 @@ declare -gA LP_FN_MAP=(
|
||||
[hostSshUser]="ssh/host_access.sh"
|
||||
[initializeAppVariables]="network/variables/variables_init_app.sh"
|
||||
[installAdguard]="adguard/adguard.sh"
|
||||
[installApp]="app/install/app_install.sh"
|
||||
[installArch]="os/install/arch.sh"
|
||||
[installAuthelia]="authelia/authelia.sh"
|
||||
[installBookstack]="bookstack/bookstack.sh"
|
||||
@ -475,7 +478,6 @@ declare -gA LP_FN_MAP=(
|
||||
[installLibrePortalAppWebUI]="webui/webui_install_app.sh"
|
||||
[installLibrePortalImageWebUI]="webui/webui_install_image.sh"
|
||||
[installLibrePortalWebUITaskService]="webui/webui_install_systemd.sh"
|
||||
[installLinkding]="linkding/linkding.sh"
|
||||
[installMastodon]="mastodon/mastodon.sh"
|
||||
[installMoneyapp]="moneyapp/moneyapp.sh"
|
||||
[installNextcloud]="nextcloud/nextcloud.sh"
|
||||
@ -901,6 +903,7 @@ declare -gA LP_FN_ROOT=(
|
||||
[appBookstackListUsers]="containers"
|
||||
[appBookstackResetPassword]="containers"
|
||||
[appBookstackSetAdmin]="containers"
|
||||
[_appCallHook]="scripts"
|
||||
[appCrowdSecAlertsList]="containers"
|
||||
[appCrowdSecConsoleDisable]="containers"
|
||||
[appCrowdSecConsoleEnroll]="containers"
|
||||
@ -953,6 +956,7 @@ declare -gA LP_FN_ROOT=(
|
||||
[appNextcloudToggleMaintenance]="containers"
|
||||
[appOwnCloudSetupConfig]="containers"
|
||||
[appPiholeApplyDnsUpdater]="containers"
|
||||
[_appPostStartIntegrations]="scripts"
|
||||
[_appReqHasDomain]="scripts"
|
||||
[_appReqServiceInstalled]="scripts"
|
||||
[_appReqServiceMsg]="scripts"
|
||||
@ -1328,6 +1332,7 @@ declare -gA LP_FN_ROOT=(
|
||||
[hostSshUser]="scripts"
|
||||
[initializeAppVariables]="scripts"
|
||||
[installAdguard]="containers"
|
||||
[installApp]="scripts"
|
||||
[installArch]="scripts"
|
||||
[installAuthelia]="containers"
|
||||
[installBookstack]="containers"
|
||||
@ -1356,7 +1361,6 @@ declare -gA LP_FN_ROOT=(
|
||||
[installLibrePortalAppWebUI]="scripts"
|
||||
[installLibrePortalImageWebUI]="scripts"
|
||||
[installLibrePortalWebUITaskService]="scripts"
|
||||
[installLinkding]="containers"
|
||||
[installMastodon]="containers"
|
||||
[installMoneyapp]="containers"
|
||||
[installNextcloud]="containers"
|
||||
@ -1802,6 +1806,7 @@ appBookstackDeleteUser() { source "${install_containers_dir}bookstack/tools/book
|
||||
appBookstackListUsers() { source "${install_containers_dir}bookstack/tools/bookstack_list_users.sh"; appBookstackListUsers "$@"; }
|
||||
appBookstackResetPassword() { source "${install_containers_dir}bookstack/tools/bookstack_reset_password.sh"; appBookstackResetPassword "$@"; }
|
||||
appBookstackSetAdmin() { source "${install_containers_dir}bookstack/tools/bookstack_set_admin.sh"; appBookstackSetAdmin "$@"; }
|
||||
_appCallHook() { source "${install_scripts_dir}app/install/app_install.sh"; _appCallHook "$@"; }
|
||||
appCrowdSecAlertsList() { source "${install_containers_dir}crowdsec/scripts/crowdsec_alerts_list.sh"; appCrowdSecAlertsList "$@"; }
|
||||
appCrowdSecConsoleDisable() { source "${install_containers_dir}crowdsec/scripts/crowdsec_console_disable.sh"; appCrowdSecConsoleDisable "$@"; }
|
||||
appCrowdSecConsoleEnroll() { source "${install_containers_dir}crowdsec/scripts/crowdsec_console_enroll.sh"; appCrowdSecConsoleEnroll "$@"; }
|
||||
@ -1854,6 +1859,7 @@ appNextcloudTailLogs() { source "${install_containers_dir}nextcloud/tools/nextcl
|
||||
appNextcloudToggleMaintenance() { source "${install_containers_dir}nextcloud/tools/nextcloud_toggle_maintenance.sh"; appNextcloudToggleMaintenance "$@"; }
|
||||
appOwnCloudSetupConfig() { source "${install_containers_dir}owncloud/scripts/owncloud_setup_config.sh"; appOwnCloudSetupConfig "$@"; }
|
||||
appPiholeApplyDnsUpdater() { source "${install_containers_dir}pihole/tools/pihole_apply_dns_updater.sh"; appPiholeApplyDnsUpdater "$@"; }
|
||||
_appPostStartIntegrations() { source "${install_scripts_dir}app/install/app_install.sh"; _appPostStartIntegrations "$@"; }
|
||||
_appReqHasDomain() { source "${install_scripts_dir}checks/requirements/check_app_install.sh"; _appReqHasDomain "$@"; }
|
||||
_appReqServiceInstalled() { source "${install_scripts_dir}checks/requirements/check_app_install.sh"; _appReqServiceInstalled "$@"; }
|
||||
_appReqServiceMsg() { source "${install_scripts_dir}checks/requirements/check_app_install.sh"; _appReqServiceMsg "$@"; }
|
||||
@ -2229,6 +2235,7 @@ hostSshSetPasswordAuth() { source "${install_scripts_dir}ssh/host_access.sh"; ho
|
||||
hostSshUser() { source "${install_scripts_dir}ssh/host_access.sh"; hostSshUser "$@"; }
|
||||
initializeAppVariables() { source "${install_scripts_dir}network/variables/variables_init_app.sh"; initializeAppVariables "$@"; }
|
||||
installAdguard() { source "${install_containers_dir}adguard/adguard.sh"; installAdguard "$@"; }
|
||||
installApp() { source "${install_scripts_dir}app/install/app_install.sh"; installApp "$@"; }
|
||||
installArch() { source "${install_scripts_dir}os/install/arch.sh"; installArch "$@"; }
|
||||
installAuthelia() { source "${install_containers_dir}authelia/authelia.sh"; installAuthelia "$@"; }
|
||||
installBookstack() { source "${install_containers_dir}bookstack/bookstack.sh"; installBookstack "$@"; }
|
||||
@ -2257,7 +2264,6 @@ installLibrePortal() { source "${install_containers_dir}libreportal/libreportal.
|
||||
installLibrePortalAppWebUI() { source "${install_scripts_dir}webui/webui_install_app.sh"; installLibrePortalAppWebUI "$@"; }
|
||||
installLibrePortalImageWebUI() { source "${install_scripts_dir}webui/webui_install_image.sh"; installLibrePortalImageWebUI "$@"; }
|
||||
installLibrePortalWebUITaskService() { source "${install_scripts_dir}webui/webui_install_systemd.sh"; installLibrePortalWebUITaskService "$@"; }
|
||||
installLinkding() { source "${install_containers_dir}linkding/linkding.sh"; installLinkding "$@"; }
|
||||
installMastodon() { source "${install_containers_dir}mastodon/mastodon.sh"; installMastodon "$@"; }
|
||||
installMoneyapp() { source "${install_containers_dir}moneyapp/moneyapp.sh"; installMoneyapp "$@"; }
|
||||
installNextcloud() { source "${install_containers_dir}nextcloud/nextcloud.sh"; installNextcloud "$@"; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user