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) ...@@ -198,15 +198,12 @@ function write_config($desc = 'Unknown', $backup = true)
* RESULT * RESULT
* integer - indicates completion * integer - indicates completion
******/ ******/
function reset_factory_defaults($lock = false) function reset_factory_defaults()
{ {
global $g; $lockkey = lock('config', LOCK_EX);
if (!$lock)
$lockkey = lock('config', LOCK_EX);
/* create conf directory, if necessary */ /* create conf directory, if necessary */
safe_mkdir('/conf'); @mkdir('/conf');
/* clear out /conf */ /* clear out /conf */
$dh = opendir('/conf'); $dh = opendir('/conf');
...@@ -217,17 +214,17 @@ function reset_factory_defaults($lock = false) ...@@ -217,17 +214,17 @@ function reset_factory_defaults($lock = false)
} }
closedir($dh); closedir($dh);
/* copy default configuration */
copy('/usr/local/etc/config.xml', '/conf/config.xml');
disable_security_checks(); disable_security_checks();
/* call the wizard */ /* call the wizard */
touch("/conf/trigger_initial_wizard"); touch('/conf/trigger_initial_wizard');
if (!$lock)
unlock($lockkey); unlock($lockkey);
setup_serial_port(); setup_serial_port();
return 0;
/* as we go through a special case directly reboot */
mwexec('/sbin/shutdown -or now');
} }
function config_restore($conffile) { function config_restore($conffile) {
......
...@@ -33,26 +33,17 @@ require_once("config.lib.inc"); ...@@ -33,26 +33,17 @@ require_once("config.lib.inc");
require_once("functions.inc"); require_once("functions.inc");
$fp = fopen('php://stdin', 'r'); $fp = fopen('php://stdin', 'r');
$yes_no_prompt = '[y|n]? ';
echo <<<EOD echo <<<EOD
You are about to reset the firewall to factory defaults. You are about to reset the firewall to factory defaults.
The firewall will reboot after resetting the configuration. The firewall will reboot after resetting the configuration.
Do you want to proceed [y|n]? Do you want to proceed {$yes_no_prompt}
EOD; EOD;
if (strcasecmp(chop(fgets($fp)), "y") == 0) { if (strcasecmp(chop(fgets($fp)), 'y') == 0) {
reset_factory_defaults(); reset_factory_defaults();
echo <<<EOD
{$g['product_name']} is rebooting now.
EOD;
system_reboot(true);
} }
fclose($fp); 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