sane-vpn-{up,down}: consolidate
This commit is contained in:
parent
b69424983f
commit
3a30b891be
|
@ -44,8 +44,7 @@ in
|
||||||
"sane-scripts.ssl-dump"
|
"sane-scripts.ssl-dump"
|
||||||
"sane-scripts.sudo-redirect"
|
"sane-scripts.sudo-redirect"
|
||||||
"sane-scripts.sync-from-servo"
|
"sane-scripts.sync-from-servo"
|
||||||
"sane-scripts.vpn-down"
|
"sane-scripts.vpn"
|
||||||
"sane-scripts.vpn-up"
|
|
||||||
"sane-scripts.which"
|
"sane-scripts.which"
|
||||||
"sane-scripts.wipe-browser"
|
"sane-scripts.wipe-browser"
|
||||||
];
|
];
|
||||||
|
|
|
@ -197,13 +197,8 @@ let
|
||||||
pkgs = [ "ffmpeg" "sox" ];
|
pkgs = [ "ffmpeg" "sox" ];
|
||||||
pyPkgs = [ "unidecode" ];
|
pyPkgs = [ "unidecode" ];
|
||||||
};
|
};
|
||||||
vpn-down = static-nix-shell.mkBash {
|
vpn = static-nix-shell.mkBash {
|
||||||
pname = "sane-vpn-down";
|
pname = "sane-vpn";
|
||||||
src = ./src;
|
|
||||||
pkgs = [ "coreutils-full" "gnugrep" "gnused" "sane-scripts.ip-check" "systemd" ];
|
|
||||||
};
|
|
||||||
vpn-up = static-nix-shell.mkBash {
|
|
||||||
pname = "sane-vpn-up";
|
|
||||||
src = ./src;
|
src = ./src;
|
||||||
pkgs = [ "coreutils-full" "gnugrep" "gnused" "sane-scripts.ip-check" "systemd" ];
|
pkgs = [ "coreutils-full" "gnugrep" "gnused" "sane-scripts.ip-check" "systemd" ];
|
||||||
};
|
};
|
||||||
|
|
29
pkgs/additional/sane-scripts/src/sane-vpn
Executable file
29
pkgs/additional/sane-scripts/src/sane-vpn
Executable file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#!nix-shell -i bash -p coreutils-full -p gnugrep -p gnused -p sane-scripts.ip-check -p systemd
|
||||||
|
|
||||||
|
oper="$1"
|
||||||
|
region="$2"
|
||||||
|
# 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')
|
||||||
|
|
||||||
|
if ! [ $(echo "$vpns" | grep "^$region$") ]
|
||||||
|
then
|
||||||
|
echo "invalid vpn name '$region'"
|
||||||
|
echo "choices:"
|
||||||
|
echo "$vpns"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
iface=wg-quick-ovpnd-$region.service
|
||||||
|
|
||||||
|
echo before: $(sane-ip-check --no-upnp)
|
||||||
|
if [ "$oper" == up ]; then
|
||||||
|
sudo systemctl start $iface
|
||||||
|
elif [ "$oper" == down ]; then
|
||||||
|
sudo systemctl stop $iface
|
||||||
|
else
|
||||||
|
echo "invalid operation '$oper'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo after: $(sane-ip-check --no-upnp)
|
|
@ -1,20 +0,0 @@
|
||||||
#!/usr/bin/env nix-shell
|
|
||||||
#!nix-shell -i bash -p coreutils-full -p gnugrep -p gnused -p sane-scripts.ip-check -p systemd
|
|
||||||
|
|
||||||
# first arg should be the region, 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')
|
|
||||||
|
|
||||||
if ! [ $(echo "$vpns" | grep "^$1$") ]
|
|
||||||
then
|
|
||||||
echo "invalid vpn name '$1'"
|
|
||||||
echo "choices:"
|
|
||||||
echo "$vpns"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
iface=wg-quick-ovpnd-$1.service
|
|
||||||
|
|
||||||
echo vpn: $(sane-ip-check --no-upnp)
|
|
||||||
sudo systemctl stop $iface
|
|
||||||
echo plain: $(sane-ip-check --no-upnp)
|
|
|
@ -1,20 +0,0 @@
|
||||||
#!/usr/bin/env nix-shell
|
|
||||||
#!nix-shell -i bash -p coreutils-full -p gnugrep -p gnused -p sane-scripts.ip-check -p systemd
|
|
||||||
|
|
||||||
# first arg should be the region, 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')
|
|
||||||
|
|
||||||
if ! [ $(echo "$vpns" | grep "^$1$") ]
|
|
||||||
then
|
|
||||||
echo "invalid vpn name '$1'"
|
|
||||||
echo "choices:"
|
|
||||||
echo "$vpns"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
iface=wg-quick-ovpnd-$1.service
|
|
||||||
|
|
||||||
echo plain: $(sane-ip-check --no-upnp)
|
|
||||||
sudo systemctl start $iface
|
|
||||||
echo vpn: $(sane-ip-check --no-upnp)
|
|
Loading…
Reference in New Issue
Block a user