OPNSense CLI interface on Roadmap?

Started by ittchmh, January 28, 2016, 09:50:54 AM

Previous topic - Next topic
Hi!

Then MS closed TMG Server development I started searching alternatives, more then 2 years ago
I choesed Vyatta, after some time I falining love into CLI, but after a few months Vyatta was sold to Brocard and Open Source project was closed. I switched to pfSense.

Configuration with CLI is very fast and very easy to edit template config.
After open source project Vyatta was closed, community forked project, now it is VyOS, it based on PERL

If OPNsens has API will it be easy to add CLI?
Or CLI is somewere in roadmap?



Hi,

For configuration changes we focus on a restful api, which can easily be used by various scripting languages and automation tools. We're haven't planned a separate  control to set parameters from the CLI at the moment.

A lot of commands however will (are) also available from the cli by using our configd system.

Regards,

Ad

Quote from: AdSchellevis on January 28, 2016, 11:13:03 AMA lot of commands however will (are) also available from the cli by using our configd system.

Are these listed somewhere?

the command templates are installed in /usr/local/opnsense/service/conf/actions.d/

A list can be obtained by:

configctl configd actions


Which is also a defined command...

Thanks!

For reference, the list looks like this
# configctl configd actions
...
proxy fetchacls [ Fetch external Proxy (squid) ACLs ]
service reload all [  ]
proxy restart [  ]
proxy status [  ]
captiveportal restart [  ]
...


and listed actions are invoked like this:
# configctl proxy status
squid is running as pid 99218.



Hi.

Are there any documentation about configctl?

TKS

How to upgrade from CLI?

I tried configctl firmware upgrade, which returns OK
and then configctl firmware status, which returns Cannot update. Why?

And is it possible to add a firewall rule from CLI?

Thanks a lot in advance!

Quote from: keketoutfou on September 07, 2017, 02:24:46 PM
How to upgrade from CLI?
using the right number in the menu (12 if I remember correctly)

Quote from: keketoutfou on September 07, 2017, 02:24:46 PM
And is it possible to add a firewall rule from CLI?
Not with the default tools - you would have to edit /config/config.xml or write a service file and reload the filter afterwards. There is no command for that.

September 07, 2017, 03:15:00 PM #8 Last Edit: September 08, 2017, 08:00:21 AM by keketoutfou
Thanks a lot for your quick response!

I'm using rundeck, a job scheduler and playbook automation. I want to upgrade multiple OPNsense instances at the same time with a job that will execute a few lines to upgrade each instance. I access instances using ssh and executing commands on them. Therefore I have no visual access and cannot use the menu you above quoted. I thought configctl firmware upgrade could be exactly what I am looking for. Could you explain why it return a 'cannot upgrade' error even though updates are available (I checked it using GUI).

Thanks in advance!

And one last question:
Is there a way to check whether ports are down/up and/or whether services are running/stopped through CLI, API or other?

Cheers!

September 29, 2017, 09:09:47 AM #10 Last Edit: September 29, 2017, 09:12:37 AM by jeje1307
QuoteI thought configctl firmware upgrade could be exactly what I am looking for. Could you explain why it return a 'cannot upgrade' error even though updates are available

QuoteAnd one last question:
Is there a way to check whether ports are down/up and/or whether services are running/stopped through CLI, API or other?

I've got the exact same questions as noname.

Did anyone find the answer ?

October 12, 2017, 04:07:59 PM #11 Last Edit: October 27, 2017, 02:23:38 PM by jeje1307
QuoteAnd one last question:
Is there a way to check whether ports are down/up and/or whether services are running/stopped through CLI, API or other?

if you just want to know if it's working Plugged or unplugged,
I did it, simply using shell command with regex. It's maybe not the best way to do it, but for now it work. And that's the best I can do.

I just started Linux a few days ago and i'm not a computer scientist neither a native english speaker, you have probably noticed that.

For exemple :

ifconfig igb2 | sed -n 's/.*status: \([^ ]*\).*/\1/gp'
Will result as : "Active" or if not active "no"

For the services i tried something probably unprofessionnal, but i've seen that a file with extension .pid was created when a services is running.

So i just create an if condition to see if yes or no the file is there.

if [ -e "/var/run/configd.pid" ];then
echo "configd active";
else
echo "configd not active"
fi


it doesn't work for all services, i'm trying to find another solution.

if you guys have a better idea, it would be great. Because i'm pretty sure what i did is like DIY.

HOW CAN I DELETE THIS MESSAGE ?

October 27, 2017, 02:21:06 PM #12 Last Edit: October 27, 2017, 02:23:01 PM by jeje1307
QuoteAnd one last question:
Is there a way to check whether ports are down/up and/or whether services are running/stopped through CLI, API or other?

if you just want to know if it's working Plugged or unplugged,
I did it, simply using shell command with regex. It's maybe not the best way to do it, but for now it work. And that's the best I can do.

I just started Linux a few days ago and i'm not a computer scientist neither a native english speaker, you have probably noticed that.

For exemple :

ifconfig igb2 | sed -n 's/.*status: \([^ ]*\).*/\1/gp'
Will result as : "Active" or if not active "no"

For the services i've seen that a file with extension .pid was created when a services is running.

#!/bin/sh
isvalidpid()
{
    /bin/pgrep -nF $1
}

is_process_running()
{
    /bin/pgrep -anx
}

if [ $(isvalidpid /var/run/ntpd.pid) > 1 ] && [ $(is_process_running) > 1 ]
then
    echo "Active"
else
    echo "Not"
fi