OpenVPN using Luci (OpenWRT) ssh commands to get instances and enable/disable them

This forum is for general conversation and user-user networking.

Moderators: TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech, TinCanTech

Post Reply
stealthrt
OpenVpn Newbie
Posts: 1
Joined: Sun Jul 16, 2023 8:29 pm

OpenVPN using Luci (OpenWRT) ssh commands to get instances and enable/disable them

Post by stealthrt » Sun Jul 16, 2023 8:39 pm

Hey all I have been researching how to go about doing this but I have not really found anything on it.

What I am trying to do is, use SSH luci, get a list of all my OpenVPN instances:
Image

And be able to enable anyone of them by their Name.

So far the only ssh command(s) I have found to list my OpenVPN instances are:

Code: Select all

uci show openvpn
Which produces an output like this:

Code: Select all

......[more output here]....
openvpn.sample_client.cert='/etc/openvpn/client.crt'
openvpn.sample_client.key='/etc/openvpn/client.key'
openvpn.sample_client.verb='3'
openvpn.test0=openvpn
openvpn.test0.config='/etc/openvpn/test0.ovpn'
openvpn.test0.enabled='1'
openvpn.test1=openvpn
openvpn.test1.config='/etc/openvpn/test1.ovpn'
And

Code: Select all

tail /etc/config/openvpn
Which produces an output like this:

Code: Select all

option key '/etc/openvpn/client.key'
option verb '3'

config openvpn 'test0'
        option config '/etc/openvpn/test0.ovpn'
        option enabled '1'

config openvpn 'test1'
        option config '/etc/openvpn/test1.ovpn'
And

Code: Select all

lsof /usr/sbin/openvpn
Which produces an output like this:

Code: Select all

COMMAND     PID   USER    FD   TYPE   DEVICE   SIZE/OFF   NODE     NAME
openvpn   28722   root   txt    REG     0,16     450687   250828   /usr/sbin/openvpn
Which would just be nice if I can use grep to just get the names and it's PID from the above ssh commands instead of getting all that other data along with it.

Ideally I would like the output to be like this (instance name, enabled/disabled and PID):

Code: Select all

test0 enabled  28722
test1 disabled 
And I know that using:

Code: Select all

/etc/init.d/openvpn stop
or

Code: Select all

kill -9 <PID>
to stop the current enabled running instance and

Code: Select all

/etc/init.d/openvpn start
to start the current enabled running instance.

Other than that I can not seem to find the proper way of enabling and disabling an OpenVPN instance by it's name or PID.

Any help would be great!

Post Reply