OpenVPN using Luci (OpenWRT) ssh commands to get instances and enable/disable them
Posted: 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:

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:
Which produces an output like this:
And
Which produces an output like this:
And
Which produces an output like this:
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):
And I know that using:
or to stop the current enabled running instance and
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!
What I am trying to do is, use SSH luci, get a list of all my OpenVPN instances:

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
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'
Code: Select all
tail /etc/config/openvpn
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'
Code: Select all
lsof /usr/sbin/openvpn
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
Ideally I would like the output to be like this (instance name, enabled/disabled and PID):
Code: Select all
test0 enabled 28722
test1 disabled
Code: Select all
/etc/init.d/openvpn stop
Code: Select all
kill -9 <PID>
Code: Select all
/etc/init.d/openvpn start
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!