What's new

Wireguard Session Manager - Discussion (2nd) thread

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Not sure if that’s what you meant. But see attached.
I run two commands.
You need to run the command in one go:
Code:
echo -e "menu hide\nlivin wg11 192.168.1.94\ne" | wg_manager

But you might still get the initial menu which clutter things up abit... you could follow @chongnt suggestion to turn it off, but you might not get any feedback at all...

Perhaps wgm could be started in silent mode from shell @Martineau like
Code:
wg_manager silent
Where menu hide when starting?

Not sure how the echo command will work with this though.
 
Last edited:
You need to run the command in one go:
Code:
echo -e "menu hide\nlivin wg11 192.168.1.94\ne" | wg_manager

But you might still get the initial menu which clutter things up abit... you could follow @chongnt suggestion to turn it off, but you might not get any feedback at all...
FYI, the new menu command is per session, so will indeed show the first/reduced banner, but the menu should be hidden until you restart wireguard_manager

If displaying the menu is to be disabled permanently then you need to use vx to uncomment the NOMENU directive.

If the NOMENU directive isn't shown, then issue
Code:
e  = Exit Script [?]

E:Option ==> createconfig
then retry the vx command
 
You need to run the command in one go:
Code:
echo -e "menu hide\nlivin wg11 192.168.1.94\ne" | wg_manager

But you might still get the initial menu which clutter things up abit... you could follow @chongnt suggestion to turn it off, but you might not get any feedback at all...

Perhaps wgm could be started in silent mode from shell @Martineau like
Code:
wg_manager silent
Where menu hide when starting?

Not sure how the echo command will work with this though.
I did run it in one go. Still getting the menu
 

Attachments

  • BA837DEE-76A5-417F-BA95-785AFF83D2CB.jpeg
    BA837DEE-76A5-417F-BA95-785AFF83D2CB.jpeg
    30.3 KB · Views: 70
  • E3C1B3FE-1A03-418F-BC08-D97A17D7A0BA.jpeg
    E3C1B3FE-1A03-418F-BC08-D97A17D7A0BA.jpeg
    83.1 KB · Views: 78
I did run it in one go. Still getting the menu
Yep, the initial menu still shows (but not a second time?)... as I see it you have two options in the posts above (for the time being)

1. Turn off Shortcuts ssh output according to @chongnt
2. Turn off menu compleatally in wgm config according to @Martineau

I will see if I can find anything in the shortcuts app that would allow for Selective outputs...
 
I did run it in one go. Still getting the menu
Found a simpler way, use the good old grep to identify a unique text in the line you want to output.

Example:
Code:
admin@RT-AC86U-D7D8:/tmp/home/root# echo -e "peer help\ne" | wg_manager | grep 9.9.9.9

   peer wg13 rule add wan 172.16.1.100 9.9.9.9 comment Quad9 DNS

So identify some unique Word in the line you want as you response ("Expat" maybee).

How about something like this:
Code:
echo -e "livin wg11 192.168.1.94\ne" | wg_manager | grep -A 1 "Option ==>"

Should be fairly general, it would only display the E:Option ==> line and 1 more line. Change -A 1 to -A 2 if more lines are needed... this would atleast give you a more relevant output. It will also give you if there is any error, well, not any error but only if wgm reports it as a "normal" error.

There are probably niftier ways but my scripting skills are limited.

Please report back what works for you!
 
Last edited:
Found a simpler way, use the good old grep to identify a unique text in the line you want to output.

Example:
Code:
admin@RT-AC86U-D7D8:/tmp/home/root# echo -e "peer help\ne" | wg_manager | grep 9.9.9.9

   peer wg13 rule add wan 172.16.1.100 9.9.9.9 comment Quad9 DNS

So identify some unique Word in the line you want as you response ("Expat" maybee).

How about something like this:
Code:
echo -e "livin wg11 192.168.1.94\ne" | wg_manager | grep -A 1 "Option ==>"

Should be fairly general, it would only display the E:Option ==> line and 1 more line. Change -A 1 to -A 2 if more lines are needed... this would atleast give you a more relevant output. It will also give you if there is any error, well, not any error but only if wgm reports it as a "normal" error.

There are probably niftier ways but my scripting skills are limited.

Please report back what works for you!
That works! thank you
 

Attachments

  • 06E2FE3C-A944-46B3-8136-02DB5215029B.jpeg
    06E2FE3C-A944-46B3-8136-02DB5215029B.jpeg
    31.5 KB · Views: 71
That works! thank you
@abir1909 / @ZebMcKayhan

I've pushed another wireguard_manager HOTFIX v4.15b6

To tidy up the Siri output, you can now permanently disable ALL ANSI/ASCII colour/attribute control sequences

Code:
e  = Exit Script [?]

E:Option ==> colour off
or even
Code:
e  = Exit Script [?]

E:Option ==> color off

and the SSH Button results should now appear a lot more readable on Siri

e.g. Before
Code:
[96mE:9mOption ==>[0m [s92m]

Welcome Expat to 'Paris'

[96mE:[93mOption --->[0m [s[0m
After
Code:
Option ==>

Welcome Expat to 'Paris'

Option ===>
 
Made another attemp. Figuring that the most important feedback may be unexpected and then maybee a single line wont due. So trying to capture data between the E:Option ==> and Wireguard ACTIVE peers status. So we get even unexpected outputs:

With the Wireguard ACTIVE peers status line showing:
Code:
admin@RT-AC86U-D7D8:/tmp/home/root# echo -e "stop wg12\ne" | wg_manager | awk 'flag; /Option ==>/{flag=1} /WireGuard ACTIVE/{flag=0}'
        Requesting WireGuard VPN Peer stop (wg12)


        wg12: transfer: 64.15 KiB received, 237.04 KiB sent             1 days 00:51:36 from 2022-02-07 18:13:52 >>>>>>
        wg12: period : 277 Bytes received, 1.03 KiB sent (Rx=277;Tx=1055)
        wireguard-clientwg12: Wireguard VPN 'client' Peer (wg12) to us.wireguard.net:42911 (# Integrity USA) Terminated


        WireGuard ACTIVE Peer Status: Clients 1, Servers 0
admin@RT-AC86U-D7D8:/tmp/home/root#

Or without it:
Code:
admin@RT-AC86U-D7D8:/tmp/home/root# echo -e "start wg12\ne" | wg_manager | awk '/Option ==>/{flag=1; next} /WireGuard ACTIVE/{flag=0} flag'
        Requesting WireGuard VPN Peer start (wg12)

        wireguard-clientwg12: Initialising Wireguard VPN 'client' Peer (wg12) in Policy Mode to us.wireguard.net:42911 (# Integrity USA) DNS=9.9.9.9,2620:fe::fe

wireguard-clientwg12: Initialisation complete.


admin@RT-AC86U-D7D8:/tmp/home/root#

Also works for multiple commands:
Code:
admin@RT-AC86U-D7D8:/tmp/home/root# echo -e "colour off\nstop wg12\nstart wg12\ne" | wg_manager | awk '/Option ==>/{flag=1; next} /WireGuard ACTIVE/{flag=0} flag'
        Requesting WireGuard VPN Peer stop (wg12)


        wg12: transfer: 184 B received, 584 B sent                      0 Days, 00:03:01 from 2022-02-08 19:12:40 >>>>>>
        wg12: period : 184 Bytes received, 584 Bytes sent (Rx=184;Tx=584)
        wireguard-clientwg12: Wireguard VPN 'client' Peer (wg12) to us.wireguard.net:42911 (# Integrity USA) Terminated


        Requesting WireGuard VPN Peer start (wg12)

        wireguard-clientwg12: Initialising Wireguard VPN 'client' Peer (wg12) in Policy Mode to us.wireguard.net:42911 (# Integrity USA) DNS=9.9.9.9,2620:fe::fe

wireguard-clientwg12: Initialisation complete.


admin@RT-AC86U-D7D8:/tmp/home/root#

So the command might look messy but should be generic enough so you dont have to mess with them except for changing your command you want to execute.

So, with status line:
Code:
echo -e "livin wg11 192.168.1.94\ne" | wg_manager | awk 'flag; /Option ==>/{flag=1} /WireGuard ACTIVE/{flag=0}'

Or without it:
Code:
echo -e "livin wg11 192.168.1.94\ne" | wg_manager | awk '/Option ==>/{flag=1; next} /WireGuard ACTIVE/{flag=0} flag'

Or to completally supress the output:
Code:
echo -e "livin wg11 192.168.1.94\ne" | wg_manager 1>/dev/null

all in all this allows for further automation by accessing any wgm internal commands from your own scripts with selective outputs. You could put your favourite commands in scripts and/or execute what you wish in a cron job or whatever. Sky is the limit!

I.e change wg11 dns:
Code:
echo -e "stop wg11\npeer wg11 dns=9.9.9.9\nstart wg11\ne" | wg_manager | awk '/Option ==>/{flag=1; next} /WireGuard ACTIVE/{flag=0} flag'

//Zeb
 
Last edited:
@abir1909 / @ZebMcKayhan

I've pushed another wireguard_manager HOTFIX v4.15b6

To tidy up the Siri output, you can now permanently disable ALL ANSI/ASCII colour/attribute control sequences

Code:
e  = Exit Script [?]

E:Option ==> colour off
or even
Code:
e  = Exit Script [?]

E:Option ==> color off
Thanks, you have done us all a great favor/favour ;-)
 
@abir1909 / @ZebMcKayhan

I've pushed another wireguard_manager HOTFIX v4.15b6

To tidy up the Siri output, you can now permanently disable ALL ANSI/ASCII colour/attribute control sequences

Code:
e  = Exit Script [?]

E:Option ==> colour off
or even
Code:
e  = Exit Script [?]

E:Option ==> color off

and the SSH Button results should now appear a lot more readable on Siri

e.g. Before
Code:
[96mE:9mOption ==>[0m [s92m]

Welcome Expat to 'Paris'

[96mE:[93mOption --->[0m [s[0m
After
Code:
Option ==>

Welcome Expat to 'Paris'

Option ===>
I tested it. Not sure what I am doing wrong.
I updated wgm. I ran color off. And still getting the long output.
 

Attachments

  • 499F2EBF-FC9E-4357-A695-3D3A8EFF21AC.png
    499F2EBF-FC9E-4357-A695-3D3A8EFF21AC.png
    56.9 KB · Views: 57
  • 5E994D37-0514-49DD-AF41-33059DA76298.png
    5E994D37-0514-49DD-AF41-33059DA76298.png
    162.7 KB · Views: 59
I tested it. Not sure what I am doing wrong.
I updated wgm. I ran color off. And still getting the long output.
The menu hide still gives you the initial menu and colour off only removes the escape characters Instead, try:
Code:
echo -e "colour off\nlivin wg12 192.168.1.94\ne" | wg_manager | awk '/Option ==>/{flag=1; next} /WireGuard ACTIVE/{flag=0} flag'
And:
Code:
echo -e "colour off\nlivin @home 192.168.1.94\ne" | wg_manager | awk '/Option ==>/{flag=1; next} /WireGuard ACTIVE/{flag=0} flag'

It should give a neat output.
 
Last edited:
The menu hide still gives you the initial menu and colour off only removes the escape characters Instead, try:
Code:
echo -e "colour off\nlivin wg12 192.168.1.94\ne" | wg_manager | awk '/Option ==>/{flag=1; next} /WireGuard ACTIVE/{flag=0} flag'
And:
Code:
echo -e "colour off\nlivin @home 192.168.1.94\ne" | wg_manager | awk '/Option ==>/{flag=1; next} /WireGuard ACTIVE/{flag=0} flag'

It should give a neat output.
It did Thx
 
Updated section about Terminal Options (including menu hide and colour off):
https://github.com/ZebMcKayhan/WireguardManager/blob/main/README.md#terminal-options

and new section "Execute menu commands externally":
https://github.com/ZebMcKayhan/WireguardManager/blob/main/README.md#execute-menu-commands-externally

//Zeb
Excellent!

However, I have now exposed the colo[u]r off and menu hide commands so you can ensure you never get the FULL initial menu when using Siri etc.

e.g.

1644398243854.png


So this may simplify the readability of the shortcuts? as these only need to be issued once as they will both be permanent if issued as shown.

NOTE: Clearly order matters ;)
(If you didn't turn off the colour attributes first, the 'Menu display is DISABLED' message would contain the ANSI/ASCII control sequences).


Also, one minor comment regarding the numerous livin examples...

I think it should be noted that if you have assigned annotation tags to your 'client' Peers, then cosmetically
Code:
livin wg13 xxx.xxx.xxx.xxx
is a bit clunky as I meant the syntax to be more human friendly if you can't actually remember which WireGuard interface is connected to which location (far fetched I know; especially if you only have one 'client' Peer interface :rolleyes: )
e.g.
Code:
livin Dallas HP-Envy13
makes more sense?
However the location string is a single word so
Code:
livin Los Angeles HP-Envy13
won't work :rolleyes:
 
However, I have now exposed the colo[u]r off and menu hide commands so you can ensure you never get the FULL initial menu when using Siri etc.

So this may simplify the readability of the shortcuts? as these only need to be issued once as they will both be permanent if issued as shown.
ok, great!

I will sink my teeth in it when I get home.

how permanent is this after you execute the command? is it permanent in this session? or across sessions? across reboots?

I was considering making a shell script, like:
<wgmExpo>
Code:
#!/bin/sh
echo -e "$1\ne" | wg_manager | awk '/Option ==>/{flag=1; next} /WireGuard ACTIVE/{flag=0} flag'

so it could be called by simply:
Code:
wgmExpo "colour off\nlivin wg12 192.168.1.94"

but not sure if it's worth the effort since this is usually set-and-forget commands.
 
how permanent is this after you execute the command? is it permanent in this session? or across sessions? across reboots?
They are permanent
I was considering making a shell script, like:
<wgmExpo>
Code:
#!/bin/sh
echo -e "$1\ne" | wg_manager | awk '/Option ==>/{flag=1; next} /WireGuard ACTIVE/{flag=0} flag'

so it could be called by simply:
Code:
wgmExpo "colour off\nlivin wg12 192.168.1.94"

but not sure if it's worth the effort since this is usually set-and-forget commands.

Piping commands into wgm_manager is efficient, but hard to read, so the wrapper script may be useful.

i.e. So assuming the following has already been executed in the SSH session
Code:
wg_manager colour off; wgm_manager menu off;
passing the request string to SSH Button/Siri is slightly slower, longer to type but more reliable?
Code:
wg_manager stop wg11; wg_manager start wg13; wgm_manager show; wgmExpo "livin wg12 192.168.1.94"
But as you say the technique works, and setting the desired command is more than likely a one-off.
 
passing the request string to SSH Button/Siri is slightly slower, longer to type but more reliable?
Thinking that if you are going to use wgmExpo you might aswell use it for all you want to do for easier command, instead of:
Code:
wg_manager colour off; wgm_manager menu off;
wg_manager stop wg11; wg_manager start wg13; wgm_manager show; wgmExpo "livin wg12 192.168.1.94"

Then:
Code:
wgmExpo "colour off\nstop wg11\nstart wg13\nshow\nlivin wg12 192.168.1.94"

Can't comment on efficiency or reliability though.

I'm not sure I would like to permanently turn off either menu or colors since I would probably be confused the next time I want to use it in ssh and have to look up the commands to enable it again.

By the way, what is the command to turn the menu back on? (I'm asking because this friend of mine accidently... ;))
 
By the way, what is the command to turn the menu back on? (I'm asking because this friend of mine accidently... ;))
Code:
menu show
or
Code:
menu on
 

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top