Commit d1f97f7b authored by Franco Fichtner's avatar Franco Fichtner

rc: simplify halt/reboot a bit and use synchronous halt on the console

parent f5b013a0
...@@ -1662,27 +1662,30 @@ function sync_system_time() { ...@@ -1662,27 +1662,30 @@ function sync_system_time() {
} }
function system_halt() function system_halt($sync = false)
{ {
system_reboot_cleanup(); system_reboot_cleanup();
mwexec("/usr/bin/nohup /usr/local/etc/rc.halt > /dev/null 2>&1 &"); $cmd ='/usr/local/etc/rc.halt > /dev/null 2>&1';
}
function system_reboot() {
global $g;
system_reboot_cleanup(); if (!$sync) {
$cmd = sprintf('/usr/bin/nohup %s &', $cmd);
}
mwexec("nohup /usr/local/etc/rc.reboot > /dev/null 2>&1 &"); mwexec($cmd);
} }
function system_reboot_sync() { function system_reboot($sync = false)
global $g; {
system_reboot_cleanup(); system_reboot_cleanup();
mwexec("/usr/local/etc/rc.reboot > /dev/null 2>&1"); $cmd ='/usr/local/etc/rc.reboot > /dev/null 2>&1';
if (!$sync) {
$cmd = sprintf('/usr/bin/nohup %s &', $cmd);
}
mwexec($cmd);
} }
function system_reboot_cleanup() { function system_reboot_cleanup() {
...@@ -1841,7 +1844,7 @@ function system_check_reset_button() { ...@@ -1841,7 +1844,7 @@ function system_check_reset_button() {
EOD; EOD;
reset_factory_defaults(); reset_factory_defaults();
system_reboot_sync(); system_reboot(true);
exit(0); exit(0);
} }
......
...@@ -52,7 +52,7 @@ if (strcasecmp(chop(fgets($fp)), "y") == 0) { ...@@ -52,7 +52,7 @@ if (strcasecmp(chop(fgets($fp)), "y") == 0) {
EOD; EOD;
system_reboot_sync(); system_reboot(true);
} }
fclose($fp); fclose($fp);
...@@ -39,7 +39,7 @@ echo "\nDo you want to proceed [y|n]? "; ...@@ -39,7 +39,7 @@ echo "\nDo you want to proceed [y|n]? ";
if (strcasecmp(chop(fgets($fp)), 'y') == 0) { if (strcasecmp(chop(fgets($fp)), 'y') == 0) {
echo "\n{$g['product_name']} will shutdown and halt system now.\n"; echo "\n{$g['product_name']} will shutdown and halt system now.\n";
system_halt(); system_halt(true);
} }
fclose($fp); fclose($fp);
...@@ -40,7 +40,7 @@ echo "\nDo you want to proceed [y|n]? "; ...@@ -40,7 +40,7 @@ echo "\nDo you want to proceed [y|n]? ";
if (strcasecmp(chop(fgets($fp)), 'y') == 0) { if (strcasecmp(chop(fgets($fp)), 'y') == 0) {
echo "\n{$g['product_name']} is rebooting now.\n\n"; echo "\n{$g['product_name']} is rebooting now.\n\n";
system_reboot_sync(); 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