sane-vpn: support "vpn-servo"
This commit is contained in:
@@ -34,7 +34,6 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
# TODO: this should live in the same file as hosts/modules/wg-home.nix...
|
# TODO: this should live in the same file as hosts/modules/wg-home.nix...
|
||||||
# TODO: update sane-vpn script to also allow activating/deactiving this interface
|
|
||||||
def-servo = def-wg-vpn "vpn-servo" {
|
def-servo = def-wg-vpn "vpn-servo" {
|
||||||
endpoint = config.sane.hosts.by-name."servo".wg-home.endpoint;
|
endpoint = config.sane.hosts.by-name."servo".wg-home.endpoint;
|
||||||
publicKey = config.sane.hosts.by-name."servo".wg-home.pubkey;
|
publicKey = config.sane.hosts.by-name."servo".wg-home.pubkey;
|
||||||
|
@@ -5,23 +5,28 @@ oper="$1"
|
|||||||
region="$2"
|
region="$2"
|
||||||
# region should be e.g. `us` or `ukr`
|
# region should be e.g. `us` or `ukr`
|
||||||
|
|
||||||
vpns=$(systemctl list-unit-files | grep wg-quick-ovpnd- | cut -f 1 -d ' ' | sed s'/^wg-quick-ovpnd-\([a-zA-Z-]*\)\.service$/\1/g')
|
vpns=$(systemctl list-unit-files | grep wg-quick- | cut -f 1 -d ' ' | sed s'/^wg-quick-\([a-zA-Z-]*\)\.service$/\1/g')
|
||||||
|
|
||||||
if ! [ $(echo "$vpns" | grep "^$region$") ]
|
if [ $(echo "$vpns" | grep "^$region$") ]; then
|
||||||
then
|
iface="$region"
|
||||||
|
elif [ $(echo "$vpns" | grep "^vpn-$region$") ]; then
|
||||||
|
iface="vpn-$region"
|
||||||
|
elif [ $(echo "$vpns" | grep "^ovpnd-$region$") ]; then
|
||||||
|
iface="ovpnd-$region"
|
||||||
|
else
|
||||||
echo "invalid vpn name '$region'"
|
echo "invalid vpn name '$region'"
|
||||||
echo "choices:"
|
echo "choices:"
|
||||||
echo "$vpns"
|
echo "$vpns"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
iface=wg-quick-ovpnd-$region.service
|
service="wg-quick-$iface.service"
|
||||||
|
|
||||||
echo before: $(sane-ip-check --no-upnp)
|
echo before: $(sane-ip-check --no-upnp)
|
||||||
if [ "$oper" == up ]; then
|
if [ "$oper" == up ]; then
|
||||||
sudo systemctl start $iface
|
sudo systemctl start "$service"
|
||||||
elif [ "$oper" == down ]; then
|
elif [ "$oper" == down ]; then
|
||||||
sudo systemctl stop $iface
|
sudo systemctl stop "$service"
|
||||||
else
|
else
|
||||||
echo "invalid operation '$oper'"
|
echo "invalid operation '$oper'"
|
||||||
exit 1
|
exit 1
|
||||||
|
Reference in New Issue
Block a user