2023-01-26 23:13:53 -08:00
|
|
|
{{- if eq .host.distro.family "darwin" -}}
|
2023-01-26 00:50:54 -08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
{{ includeTemplate "universal/profile" }}
|
|
|
|
{{ includeTemplate "universal/logg" }}
|
|
|
|
|
2023-02-01 13:52:59 -08:00
|
|
|
# TODO - Populate Tunnelblick on macOS using the .ovpn profiles located in $HOME/.config/vpn
|
|
|
|
# along with the secrets for the protonVPN OpenVPN (check vpn-linux.tmpl)
|
2023-01-26 23:13:53 -08:00
|
|
|
|
|
|
|
### Backup previous network settings
|
|
|
|
if [ -f /Library/Preferences/com.apple.networkextension.plist ]; then
|
2023-02-01 12:22:57 -08:00
|
|
|
logg info 'Backing up /Library/Preferences/com.apple.networkextension.plist to /Library/Preferences/com.apple.networkextension.plist.old'
|
2023-01-26 23:13:53 -08:00
|
|
|
sudo cp -f /Library/Preferences/com.apple.networkextension.plist /Library/Preferences/com.apple.networkextension.plist.old
|
|
|
|
else
|
|
|
|
logg info 'The /Library/Preferences/com.apple.networkextension.plist file does not exist yet'
|
|
|
|
fi
|
|
|
|
|
|
|
|
### Ensure /etc/wireguard exists
|
|
|
|
if [ ! -d /etc/wireguard ]; then
|
|
|
|
logg info 'Creating `/etc/wireguard` since it does not exist yet'
|
|
|
|
sudo mkdir -p /etc/wireguard
|
|
|
|
sudo chmod 600 /etc/wireguard
|
|
|
|
fi
|
|
|
|
|
|
|
|
### Add the WireGuard configurations
|
2023-02-01 12:26:54 -08:00
|
|
|
find "${XDG_CONFIG_HOME:-$HOME/.config}/vpn" -mindepth 1 -maxdepth 1 -type f -name "*.conf" | while read WG_CONF; do
|
2023-01-26 23:13:53 -08:00
|
|
|
WG_FILE="$(basename "$WG_CONF")"
|
|
|
|
logg info 'Adding `'"$WG_FILE"'` to /etc/wireguard'
|
|
|
|
sudo cp -f "$WG_CONF" "/etc/wireguard/$WG_FILE"
|
|
|
|
done
|
2023-01-26 14:56:49 -08:00
|
|
|
|
2023-01-26 00:50:54 -08:00
|
|
|
{{ end -}}
|