FOR TIPS, gUIDES & TUTORIALS

subscribe to our Youtube

GO TO YOUTUBE

14455 questions

17168 answers

28195 comments

0 members

We are migrating to our new platform at https://community.teltonika.lt. Moving forward, you can continue discussions on this new platform. This current platform will be temporarily maintained for reference purposes.
0 votes
406 views 0 comments
by anonymous

Hello,

I'm using the Teltonika RUT955 and I'm able to retrieve or set configuration using a Python script using following JSON.

Retrieve software version:

{

    "jsonrpc": "2.0", "id": 1, "method": "call", "params":

    [

        "000000000000000000000000000", "file", "read",

        {

            "path":"/etc/version"

        }

    ]

}

Set pass_changed (teltonika.sys.pass_changed=1) value to 1:

{

    "jsonrpc": "2.0", "id": 1, "method": "call", "params":

    [

        "00000000000000000000000", "uci", "set",

        {

            "config":"teltonika", 

            "section":"sys",

            "values":

             {

                     "pass_changed":1

              }

         }

    ]

}

Now I want to be able to create an OpenVPN client, I found the following UCI commands to do so:

# uci add openvpn client_MyClient
# uci set openvpn.client_MyClient=openvpn

But how can I translate this 'add'-method into JSON code?

Thanks alot!

1 Answer

0 votes
by anonymous
Hello Peetha,

For the Openvpn configuration config file can be found under /etc/config/openvpn. In config file not all config sections and options are present already, you will need to add sections and options using UCI commands.

UCI command to add the Openvpn client are:

uci set openvpn.tunnelX=openvpn

uci set openvpn.tunnelX.enable='1'  

After adding the section and options you  will need to commit the changes using <uci commit> command.

Follow link to know about the UCI command using the link:

https://wiki.teltonika-networks.com/view/UCI_command_usage#Summary

For using UCI commands with JSON you can replace the set command with add or add_list command in your example:

Follow link for more details on using UCI command with JSON

https://wiki.teltonika-networks.com/view/RUT240_Monitoring_via_JSON-RPC_windows

Below is the example for using UCI command with JSON:

To Create Openvpn Client:

{

    "jsonrpc":"2.0", "id":1, "method":"call", "params":

    [

        " session_id ", "uci", "add",

        {

        "config":"openvpn", "type":"openvpn", "name":"client _name"

        }

    ]

}

To Create options in the File:

{

    "jsonrpc":"2.0", "id":2, "method":"call", "params":

    [

        "0898ad57301f9df308b606e482e3a4d7", "uci", "set",

        {

        "config":"openvpn", "section":"client _name", "type":"openvpn", "values":

        {

        "keepalive":"10 120",

        "dev":"tunX",

        "persist_tun":"1",

        "type":"client",

        "_name":"client _name"

        }

        }

    ]

}

Next you will need to commit and reload changes.

Follow link for more details: https://wiki.teltonika-networks.com/view/RUT240_Monitoring_via_JSON-RPC_windows#UCI_COMMIT

Regards,

Shivang