Update 2 files
- /home/.chezmoitemplates/secrets/tailscale-fallback - /home/.chezmoiscripts/universal/run_onchange_after_59-connect-tailscale.tmpl
This commit is contained in:
parent
2c1955333a
commit
c094214205
2 changed files with 27 additions and 23 deletions
|
@ -1,5 +1,28 @@
|
|||
{{- if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "tailscale")) -}}
|
||||
{{ includeTemplate "secrets/tailscale" | decrypt -}}
|
||||
{{ else if (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "tailscale-fallback")) -}}
|
||||
{{ includeTemplate "secrets/tailscale-fallback" }}
|
||||
{{- if and (ne .host.distro.family "windows") (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "tailscale")) -}}
|
||||
#!/usr/bin/env bash
|
||||
|
||||
### Install the Tailscale system daemon
|
||||
if [ -d /Applications ] && [ -d System ]; then
|
||||
# macOS
|
||||
if command -v tailscaled > /dev/null; then
|
||||
logg info 'Ensuring `tailscaled` system daemon is installed'
|
||||
sudo tailscaled install-system-daemon
|
||||
logg info '`tailscaled` system daemon is now installed and will load on boot'
|
||||
else
|
||||
logg info '`tailscaled` does not appear to be installed'
|
||||
fi
|
||||
fi
|
||||
|
||||
### Connect to Tailscale network
|
||||
TAILSCALE_AUTH_KEY="$(cat "{{ .chezmoi.sourceDir }}/.chezmoitemplates/secrets/key-netdata-token" | chezmoi decrypt)"
|
||||
if command -v tailscale > /dev/null && [ "$TAILSCALE_AUTH_KEY" != "" ]; then
|
||||
logg info 'Connecting to Tailscale with user-defined authentication key'
|
||||
timeout 14 tailscale up --authkey="$TAILSCALE_AUTH_KEY" --accept-routes || EXIT_CODE=$?
|
||||
if [ -n "$EXIT_CODE" ]; then
|
||||
logg warn '`tailscale up` timed out'
|
||||
else
|
||||
logg success 'Connected to Tailscale network'
|
||||
fi
|
||||
fi
|
||||
|
||||
{{- end -}}
|
|
@ -1,19 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
### Install the Tailscale system daemon
|
||||
if [ -d /Applications ] && [ -d System ]; then
|
||||
# macOS
|
||||
if command -v tailscaled > /dev/null; then
|
||||
logg info 'Ensuring `tailscaled` system daemon is installed'
|
||||
sudo tailscaled install-system-daemon
|
||||
logg info '`tailscaled` system daemon is now installed and will load on boot'
|
||||
else
|
||||
logg info '`tailscaled` does not appear to be installed'
|
||||
fi
|
||||
fi
|
||||
|
||||
### Connect to Tailscale network
|
||||
if command -v tailscale > /dev/null && [ "{{ env "TAILSCALE_AUTH_KEY" }}" != "" ]; then
|
||||
logg info 'Connecting to Tailscale with user-defined authentication key'
|
||||
tailscale up --authkey={{ env "TAILSCALE_AUTH_KEY" }} && logg success 'Connected to Tailscale network'
|
||||
fi
|
Loading…
Reference in a new issue