summaryrefslogtreecommitdiffstats
path: root/etc/inc/voucher.inc
diff options
context:
space:
mode:
Diffstat (limited to 'etc/inc/voucher.inc')
-rw-r--r--etc/inc/voucher.inc32
1 files changed, 15 insertions, 17 deletions
diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc
index ad96914..be3e322 100644
--- a/etc/inc/voucher.inc
+++ b/etc/inc/voucher.inc
@@ -29,7 +29,7 @@
*/
/*
- pfSense_BUILDER_BINARIES: /usr/local/bin/voucher /usr/local/bin/minicron
+ pfSense_BUILDER_BINARIES: /usr/local/bin/voucher
pfSense_MODULE: captiveportal
*/
@@ -265,6 +265,9 @@ function voucher_expire($voucher_received) {
if ($active_dirty == true) {
foreach ($active_vouchers as $roll => $active)
voucher_write_active_db($roll, $active);
+
+ /* Triger a sync of the vouchers on config */
+ send_event("service sync vouchers");
}
// Write back the used DB's
@@ -440,6 +443,9 @@ function voucher_auth($voucher_received, $test = 0) {
$active_vouchers[$first_voucher_roll][$first_voucher] = "$timestamp,$minutes";
voucher_write_active_db($roll, $active_vouchers[$first_voucher_roll]);
+ /* Triger a sync of the vouchers on config */
+ send_event("service sync vouchers");
+
unlock($voucherlck);
return $total_minutes;
@@ -448,9 +454,6 @@ function voucher_auth($voucher_received, $test = 0) {
function voucher_configure($sync = false) {
global $config, $g;
- /* kill any running minicron */
- killbypid("{$g['varrun_path']}/vouchercron.pid");
-
if (!isset($config['voucher']['enable']))
return 0;
@@ -459,15 +462,6 @@ function voucher_configure($sync = false) {
if ($sync == true)
captiveportal_syslog("Writing voucher db from sync data...");
- // start cron if we're asked to save runtime DB periodically
- // to XML config if it changed
- $croninterval = $config['voucher']['saveinterval'] * 60; // need seconds. Config has minutes
- if ($croninterval) {
- /* start pruning process (interval defaults to 60 seconds) */
- mwexec("/usr/local/bin/minicron $croninterval {$g['varrun_path']}/vouchercron.pid " .
- "/etc/rc.savevoucher");
- }
-
$voucherlck = lock('voucher', LOCK_EX);
/* write public key used to verify vouchers */
@@ -564,8 +558,12 @@ function voucher_read_active_db($roll) {
}
}
fclose($fd);
- if ($dirty) // if we found expired entries, lets save our snapshot
+ if ($dirty) { // if we found expired entries, lets save our snapshot
voucher_write_active_db($roll, $active);
+
+ /* Triger a sync of the vouchers on config */
+ send_event("service sync vouchers");
+ }
}
}
return $active;
@@ -636,12 +634,12 @@ function voucher_log($priority, $message) {
}
/* Save active and used voucher DB into XML config and write it to flash
- * Called during reboot -> system_reboot_cleanup() and minicron
+ * Called during reboot -> system_reboot_cleanup() and every active voucher change
*/
function voucher_save_db_to_config() {
global $config, $g;
- if (!isset($config['voucher']['enable']) || $config['voucher']['saveinterval'] == 0)
+ if (!isset($config['voucher']['enable']))
return; // no vouchers or don't want to save DB's
$voucherlck = lock('voucher', LOCK_EX);
@@ -669,7 +667,7 @@ function voucher_save_db_to_config() {
unlock($voucherlck);
- write_config();
+ write_config("Synching vouchers");
return;
}
OpenPOWER on IntegriCloud