mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Add voucher backup, configurable from Diagnostics > NanoBSD. Fixes #1087
This commit is contained in:
parent
95ceb35b91
commit
0d89a2fcac
@ -210,8 +210,21 @@ function captiveportal_configure() {
|
||||
|
||||
if (isset($config['captiveportal']['enable'])) {
|
||||
|
||||
if ($g['booting'])
|
||||
if ($g['booting']) {
|
||||
echo "Starting captive portal... ";
|
||||
if ($g['platform'] != "pfSense") {
|
||||
/* restore the vouchers, if we have them */
|
||||
if (file_exists("{$g['cf_conf_path']}/vouchers.tgz")) {
|
||||
$voucherrestore = "";
|
||||
$voucherreturn = "";
|
||||
exec("cd /;LANG=C /usr/bin/tar -xzf {$g['cf_conf_path']}/vouchers.tgz 2>&1", $voucherrestore, $voucherreturn);
|
||||
$voucherrestore = implode(" ", $voucherrestore);
|
||||
if($voucherreturn <> 0) {
|
||||
log_error("Voucher restore failed exited with $voucherreturn, the error is: $voucherrestore\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* kill any running mini_httpd */
|
||||
killbypid("{$g['varrun_path']}/lighty-CaptivePortal.pid");
|
||||
|
||||
8
etc/rc.backup_vouchers.sh
Normal file
8
etc/rc.backup_vouchers.sh
Normal file
@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Save the voucher databases to the config path.
|
||||
if [ -d "/var/db/" ]; then
|
||||
/etc/rc.conf_mount_rw
|
||||
cd / && tar -czf /cf/conf/vouchers.tgz -C / var/db/voucher_*.db
|
||||
/etc/rc.conf_mount_ro
|
||||
fi
|
||||
@ -32,4 +32,5 @@ if [ "$PLATFORM" = "pfSense" ]; then
|
||||
else
|
||||
/etc/rc.backup_rrd.sh
|
||||
/etc/rc.backup_dhcpleases.sh
|
||||
/etc/rc.backup_vouchers.sh
|
||||
fi
|
||||
|
||||
@ -108,6 +108,10 @@ if (isset($_POST['dhcpbackup'])) {
|
||||
$config['system']['dhcpbackup'] = $_POST['dhcpbackup'];
|
||||
install_cron_job("/etc/rc.backup_dhcpleases.sh", ($config['system']['dhcpbackup'] > 0), $minute="0", "*/{$config['system']['dhcpbackup']}");
|
||||
}
|
||||
if (isset($_POST['voucherbackup'])) {
|
||||
$config['system']['voucherbackup'] = $_POST['voucherbackup'];
|
||||
install_cron_job("/etc/rc.backup_voucherleases.sh", ($config['system']['voucherbackup'] > 0), $minute="0", "*/{$config['system']['voucherbackup']}");
|
||||
}
|
||||
|
||||
|
||||
if ($savemsg)
|
||||
@ -215,6 +219,23 @@ if ($savemsg)
|
||||
<br/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td width="22%" valign="top" class="vncell"><?=gettext("Voucher Backup");?></td>
|
||||
<td width="78%" class="vtable">
|
||||
<form action="diag_nanobsd.php" method="post" name="iform">
|
||||
<?=gettext("Frequency:");?>
|
||||
<select name='voucherbackup'>
|
||||
<option value='0' <? if (!isset($config['system']['voucherbackup']) || ($config['system']['voucherbackup'] == 0)) echo "selected"; ?>><?=gettext("Disable"); ?></option>
|
||||
<? for ($x=1; $x<=24; $x++) { ?>
|
||||
<option value='<?= $x ?>' <? if ($config['system']['voucherbackup'] == $x) echo "selected"; ?>><?= $x ?> <?=gettext("hour"); ?><? if ($x>1) echo "s"; ?></option>
|
||||
<? } ?>
|
||||
</select>
|
||||
<br/>
|
||||
<?=gettext("This will peridoically backup the Captive Portal Voucher Database so it can be restored automatically on the next boot. Keep in mind that the more frequent the backup, the more writes will happen to your media.");?>
|
||||
<br/>
|
||||
<br/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" class=""> </td><td><br/><input type='submit' value='<?=gettext("Save"); ?>'></form></td>
|
||||
</tr>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user