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
e2a82d38
Commit
e2a82d38
authored
Apr 02, 2015
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rc: fix factory defaults #124
parent
4d336198
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
25 deletions
+13
-25
config.lib.inc
src/etc/inc/config.lib.inc
+10
-13
rc.initial.defaults
src/etc/rc.initial.defaults
+3
-12
No files found.
src/etc/inc/config.lib.inc
View file @
e2a82d38
...
...
@@ -198,15 +198,12 @@ function write_config($desc = 'Unknown', $backup = true)
* RESULT
* integer - indicates completion
******/
function
reset_factory_defaults
(
$lock
=
false
)
function
reset_factory_defaults
()
{
global
$g
;
if
(
!
$lock
)
$lockkey
=
lock
(
'config'
,
LOCK_EX
);
/* create conf directory, if necessary */
safe_
mkdir
(
'/conf'
);
@
mkdir
(
'/conf'
);
/* clear out /conf */
$dh
=
opendir
(
'/conf'
);
...
...
@@ -217,17 +214,17 @@ function reset_factory_defaults($lock = false)
}
closedir
(
$dh
);
/* copy default configuration */
copy
(
'/usr/local/etc/config.xml'
,
'/conf/config.xml'
);
disable_security_checks
();
/* call the wizard */
touch
(
"/conf/trigger_initial_wizard"
);
if
(
!
$lock
)
touch
(
'/conf/trigger_initial_wizard'
);
unlock
(
$lockkey
);
setup_serial_port
();
return
0
;
/* as we go through a special case directly reboot */
mwexec
(
'/sbin/shutdown -or now'
);
}
function
config_restore
(
$conffile
)
{
...
...
src/etc/rc.initial.defaults
View file @
e2a82d38
...
...
@@ -33,26 +33,17 @@ require_once("config.lib.inc");
require_once
(
"functions.inc"
);
$fp
=
fopen
(
'php://stdin'
,
'r'
);
$yes_no_prompt
=
'[y|n]? '
;
echo
<<<EOD
You are about to reset the firewall to factory defaults.
The firewall will reboot after resetting the configuration.
Do you want to proceed
[y|n]?
Do you want to proceed
{$yes_no_prompt}
EOD;
if
(
strcasecmp
(
chop
(
fgets
(
$fp
)),
"y"
)
==
0
)
{
if
(
strcasecmp
(
chop
(
fgets
(
$fp
)),
'y'
)
==
0
)
{
reset_factory_defaults
();
echo
<<<EOD
{$g['product_name']} is rebooting now.
EOD;
system_reboot
(
true
);
}
fclose
(
$fp
);
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