Commit e2a82d38 authored by Franco Fichtner's avatar Franco Fichtner

rc: fix factory defaults #124

parent 4d336198
......@@ -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) {
......
......@@ -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);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment