Developer Shell Usage and Commands
-
Hello,
I am looking to automate a number of tasks through the developer shell such as adding/removing aliases, rules, etc. I have the basic process down and have been able to modify basic settings. Does anyone have an example of adding/modifying a firewall rule or deleting objects such as aliases or rules?
Any help would be appreciated.
Here is an example of what I have so far to add/modify an alias. I use this command:" ssh admin@192.168.1.1 '/usr/local/sbin/pfSsh.php' < cmds.txt " to feed the below commands to the shell so they become active. What I can't figure out is how to add a rule or delete an object.
$config['aliases']['alias'][1] = array(
"name" => "GoogleDNS",
"address" => "8.8.8.8",
"descr" => "GoogleDNS",
"type" => "host",
"detail" => "Added via script");write_config();
exec;
exit -
basically you "unset" the variable and write the config again
see how the webgui does it here:
https://github.com/pfsense/pfsense/blob/master/src/usr/local/www/firewall_aliases.php#L134-L145adding&deleting fw rules can also be found in the webgui sources but are somewhat more complex
to add/edit https://github.com/pfsense/pfsense/blob/master/src/usr/local/www/firewall_rules_edit.php (you probably need to understand most of this file, to safely add rules)
to delete https://github.com/pfsense/pfsense/blob/master/src/usr/local/www/firewall_rules.php#L224-L244 -
Has anyone actually done this before and can provide an example of a rule addition from the developer shell?