itsam
June 6, 2025, 11:46am
1
Hi Teltonika team,
we have many RUTX08 around the world and manage the I/O’s with a script.
In 07.13.4 is a syntax change (again), with 07.12.3 we can detect the OpenVPN by the name:
ifconfig | grep -q ‘VPNName ’
now it’s replaced by the “interface”:
ifconfig | grep -q ‘tun_ ’
Also enable and disable OpenVPN was before possible with:
uci set openvpn.VPNNAME .enable=‘0’
now the syntax of the setting is:
uci set openvpn.inst1 .enable=‘0’
Is there a better way to script this upgrade resistant?
Thanks.
pwsh
June 6, 2025, 7:55pm
2
Yes, use API it shouldn’t change between versions. https://developers.teltonika-networks.com/
Hello @itsam ,
Could you please confirm whether your issue has been resolved or if you still require any assistance?
Best regards,
itsam
June 10, 2025, 8:28am
5
Hi @Marija ,
still more questions than answers at the moment
Unfortunately the examples [1] don’t show how to script it local on the device as /bin/sh script.
I need the following:
read input
if yes connect openvpn and enable output (high)
else disconnect openvpn and disable output (low)
I can use the api local in the script without authentication, right?
[1] https://developers.teltonika-networks.com/tutorials/
pwsh
June 10, 2025, 2:45pm
6
It can be called locally without authentication by using /sbin/api
1 Like
itsam
July 22, 2025, 7:50am
7
Hello @Marija ,
do you have an example for me?
read state of OpenVPN connection
enable / disable OpenVPN connection
read digital input
enable / disable digital output
I try to replace our actual bash script with the new api…
Marija
July 22, 2025, 11:33am
8
Hello @itsam ,
Here are some API examples you can use in CLI and in your custom script:
To read the OpenVPN connection state , use api get /openvpn/status
More info: OpenVPN GET status
To disable the OpenVPN connection , use: api put /openvpn/config '{"data": [{"id": "inst1", "enable": "0"}]}'
To enable it , use: api put /openvpn/config '{"data": [{"id": "inst1", "enable": "1"}]}'
More info: OpenVPN PUT config
To read Input/Output status , use: api get /io/status
More info: Input/Output GET status
To enable a digital output , use: api post /io/dout1/actions/change_state '{"data": {"value": "1"}}'
To disable it , use: api post /io/dout1/actions/change_state '{"data": {"value": "0"}}'
More info: Input/Output POST change_state
Best regards,
1 Like
itsam
July 28, 2025, 1:21pm
9
Thank you @Marija for the examples!
How can I use the json output in my bash script?
Is there any tool to get this values in variables?
For example, how to test the output of api get /io/status [...?...]?
if [ "$iostatus" == "0" ] ; then
api post /io/dout1/actions/change_state '{"data": {"value": "1"}}'
else
echo "already enabled"
fi
(We don’t like to install additional add-ons, must be working with the basic RUTX08 firmware / commands).
Marija
July 29, 2025, 12:35pm
10
Hello @itsam ,
This is a simple example of the script which checks if OpenVPN disabled, and if it does, then it will enable it using API:
status=$(api get /openvpn/status | grep -o '"status":"[0-9]*"' | grep -o '[0-9]*')
if [ "$status" = "4" ]; then
api put /openvpn/config '{"data": [{"id": "inst1", "enable": "1"}]}'
Status 4 means the VPN instance is disconnected.
Status 2 means the VPN instance is connected.
Best regards,
1 Like
system
Closed
August 1, 2025, 12:36am
11
This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.