diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 193bd5c93..2773a4f5d 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -1662,27 +1662,30 @@ function sync_system_time() { } -function system_halt() +function system_halt($sync = false) { 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'; + + if (!$sync) { + $cmd = sprintf('/usr/bin/nohup %s &', $cmd); + } + + mwexec($cmd); } -function system_reboot() { - global $g; - +function system_reboot($sync = false) +{ system_reboot_cleanup(); - mwexec("nohup /usr/local/etc/rc.reboot > /dev/null 2>&1 &"); -} + $cmd ='/usr/local/etc/rc.reboot > /dev/null 2>&1'; -function system_reboot_sync() { - global $g; + if (!$sync) { + $cmd = sprintf('/usr/bin/nohup %s &', $cmd); + } - system_reboot_cleanup(); - - mwexec("/usr/local/etc/rc.reboot > /dev/null 2>&1"); + mwexec($cmd); } function system_reboot_cleanup() { @@ -1841,7 +1844,7 @@ function system_check_reset_button() { EOD; reset_factory_defaults(); - system_reboot_sync(); + system_reboot(true); exit(0); } diff --git a/src/etc/rc.initial.defaults b/src/etc/rc.initial.defaults index 5903e92d7..b35fed54f 100755 --- a/src/etc/rc.initial.defaults +++ b/src/etc/rc.initial.defaults @@ -52,7 +52,7 @@ if (strcasecmp(chop(fgets($fp)), "y") == 0) { EOD; - system_reboot_sync(); + system_reboot(true); } fclose($fp); diff --git a/src/etc/rc.initial.halt b/src/etc/rc.initial.halt index 82828ccf7..01fc88cab 100755 --- a/src/etc/rc.initial.halt +++ b/src/etc/rc.initial.halt @@ -39,7 +39,7 @@ echo "\nDo you want to proceed [y|n]? "; if (strcasecmp(chop(fgets($fp)), 'y') == 0) { echo "\n{$g['product_name']} will shutdown and halt system now.\n"; - system_halt(); + system_halt(true); } fclose($fp); diff --git a/src/etc/rc.initial.reboot b/src/etc/rc.initial.reboot index b93ab9c6f..5885dd6c1 100755 --- a/src/etc/rc.initial.reboot +++ b/src/etc/rc.initial.reboot @@ -40,7 +40,7 @@ echo "\nDo you want to proceed [y|n]? "; if (strcasecmp(chop(fgets($fp)), 'y') == 0) { echo "\n{$g['product_name']} is rebooting now.\n\n"; - system_reboot_sync(); + system_reboot(true); } fclose($fp);