librelad 3e10dc99b4 refactor(headscale): flatten + move headscale into its app folder
Move the whole central scripts/headscale/ tree into containers/headscale/, the
last app-specific dir living centrally:

- 11 sourced function files (incl. the former local/ remote/ subdirs) flattened
  into containers/headscale/scripts/ — flat because the container scan is
  maxdepth 3, so one subfolder level is the limit; basenames already encode the
  local/remote distinction.
- tailscale.sh is a CONTAINER PAYLOAD (ends in a bare `install_tailscale` call,
  runs apt/curl) — it must never be sourced into the manager, so it goes to
  containers/headscale/resources/ (pruned by the scan), NOT scripts/. Verified
  install_tailscale does not leak into the runtime after sourcing.
- Fix tailscaleInstallToContainer to copy the payload from its new resources/
  path (it previously referenced ${install_scripts_dir}tailscale.sh, which never
  matched the file's actual location) and drop the dead commented docker-cp line.
- Remove the now-moot headscale special-case from generate_arrays.sh; regenerate
  (files_headscale.sh drops — headscale is fully container-scanned now).

All 11 functions source + define cleanly; callers resolve by name regardless of
location.

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

61 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
setupHeadscale()
{
local app_name="$1"
local local_type="$2"
if [ "$app_name" != "localhost" ]; then
setupHeadscaleVariables "$app_name"
fi
local CFG_INSTALL_NAME=$(echo "$CFG_INSTALL_NAME" | tr '[:upper:]' '[:lower:]')
local status=$(dockerCheckAppInstalled "headscale" "docker")
if [ "$status" == "installed" ]; then
# We don't set up headscale for headscale
if [[ "$app_name" == "headscale" ]]; then
dockerCommandRun "docker exec headscale headscale users create $CFG_INSTALL_NAME"
checkSuccess "Creating Headscale user $CFG_INSTALL_NAME"
while true; do
echo ""
isQuestion "Would you like to connect your localhost client to the Headscale server? (y/n) "
read -p "" local_headscale
if [[ -n "$local_headscale" ]]; then
break
fi
isNotice "Please provide a valid input."
done
if [[ "$local_headscale" == [yY] ]]; then
setupHeadscaleUser localhost local
fi
elif [[ "$app_name" == "localhost" ]]; then
while true; do
echo ""
isQuestion "Would you like to set up your localhost Headscale client to Localhost or Remote? (l/r) "
read -p "" localhost_type_headscale
if [[ -n "$localhost_type_headscale" ]]; then
break
fi
isNotice "Please provide a valid input."
done
if [[ "$localhost_type_headscale" == [lL] ]]; then
setupHeadscaleUser localhost local
elif [[ "$localhost_type_headscale" == [rR] ]]; then
setupHeadscaleUser localhost remote
fi
else
if [[ "$headscale_setup" != "disabled" ]]; then
setupHeadscaleUser "$app_name"
elif [[ "$headscale_setup" == "disabled" || "$headscale_setup" == "" ]]; then
isNotice "Headscale is not enabled for $app_name, unable to install."
fi
fi
else
isSuccessful "Headscale is not installed."
fi
}