I managed to get it all working, I had to use a combination of the two solutions I had found. Following the post found at:https://forum.pfsense.org/index.php?topic=80789.15 I used the two scripts which left me with this:
To disable the captive portal, I made a script called rc.captiveportal_disable:
#!/usr/local/bin/php -f
/* $Id$ */
/*
rc.captiveportal_disable
copied and modified from rc.captiveportal_configure
*/
require("config.inc");
require("functions.inc");
require_once("filter.inc");
require("shaper.inc");
require("captiveportal.inc");
captiveportal_disable();
function captiveportal_disable() {
global $config, $cpzone, $argv;
if (is_array($config['captiveportal'])) {
foreach ($config['captiveportal'] as $cpkey => $cp) {
$cpzone = $cpkey;
if (strpos($argv[1], $cpzone) !== false) {
if (isset($cp['enable'])) {
unset($cp['enable']);
}
captiveportal_configure_zone($cp);
}
}
} else
mwexec("/sbin/sysctl net.link.ether.ipfw=0");
}
?>
And another disable script that I made to call the above script and unload all IPFW tables(called that one rc.captiveportaloff):
/etc/rc.captiveportal_disable vouchers
/sbin/kldunload ipfw.ko
After doing this the captive portal will be disabled and allowing internet traffic through
To re-enable I used the script to reconfigure the captive portal for the particular zone, named rc.captiveportal_enable:
#!/usr/local/bin/php -f
/* $Id$ */
/*
rc.captiveportal_disable
copied and modified from rc.captiveportal_configure
*/
require("config.inc");
require("functions.inc");
require_once("filter.inc");
require("shaper.inc");
require("captiveportal.inc");
captiveportal_enable();
function captiveportal_enable() {
global $config, $cpzone, $argv;
if (is_array($config['captiveportal'])) {
foreach ($config['captiveportal'] as $cpkey => $cp) {
$cpzone = $cpkey;
if (strpos($argv[1], $cpzone) !== false) {
$cp['enable']=true;
captiveportal_configure_zone($cp);
}
}
} else
mwexec("/sbin/sysctl net.link.ether.ipfw=0");
}
?>
Then another script to call the above script and reload all the IPFW tables, named rc.captiveportalon:
/sbin/kldload ipfw.ko
ipfw zone 2 create
/sbin/ipfw -x 2 -q /tmp/ipfw_vouchers.cp.rules
ipfw zone 2 madd hn1
/etc/rc.captiveportal_enable vouchers
Then use a cron job to call rc.captiveportaloff and rc.captiveportalon whenever you like. Seems like a dirty way of getting this done, but it works for me. It would take a bit more code if your are dealing with multiple zones, but for a single zone this works.
One other question, how does the tmp folder behave? I have my script using the ipfw rules found in /tmp/ipfw_vouchers.cp.rules, if I happen to reboot pfsense while CP is turned off, will it end up deleting that file thus breaking CP completely?