setup for vpns
This commit is contained in:
parent
927ad87cf9
commit
002ff2ea0c
2 changed files with 37 additions and 0 deletions
|
@ -7,3 +7,5 @@ exec-once = $hypr/scripts/init
|
|||
exec-once = hypridle
|
||||
exec-once = dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP
|
||||
exec-once = copyq --start-server
|
||||
# exec-once = foot "sudo bash $HOME/.config/hypr/scripts/wireguard-setup"
|
||||
exec-once = kitty bash -c "echo 'VPN-Setup:' && sudo $HOME/.config/hypr/scripts/wireguard-setup"
|
||||
|
|
35
scripts/wireguard-setup
Executable file
35
scripts/wireguard-setup
Executable file
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# ─< Check if the given command exists silently >─────────────────────────────────────────
|
||||
command_exists() {
|
||||
command -v "$@" >/dev/null 2>&1
|
||||
}
|
||||
|
||||
wg-setup() {
|
||||
shopt -s nullglob
|
||||
local peers=()
|
||||
local ip
|
||||
ip="$(ip ad)"
|
||||
|
||||
for p in /etc/wireguard/*; do
|
||||
# NOTE:
|
||||
# get names without .conf
|
||||
# /etc/wireguard/wg0.conf would convert to `wg0` only
|
||||
peers+=("$(basename ${p%.conf})")
|
||||
done
|
||||
|
||||
case "${1:-up}" in
|
||||
up)
|
||||
cmd="wg-quick up"
|
||||
;;
|
||||
down)
|
||||
cmd="wg-quick down"
|
||||
;;
|
||||
esac
|
||||
|
||||
for peer in "${peers[@]}"; do
|
||||
$cmd $peer
|
||||
done
|
||||
}
|
||||
|
||||
wg-setup "$@"
|
Loading…
Add table
Add a link
Reference in a new issue