2023-02-05 00:09:07 -08:00
|
|
|
{{- if (ne .host.distro.family "windows") }}
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
### Configure CloudFlare WARP (if not WSL and warp-cli is installed)
|
2023-02-15 19:14:33 -08:00
|
|
|
if [[ ! "$(test -d /proc && grep Microsoft /proc/version > /dev/null)" ]] && command -v warp-cli > /dev/null; then
|
2023-02-05 00:09:07 -08:00
|
|
|
### Register CloudFlare WARP
|
|
|
|
if warp-cli --accept-tos status | grep 'Registration missing' > /dev/null; then
|
|
|
|
logg info 'Registering CloudFlare WARP'
|
|
|
|
warp-cli --accept-tos register
|
|
|
|
else
|
|
|
|
logg info 'Already registered with CloudFlare WARP'
|
|
|
|
fi
|
|
|
|
|
|
|
|
### Connect CloudFlare WARP
|
|
|
|
if warp-cli --accept-tos status | grep 'Disconnected' > /dev/null; then
|
|
|
|
logg info 'Connecting to CloudFlare WARP'
|
|
|
|
warp-cli --accept-tos connect
|
|
|
|
else
|
|
|
|
logg info 'Already connected to CloudFlare WARP'
|
|
|
|
fi
|
|
|
|
|
|
|
|
### Enable Always-On mode
|
|
|
|
logg info 'Enabling always-on mode'
|
|
|
|
warp-cli --accept-tos enable-always-on
|
|
|
|
|
|
|
|
### Enable Family Mode
|
|
|
|
# logg info 'Enabling family-mode'
|
|
|
|
# warp-cli --accept-tos set-families-mode full
|
|
|
|
|
|
|
|
### Enable WARP+DNS mode
|
|
|
|
# logg info 'Enabling WARP+DNS mode'
|
|
|
|
# warp-cli set-mode warp+doh
|
|
|
|
|
|
|
|
# TODO
|
2023-02-15 19:56:44 -08:00
|
|
|
{{ if and (stat (joinPath .host.home ".config" "age" "chezmoi.txt")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "key-cloudflare-teams-client-id")) (stat (joinPath .chezmoi.sourceDir ".chezmoitemplates" "secrets" "key-cloudflare-teams-client-secret")) -}}
|
2023-02-05 00:09:07 -08:00
|
|
|
### Enroll with CloudFlare Teams
|
|
|
|
logg info 'Enrolling with CloudFlare Teams'
|
|
|
|
warp-cli teams-enroll '{{- includeTemplate "secrets/key-cloudflare-teams-client-id" | decrypt -}}' '{{- includeTemplate "secrets/key-cloudflare-teams-client-secret" | decrypt -}}'
|
|
|
|
{{- end }}
|
|
|
|
fi
|
|
|
|
|
|
|
|
{{ end -}}
|