mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 17:14:46 +00:00
system: add captive portal session backup #1437
This commit is contained in:
parent
83b5aae6c3
commit
156f8d445f
1
plist
1
plist
@ -71,6 +71,7 @@
|
||||
/usr/local/etc/pkg/fingerprints/OPNsense/trusted/opnsense-update.deciso.com.20160725
|
||||
/usr/local/etc/pkg/fingerprints/OPNsense/trusted/pkg.opnsense.org.20161210
|
||||
/usr/local/etc/rc
|
||||
/usr/local/etc/rc.backup_captiveportal
|
||||
/usr/local/etc/rc.backup_dhcpleases
|
||||
/usr/local/etc/rc.backup_netflow
|
||||
/usr/local/etc/rc.backup_rrd
|
||||
|
||||
@ -1606,6 +1606,10 @@ function system_cron_configure($verbose = false)
|
||||
$autocron[] = generate_cron_job('/usr/local/etc/rc.backup_netflow', '0', '*/' . $config['system']['netflowbackup']);
|
||||
}
|
||||
|
||||
if (!empty($config['system']['captiveportalbackup'])) {
|
||||
$autocron[] = generate_cron_job('/usr/local/etc/rc.backup_captiveportal', '0', '*/' . $config['system']['captiveportalbackup']);
|
||||
}
|
||||
|
||||
if (!empty($config['system']['remotebackup']['GDriveEnabled'])) {
|
||||
$autocron[] = generate_cron_job('/usr/local/opnsense/scripts/remote_backup.php', 0, 1);
|
||||
}
|
||||
|
||||
@ -241,10 +241,10 @@ done
|
||||
# Startup configd
|
||||
/usr/local/etc/rc.d/configd start
|
||||
|
||||
# Restore backups from previous shutdown (if any)
|
||||
/usr/local/etc/rc.backup_dhcpleases restore
|
||||
/usr/local/etc/rc.backup_netflow restore
|
||||
/usr/local/etc/rc.backup_rrd restore
|
||||
# Restore backups from previous shutdown
|
||||
for BACKUP in captiveportal dhcpleases netflow rrd; do
|
||||
/usr/local/etc/rc.backup_${BACKUP} restore
|
||||
done
|
||||
|
||||
# Execute the early syshook / plugin commands
|
||||
/usr/local/etc/rc.syshook early
|
||||
|
||||
14
src/etc/rc.backup_captiveportal
Executable file
14
src/etc/rc.backup_captiveportal
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
BACKUPFILE="/conf/captiveportal.sqlite"
|
||||
BACKUPDB="/var/captiveportal/captiveportal.sqlite"
|
||||
|
||||
if [ "${1}" = "restore" ]; then
|
||||
if [ -f "${BACKUPFILE}" ]; then
|
||||
cp "${BACKUPFILE}" "${BACKUPDB}"
|
||||
fi
|
||||
else
|
||||
if [ -f "${BACKUPDB}" ]; then
|
||||
sqlite3 "${BACKUPDB}" ".backup ${BACKUPFILE}"
|
||||
fi
|
||||
fi
|
||||
@ -10,9 +10,9 @@
|
||||
/usr/local/etc/rc.opnsense stop
|
||||
|
||||
# backup volatile internals
|
||||
/usr/local/etc/rc.backup_dhcpleases stop
|
||||
/usr/local/etc/rc.backup_netflow stop
|
||||
/usr/local/etc/rc.backup_rrd stop
|
||||
for BACKUP in captiveportal dhcpleases netflow rrd; do
|
||||
/usr/local/etc/rc.backup_${BACKUP} stop
|
||||
done
|
||||
|
||||
# wait for config lock to release
|
||||
php -a >/dev/null << EOF
|
||||
|
||||
@ -85,6 +85,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
$pconfig['rrdbackup'] = !empty($config['system']['rrdbackup']) ? $config['system']['rrdbackup'] : null;
|
||||
$pconfig['dhcpbackup'] = !empty($config['system']['dhcpbackup']) ? $config['system']['dhcpbackup'] : null;
|
||||
$pconfig['netflowbackup'] = !empty($config['system']['netflowbackup']) ? $config['system']['netflowbackup'] : null;
|
||||
$pconfig['captiveportalbackup'] = !empty($config['system']['captiveportalbackup']) ? $config['system']['captiveportalbackup'] : null;
|
||||
$pconfig['powerd_ac_mode'] = "hadp";
|
||||
if (!empty($config['system']['powerd_ac_mode'])) {
|
||||
$pconfig['powerd_ac_mode'] = $config['system']['powerd_ac_mode'];
|
||||
@ -174,6 +175,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
unset($config['system']['netflowbackup']);
|
||||
}
|
||||
|
||||
if (!empty($pconfig['captiveportalbackup'])) {
|
||||
$config['system']['captiveportalbackup'] = $pconfig['captiveportalbackup'];
|
||||
} elseif (isset($config['system']['captiveportalbackup'])) {
|
||||
unset($config['system']['captiveportalbackup']);
|
||||
}
|
||||
|
||||
write_config();
|
||||
$savemsg = get_std_save_message();
|
||||
|
||||
@ -340,6 +347,24 @@ include("head.inc");
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a id="help_for_captiveportalbackup" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Periodic Captive Portal Backup");?></td>
|
||||
<td>
|
||||
<select name="captiveportalbackup" class="selectpicker" data-style="btn-default" id="captiveportalbackup">
|
||||
<option value='0' <?= $pconfig['captiveportalbackup'] == 0 ? 'selected="selected"' : ''; ?>><?=gettext('Disabled'); ?></option>
|
||||
<?php
|
||||
for ($x = 1; $x <= 24; $x++): ?>
|
||||
<option value="<?= $x ?>" <?= $pconfig['captiveportalbackup'] == $x ? 'selected="selected"' : '';?>>
|
||||
<?= $x == 1 ? gettext('1 hour') : sprintf(gettext('%s hours'), $x) ?>
|
||||
</option>
|
||||
<?php
|
||||
endfor; ?>
|
||||
</select>
|
||||
<div class="hidden" for="help_for_captiveportalbackup">
|
||||
<?=gettext("This will periodically backup the captive portal session data so it can be restored automatically on the next boot.");?>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="2" valign="top" class="listtopic"><?=gettext("Power Savings"); ?></th>
|
||||
</tr>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user