cleanup
This commit is contained in:
parent
ddbc24a33f
commit
ddd00d7844
16 changed files with 121 additions and 91 deletions
|
@ -1,24 +1,26 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
function off() {
|
||||
local ifs
|
||||
|
||||
read -ra ifs < <(wg show interfaces) || true
|
||||
for i in "${ifs[@]}"; do
|
||||
wg-quick down "$i"
|
||||
done
|
||||
}
|
||||
|
||||
[ "$EUID" != 0 ] && { pkexec bash -c "DISPLAY='$DISPLAY' XAUTHORITY='$XAUTHORITY' $0 $*"; exit; }
|
||||
|
||||
[ "$1" == off ] && { off; exit; }
|
||||
|
||||
if [ -n "$DISPLAY" ]; then
|
||||
if="$(basename -s.conf /etc/wireguard/*.conf | /usr/local/bin/dmenu)"
|
||||
if tty -s; then
|
||||
DMENU=fzf
|
||||
SUDO=sudo
|
||||
else
|
||||
select if in $(basename -s.conf /etc/wireguard/*.conf); do
|
||||
break
|
||||
done
|
||||
DMENU=/usr/local/bin/dmenu
|
||||
SUDO=pkexec
|
||||
fi
|
||||
|
||||
if [ "$EUID" != 0 ]; then
|
||||
exec "$SUDO" env DISPLAY="$DISPLAY" XAUTHORITY="$XAUTHORITY" \
|
||||
"$BASH" -- "${BASH_SOURCE[0]}" "$@"
|
||||
fi
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
set -- "$(basename -s.conf /etc/wireguard/*.conf | "$DMENU")"
|
||||
fi
|
||||
|
||||
while read -r i; do
|
||||
wg-quick down "$i"
|
||||
done < <(wg show interfaces)
|
||||
|
||||
if [ "$1" != off ]; then
|
||||
wg-quick up "$1"
|
||||
fi
|
||||
off
|
||||
wg-quick up "$if"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue