blob: f3dc0b118d4c1d0df7fa9277975cb3452f05ee32 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/bin/sh
if [ "$(id -u)" != "0" ]; then
echo "Must be run as root"
exit 1
fi
# This script assumes you have some $XDG_RUNTIME_DIR set up.
# The easiest way is systemd/elogind.
FNAME="/run/user/1000/vpn"
# Toggle vpn
if [ -e "$FNAME" ]; then
read -r IF < /run/user/1000/vpn
echo "Bringing $IF down..."
wg-quick down "$IF"
rm "$FNAME"
else
IF="$(find /etc/wireguard -type f -name "us-*" | shuf -n 1)"
echo "Bringing $IF up..."
wg-quick up "$IF"
echo "$IF" > $FNAME
fi
# Shorthand to [s]witch to a new server
if [ "$1" = "-s" ] ; then
vpn
else
true
fi
|