Created
December 28, 2021 02:04
-
-
Save ochafik/bcea0bdd3c0ea44e638409694543ba9e to your computer and use it in GitHub Desktop.
Wrapper around `wg show` that uses pivpn configuration names instead of peer ids
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Beautifies output of `wg show` using config names from pivpn | |
# | |
wg show | awk "BEGIN { $( | |
# Map peer to preshared key | |
wg show all preshared-keys | awk '{ print "key[\"" $2 "\"] = \"" $3 "\";" }' | |
for f in $( ( . /etc/pivpn/wireguard/setupVars.conf ; echo $install_home ) )/configs/* ; do | |
# Map preshared key to config name | |
printf 'name["%s"] = "%s";\n' \ | |
"$( cat $f | grep PresharedKey | sed 's/.*= //' )" \ | |
"$( basename $f | sed 's/.conf$//' )" | |
done | |
) } /peer/ { print name[key[\$2]] ; next } { print \$0 }" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment