|
From: <abe...@us...> - 2009-11-06 22:54:56
|
Revision: 3413
http://astlinux.svn.sourceforge.net/astlinux/?rev=3413&view=rev
Author: abelbeck
Date: 2009-11-06 22:54:49 +0000 (Fri, 06 Nov 2009)
Log Message:
-----------
Web interface, System tab, a reboot can be scheduled within the next 24 hours
Modified Paths:
--------------
branches/0.7/package/webinterface/altweb/admin/system.php
branches/0.7/package/webinterface/altweb/common/functions.php
branches/0.7/package/webinterface/altweb/common/status.inc
branches/0.7/package/webinterface/altweb/common/version.php
Modified: branches/0.7/package/webinterface/altweb/admin/system.php
===================================================================
--- branches/0.7/package/webinterface/altweb/admin/system.php 2009-11-06 22:53:24 UTC (rev 3412)
+++ branches/0.7/package/webinterface/altweb/admin/system.php 2009-11-06 22:54:49 UTC (rev 3413)
@@ -98,6 +98,23 @@
return(30);
}
+// Function: getRebootDelayMenu
+//
+function getRebootDelayMenu() {
+ $start = (int)date('G');
+ $start = ($start % 2 == 0) ? $start + 1 : $start + 2;
+
+ $menuitems['Now'] = 0;
+ for ($i = 0; $i < 24; $i += 2) {
+ $key = str_pad(($start % 24), 2, '0', STR_PAD_LEFT).':00';
+ $menuitems[$key] = $start;
+ $start += 2;
+ }
+ $menuitems['Cancel'] = -1;
+
+ return($menuitems);
+}
+
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$result = 1;
if (! $global_admin) {
@@ -206,10 +223,21 @@
}
} elseif (isset($_POST['submit_reboot'])) {
$result = 99;
+ $delay = (int)$_POST['reboot_delay'];
if (isset($_POST['confirm_reboot'])) {
- systemREBOOT($myself, 10);
+ if ($delay == 0) {
+ systemREBOOT($myself, 10);
+ } else {
+ if (scheduleREBOOT($delay)) {
+ $result = ($delay > 0) ? 40 : 41;
+ } else if ($delay < 0) {
+ $result = 1;
+ }
+ }
} else {
$result = 7;
+ header('Location: '.$myself.'?reboot_delay='.$delay.'&result='.$result);
+ exit;
}
} elseif (isset($_POST['firmware_submit'])) {
$result = 99;
@@ -290,6 +318,12 @@
} else { // Start of HTTP GET
require_once '../common/header.php';
+ if (isset($_GET['reboot_delay'])) {
+ $reboot_delay = $_GET['reboot_delay'];
+ } else {
+ $reboot_delay = '0';
+ }
+
if (isset($_GET['firmware_action'])) {
$firmware_action = $_GET['firmware_action'];
} else {
@@ -337,6 +371,10 @@
putHtml('<p style="color: red;">Error writing configuration files.</p>');
} elseif ($result == 30) {
putHtml('<p style="color: green;">New Restored Configuration, Reboot System to apply.</p>');
+ } elseif ($result == 40) {
+ putHtml('<p style="color: green;">Reboot Scheduled within 24 hours.</p>');
+ } elseif ($result == 41) {
+ putHtml('<p style="color: green;">Scheduled Reboot Canceled.</p>');
} elseif ($result == 99) {
putHtml('<p style="color: red;">Action Failed.</p>');
} elseif ($result == 100 || $result == 101 || $result == 102) {
@@ -462,11 +500,20 @@
–
<input type="checkbox" value="reload" name="confirm_reload" /> Confirm
</td><td class="dialogText" style="text-align: center;">
- <input type="submit" value="Reboot" name="submit_reboot" />
- –
- <input type="checkbox" value="reboot" name="confirm_reboot" /> Confirm
- </td></tr>
<?php
+ putHtml('<select name="reboot_delay">');
+ $reboot_delay_menu = getRebootDelayMenu();
+ foreach ($reboot_delay_menu as $key => $value) {
+ $sel = ($reboot_delay == $value) ? ' selected="selected"' : '';
+ putHtml('<option value="'.$value.'"'.$sel.'>'.$key.'</option>');
+ }
+ putHtml('</select>');
+ putHtml('–');
+ putHtml('<input type="submit" value="Reboot" name="submit_reboot" />');
+ putHtml('–');
+ putHtml('<input type="checkbox" value="reboot" name="confirm_reboot" /> Confirm');
+ putHtml('</td></tr>');
+
putHtml('<tr><td style="text-align: center;" colspan="2">');
putHtml('<h2>System Firmware Upgrade:</h2>');
putHtml('</td></tr><tr><td class="dialogText" style="text-align: center;" colspan="2">');
Modified: branches/0.7/package/webinterface/altweb/common/functions.php
===================================================================
--- branches/0.7/package/webinterface/altweb/common/functions.php 2009-11-06 22:53:24 UTC (rev 3412)
+++ branches/0.7/package/webinterface/altweb/common/functions.php 2009-11-06 22:54:49 UTC (rev 3413)
@@ -103,6 +103,22 @@
}
}
+// Function: scheduleREBOOT
+//
+function scheduleREBOOT($delay) {
+ $time = time();
+
+ @system('killall reboot >/dev/null 2>/dev/null', $status);
+
+ $delay -= (int)date('G', $time);
+ if ($delay > 0) {
+ $delay *= 3600;
+ $delay -= ((int)date('i', $time) * 60);
+ @system('/sbin/reboot -d'.$delay.' >/dev/null 2>/dev/null &', $status);
+ }
+ return($status == 0 ? TRUE : FALSE);
+}
+
// Function: session_manual_gc
//
function session_manual_gc() {
Modified: branches/0.7/package/webinterface/altweb/common/status.inc
===================================================================
--- branches/0.7/package/webinterface/altweb/common/status.inc 2009-11-06 22:53:24 UTC (rev 3412)
+++ branches/0.7/package/webinterface/altweb/common/status.inc 2009-11-06 22:54:49 UTC (rev 3413)
@@ -21,6 +21,7 @@
// 02-11-2009, Added Firewall States
// 04-14-2009, Added OpenVPN Client Status
// 06-15-2009, Added IPsec Associations
+// 11-06-2009, Added Reboot Scheduled notice
//
// System location of OpenVPN Client logfile
$OVPNCLOGFILE = '/var/log/openvpnclient-status.log';
@@ -60,6 +61,7 @@
$status['openvpn'] = 0;
$status['racoon'] = 0;
$status['syslogd'] = 0;
+ $status['reboot'] = 0;
$tmpfile = tempnam("/tmp", "PHP_");
@system('ps >'.$tmpfile);
@@ -78,6 +80,8 @@
$status['openvpn']++;
} elseif (strpos($line, ' racoon') !== FALSE || strpos($line, '/racoon') !== FALSE) {
$status['racoon']++;
+ } elseif (strpos($line, 'reboot -d') !== FALSE) {
+ $status['reboot']++;
}
}
}
@@ -413,9 +417,10 @@
// uptime
$line = trim(shell_exec('uptime'));
if (preg_match('/^.*up *(.*)load average: *(.*)/i', $line, $matches)) {
+ $delayreboot = ($daemon['reboot'] > 0) ? ' - REBOOT SCHEDULED' : '';
echo '<tr ', ($i++ % 2 == 0) ? 'class="dtrow0"' : 'class="dtrow1"', '>';
echo '<td class="dialogText" style="text-align: right; font-weight: bold;">', 'System Uptime:', '</td>';
- echo '<td style="text-align: left;">', rtrim($matches[1], ', '), '</td>';
+ echo '<td style="text-align: left;">', rtrim($matches[1], ', ').$delayreboot, '</td>';
echo '<td class="dialogText" style="text-align: right; font-weight: bold;">', 'Load Average:', '</td>';
echo '<td style="text-align: left;">', $matches[2], '</td>';
putHtml('</tr>');
Modified: branches/0.7/package/webinterface/altweb/common/version.php
===================================================================
--- branches/0.7/package/webinterface/altweb/common/version.php 2009-11-06 22:53:24 UTC (rev 3412)
+++ branches/0.7/package/webinterface/altweb/common/version.php 2009-11-06 22:54:49 UTC (rev 3413)
@@ -1,6 +1,6 @@
<?php
// version.php for AstLinux Alternate Web Interface
-$GUI_VERSION = '1.6.01';
+$GUI_VERSION = '1.6.02';
?>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|