#!/bin/bash

# Shared install-side bookkeeping for host-installed apps (CFG_<APP>_HOST_INSTALL=true).
#
# The apt/systemd install itself is app-specific and stays in the app's own
# script; this helper covers the LibrePortal-side registration every host app
# needs so each one doesn't re-discover the same gap.
#
# There is no hostAppUninstall counterpart on purpose: uninstalls route
# through dockerUninstallApp (CLI + menu both call it), which already does the
# generic teardown — compose down, data dir, DB rows, WebUI regen — and invokes
# the app's uninstall<App> hook for any host-specific steps.

# Call at the end of a host app's install, once its package + services are up.
#   - apps DB row (status=1): the WebUI services generator's Docker pass only
#     walks status=1 apps, so any host app that also ships a docker component
#     (e.g. crowdsec's dashboard) needs the row to surface in the Services tab.
#   - WebUI regen: marks the app installed + refreshes its services/config.
hostAppInstall()
{
    local app_name="$1"
    if [[ -z "$app_name" ]]; then
        isError "hostAppInstall: no app name provided."
        return 1
    fi

    databaseInstallApp "$app_name";
    webuiContainerSetup "$app_name" install;
}
