diff options
author | Xiao Pan <xyz@flylightning.xyz> | 2025-01-11 21:03:52 -0800 |
---|---|---|
committer | Xiao Pan <xyz@flylightning.xyz> | 2025-01-11 21:03:52 -0800 |
commit | c1b7b022611bca8c470c2ebc3678675a436390f3 (patch) | |
tree | fcf48432ae3ef4dce87a8a0bcc9b2ba197105fc2 /sh/vip | |
parent | 80d5c54225e115ec0f260c253f14db25fbc7d117 (diff) |
wireguard switch to use cfg repo branches as names
Diffstat (limited to 'sh/vip')
-rwxr-xr-x | sh/vip | 25 |
1 files changed, 6 insertions, 19 deletions
@@ -1,25 +1,12 @@ #!/bin/sh # Vpn IP -case "$(nmcli -t --fields device,state device)" in - *wg_aa:connected*) echo aa;; - *wg_ca:connected*) echo ca;; - *wg_ia:connected*) echo ia;; - *wg_ib:connected*) echo ib;; - *wg_mydefault:connected*) echo mydefault;; - *wg_studio:connected*) echo studio;; - *) echo none;; -esac +# seperate with _ and : , see `man awk.1p` "Otherwise, the string value of FS +# shall be considered to be an extended regular expression. ...", so -F if +# multiple chars means it is regex? so [_:] inside [] there's _ and : char +# which in regex means _ and : char? More maybe see: +# https://www.gnu.org/software/gawk/manual/html_node/Regexp-Field-Splitting.html +nmcli -t --fields device,state device | awk -F'[_:]' '/wg_.*:connected/{print $2}' printf 'default: '; curl -m1 ifconfig.co printf '4: '; curl -4m1 ifconfig.co printf '6: '; curl -6m1 ifconfig.co - -# the old way, slower and more code -#nm_device_state="$(nmcli -t --fields device,state device)" -#if echo "$nm_device_state" | grep -q '^wg_ia:connected$'; then -# echo ia -#elif echo "$nm_device_state" | grep -q '^wg_studio:connected$'; then -# echo studio -#else -# echo insp -#fi |