mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-20 03:16:12 +00:00
rc: fix factory defaults #124
This commit is contained in:
parent
4d336198be
commit
e2a82d38e7
@ -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);
|
||||
$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)
|
||||
unlock($lockkey);
|
||||
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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user