but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see [http://www.gnu.org/licenses/]. - BoneOS source code is available via svn at [http://svn.code.sf.net/p/boneos/code/]. - look at TeeBX website [http://www.teebx.com] to get details about license. */ require_once '/etc/inc/utils.lib.php'; require_once '/etc/inc/appliancebone.lib.php'; $in = fopen('php://stdin', 'r'); $out = fopen('php://stdout', 'w'); $msgProgress = 'Stopping running applications and Unmounting File Systems'; fwrite($out, "\nPlease hit [r] to reboot, uppercase [S] to shutdown or any other key to exit,\nthen press RETURN. How do you want to proceed [r/S]?\n >"); $opt = chop(fgets($in)); if (strcmp($opt, 'r') === 0) { $msg = 'The system is rebooting now. Please wait.'; $mode = 'reboot'; fwrite($out, $msgProgress . '...' . PHP_EOL); } elseif (strcmp($opt, 'S') === 0) { $msg = 'The system is shutting down and will be powered off if your platform support it. Please wait.'; $mode = 'poweroff'; fwrite($out, $msgProgress . '...' . PHP_EOL); } else { exit; } doSystemStop($mode); fwrite($out, $msg); sleep(10);
} $data['action'] = $_POST['action']; $stopOpts = array(); if (file_exists('/etc/inc/appliance.lib.php')) { include_once '/etc/inc/appliance.lib.php'; if (is_callable('getStopApplianceOptions')) { $stopOpts = getStopApplianceOptions(); } } if ($data['action'] === 'reboot' || $data['action'] === 'poweroff') { $data['msg'] = _('The system is rebooting now. Please wait.'); if ($data['action'] === 'poweroff') { $data['msg'] = _('The system is shutting down and will be powered off if your platform support it. Please wait.'); } sleep(1); $data['retval'] = doSystemStop($data['action']); } elseif ($data['action'] === 'prepare') { foreach (array_keys($stopOpts) as $opKey) { if (!isset($_POST[$opKey])) { continue; } if (is_callable($stopOpts[$opKey]['function'])) { $data['retval'] = call_user_func($stopOpts[$opKey]['function']); $data['msg'] = "<input type=\"hidden\" id =\"retval{$opKey}\" value=\"{$data['retval']}\">"; if ($data['retval'] == $stopOpts[$opKey]['expect']) { $data['msg'] .= $stopOpts[$opKey]['feedback_done']; } elseif ($stopOpts[$opKey]['mode'] == 'poll') { $data['msg'] .= $data['retval'] . ' ' . $stopOpts[$opKey]['feedback_wait']; } // only one task at a time break;