#!/bin/bash

tailscaleInstallToContainer()
{
    local app_name="$1"
    local type="$2"

    local result=$(createFolders "loud" $docker_install_user $containers_dir$app_name/tailscale)
    checkSuccess "Creating Tailscale folder"

    copyFile "loud" "${install_containers_dir}headscale/resources/tailscale.sh" "$containers_dir$app_name/tailscale/tailscale.sh" $docker_install_user | runInstallWrite -a "$logs_dir/$docker_log_file" 2>&1

    if [[ "$type" != "install" ]]; then
        dockerComposeRestart $app_name;
    fi

    dockerCommandRun "docker exec -it $app_name /usr/local/bin/tailscale.sh"
    checkSuccess "Executing Tailscale installer script in the $app_name container"
}