Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
156f8d44
Commit
156f8d44
authored
Mar 02, 2017
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
system: add captive portal session backup #1437
parent
83b5aae6
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
7 deletions
+51
-7
plist
plist
+1
-0
system.inc
src/etc/inc/system.inc
+4
-0
rc
src/etc/rc
+4
-4
rc.backup_captiveportal
src/etc/rc.backup_captiveportal
+14
-0
rc.shutdown
src/etc/rc.shutdown
+3
-3
system_advanced_misc.php
src/www/system_advanced_misc.php
+25
-0
No files found.
plist
View file @
156f8d44
...
...
@@ -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
...
...
src/etc/inc/system.inc
View file @
156f8d44
...
...
@@ -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
);
}
...
...
src/etc/rc
View file @
156f8d44
...
...
@@ -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 restor
e
# Restore backups from previous shutdown
for
BACKUP
in
captiveportal dhcpleases netflow rrd
;
do
/usr/local/etc/rc.backup_
${
BACKUP
}
restore
don
e
# Execute the early syshook / plugin commands
/usr/local/etc/rc.syshook early
...
...
src/etc/rc.backup_captiveportal
0 → 100755
View file @
156f8d44
#!/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
src/etc/rc.shutdown
View file @
156f8d44
...
...
@@ -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
...
...
src/www/system_advanced_misc.php
View file @
156f8d44
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment