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>
144 lines
4.4 KiB
Bash
Executable File
144 lines
4.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
headscaleCommands()
|
|
{
|
|
# Setup Headscale for Localhost
|
|
if [[ "$headscaleclientlocal" == [yY] ]]; then
|
|
setupHeadscale localhost;
|
|
fi
|
|
|
|
# Setup Headscale for app
|
|
if [[ "$headscaleclientapp" == [yY] ]]; then
|
|
local app_names=()
|
|
local app_dir
|
|
|
|
isHeader "Install Headscale Apps List"
|
|
|
|
# Find all subdirectories under the directory where your apps are installed
|
|
for app_dir in "$containers_dir"/*/; do
|
|
if [[ -d "$app_dir" ]]; then
|
|
# Extract the app name (folder name)
|
|
local app_name=$(basename "$app_dir")
|
|
local app_names+=("$app_name")
|
|
fi
|
|
done
|
|
|
|
# Check if any apps were found
|
|
if [ ${#app_names[@]} -eq 0 ]; then
|
|
isNotice "No apps found in the installation directory."
|
|
fi
|
|
|
|
# List numbered options for app names
|
|
isNotice "Select an app to set up Headscale for:"
|
|
echo ""
|
|
for i in "${!app_names[@]}"; do
|
|
isOption "$((i + 1)). ${app_names[i]}"
|
|
done
|
|
|
|
# Read user input for app selection
|
|
echo ""
|
|
isQuestion "Enter the number of the app (or 'x' to exit): "
|
|
read -p "" selected_option
|
|
|
|
case "$selected_option" in
|
|
[1-9]*)
|
|
# Check if the selected option is a valid number
|
|
if ((selected_option >= 1 && selected_option <= ${#app_names[@]})); then
|
|
local selected_app="${app_names[selected_option - 1]}"
|
|
|
|
# Call the setupHeadscale function with the selected app name
|
|
setupHeadscale "$selected_app"
|
|
else
|
|
isNotice "Invalid app number. Please choose a valid option."
|
|
fi
|
|
;;
|
|
x)
|
|
isNotice "Exiting..."
|
|
;;
|
|
*)
|
|
isNotice "Invalid option. Please choose a valid option or 'x' to exit."
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
# Create a user
|
|
if [[ "$headscaleusercreate" == [yY] ]]; then
|
|
echo ""
|
|
echo "---- Creating user $CFG_INSTALL_NAME for Headscale :"
|
|
echo ""
|
|
local CFG_INSTALL_NAME=$(echo "$CFG_INSTALL_NAME" | tr '[:upper:]' '[:lower:]')
|
|
dockerCommandRun "docker exec headscale headscale users create $CFG_INSTALL_NAME"
|
|
echo ""
|
|
isNotice "Press Enter to continue..."
|
|
read
|
|
fi
|
|
|
|
# Create a user
|
|
if [[ "$headscaleusercreate" == [yY] ]]; then
|
|
echo ""
|
|
echo "---- Creating user $CFG_INSTALL_NAME for Headscale :"
|
|
echo ""
|
|
local CFG_INSTALL_NAME=$(echo "$CFG_INSTALL_NAME" | tr '[:upper:]' '[:lower:]')
|
|
dockerCommandRun "docker exec headscale headscale users create $CFG_INSTALL_NAME"
|
|
echo ""
|
|
isNotice "Press Enter to continue..."
|
|
read
|
|
fi
|
|
|
|
# Create a key
|
|
if [[ "$headscaleapikeyscreate" == [yY] ]]; then
|
|
echo ""
|
|
echo "---- Generating Auth Key in Headscale for user $CFG_INSTALL_NAME :"
|
|
echo ""
|
|
local CFG_INSTALL_NAME=$(echo "$CFG_INSTALL_NAME" | tr '[:upper:]' '[:lower:]')
|
|
dockerCommandRun "docker exec headscale headscale preauthkeys create -e 1h -u $CFG_INSTALL_NAME"
|
|
echo ""
|
|
isNotice "Press Enter to continue..."
|
|
read
|
|
fi
|
|
|
|
# Show list of keys
|
|
if [[ "$headscaleapikeyslist" == [yY] ]]; then
|
|
echo ""
|
|
echo "---- Showing all Headscale API Keys :"
|
|
echo ""
|
|
dockerCommandRun "docker exec headscale headscale apikeys list"
|
|
echo ""
|
|
isNotice "Press Enter to continue..."
|
|
read
|
|
fi
|
|
|
|
# Show list of nodes
|
|
if [[ "$headscalenodeslist" == [yY] ]]; then
|
|
echo ""
|
|
echo "---- Showing all Headscale Nodes :"
|
|
echo ""
|
|
dockerCommandRun "docker exec headscale headscale nodes list"
|
|
echo ""
|
|
isNotice "Press Enter to continue..."
|
|
read
|
|
fi
|
|
|
|
# Show list of users
|
|
if [[ "$headscaleuserlist" == [yY] ]]; then
|
|
echo ""
|
|
echo "---- Showing all Headscale Users :"
|
|
echo ""
|
|
dockerCommandRun "docker exec headscale headscale user list"
|
|
echo ""
|
|
isNotice "Press Enter to continue..."
|
|
read
|
|
fi
|
|
|
|
# Show version
|
|
if [[ "$headscaleversion" == [yY] ]]; then
|
|
echo ""
|
|
checkSuccess "Showing the Headscale Version :"
|
|
echo ""
|
|
dockerCommandRun "docker exec headscale headscale version"
|
|
echo ""
|
|
isNotice "Press Enter to continue..."
|
|
read
|
|
fi
|
|
}
|