57 |
echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching list of packages to upgrade on client #'.$client.' ('.$ip.')...<br>'); |
echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching list of packages to upgrade on client #'.$client.' ('.$ip.')...<br>'); |
58 |
|
|
59 |
if($alxos >= '0.6.0') { |
if($alxos >= '0.6.0') { |
60 |
$out = sshdo('NOCOLORS=true /sbin/mage uppretend | egrep "\[.*\]" | sed "s:\[.*\]\ \(.*\):\1:" | sed "s:/:,:" | sed "s:\(.*\)-:\1,:" | sed "s:\(.*\)-:\1,:"', $ip); |
$out = @sshdo('NOCOLORS=true /sbin/mage uppretend | egrep "\[.*\]" | sed "s:\[.*\]\ \(.*\):\1:" | sed "s:/:,:" | sed "s:\(.*\)-:\1,:" | sed "s:\(.*\)-:\1,:"', $ip); |
61 |
} |
} |
62 |
else { |
else { |
63 |
$out = sshdo('NOCOLORS=true /sbin/mageupgrade --calc-bash', $ip); |
$out = @sshdo('NOCOLORS=true /sbin/mageupgrade --calc-bash | cut -d, -f1-2,4 | sed "s/\(.*\)-r\(.*\)/\1,r\2/"', $ip); |
64 |
} |
} |
65 |
echo '<pre>'; |
echo '<pre>'; |
66 |
echo '<table border="0">'; |
echo '<table border="0">'; |
67 |
if (array_key_exists("0", $out)) |
if (array_key_exists("0", $out)) |
68 |
{ |
{ |
69 |
foreach( $out as $i) |
// tell that there are no updates if $out/$i is empty |
70 |
|
if ( $out[1] == "") |
71 |
{ |
{ |
72 |
// element 0 is always 0 |
echo "No updates available. The system is fully upgraded."; |
73 |
if ($i=="0") continue; |
} else { |
74 |
|
foreach( $out as $i) |
75 |
$item=explode(",",$i); |
{ |
76 |
$pcat=$item[0]; |
// element 0 is always 0 |
77 |
$pname=$item[1]; |
if ($i=="0") continue; |
78 |
$pver=$item[2]; |
|
79 |
$pbuild=$item[3]; |
$row=explode("\n", $i); |
80 |
|
foreach( $row as $x) |
81 |
echo '<tr><td>'; |
{ |
82 |
echo '<font color=green>'.$pcat.'/'.$pname.'</font>'; |
//ignore empty rows |
83 |
echo '<td>'; |
//(the last one may empty) |
84 |
echo '<font color=blue> => [ '.$pver.'-'.$pbuild.' ] </font>'; |
if ($x=="") continue; |
85 |
echo '</td>'; |
|
86 |
echo '</td></tr>'; |
$item=explode(",",trim($x)); |
87 |
|
$pcat=$item[0]; |
88 |
|
$pname=$item[1]; |
89 |
|
$pver=$item[2]; |
90 |
|
$pbuild=$item[3]; |
91 |
|
|
92 |
|
echo '<tr><td>'; |
93 |
|
echo '<font color=green>'.$pcat.'/'.$pname.'</font>'; |
94 |
|
echo '<td>'; |
95 |
|
echo '<font color=blue> => [ '.$pver.'-'.$pbuild.' ] </font>'; |
96 |
|
echo '</td>'; |
97 |
|
echo '</td></tr>'; |
98 |
|
} |
99 |
|
} |
100 |
} |
} |
101 |
} |
} |
102 |
else echo 'No updates for client '.$client.' available.'; |
else echo 'No updates for client '.$client.' available.'; |
109 |
echo '<br>'; |
echo '<br>'; |
110 |
echo '<pre><div align=left class=left>'; |
echo '<pre><div align=left class=left>'; |
111 |
|
|
112 |
sshdo('NOCOLORS=true /sbin/mage update', $ip); |
@sshdo('NOCOLORS=true /sbin/mage update', $ip); |
113 |
|
|
114 |
echo '</div></pre>'; |
echo '</div></pre>'; |
115 |
echo '<script language="JavaScript">alert(\'Database-update successfully completed on client #'.$client.' .\')</script>'; |
echo '<script language="JavaScript">alert(\'Database-update successfully completed on client #'.$client.' .\')</script>'; |
121 |
echo '<pre><div align=left class=left>'; |
echo '<pre><div align=left class=left>'; |
122 |
|
|
123 |
# check if /usr/sbin/update-alx exists, if not update mage-alx and alxconfig-alx first |
# check if /usr/sbin/update-alx exists, if not update mage-alx and alxconfig-alx first |
124 |
$err = sshdo('[ -x /usr/sbin/update-alx ]', $ip); |
$err = @sshdo('[ -x /usr/sbin/update-alx ]', $ip); |
125 |
if($err[0]!=0) |
if($err[0]!=0) |
126 |
{ |
{ |
127 |
echo '"update-alx" missing on client "'.$client.'". Updating mage and alxconfig-ng first ...<br>'; |
echo '"update-alx" missing on client "'.$client.'". Updating mage and alxconfig-ng first ...<br>'; |
128 |
sshdo('NOCOLORS=true mage install mage', $ip); |
@sshdo('NOCOLORS=true mage install mage', $ip); |
129 |
sshdo('NOCOLORS=true mage install alxconfig-ng', $ip); |
@sshdo('NOCOLORS=true mage install alxconfig-ng', $ip); |
130 |
} |
} |
131 |
$err = sshdo('NOCOLORS=true /usr/sbin/update-alx', $ip); |
$err = @sshdo('NOCOLORS=true /usr/sbin/update-alx', $ip); |
132 |
if ($err[0]!=0) echo '<script language="JavaScript">alert(\'Upgrade *failed* on client #'.$client.' .\')</script>'; |
if ($err[0]!=0) echo '<script language="JavaScript">alert(\'Upgrade *failed* on client #'.$client.' .\')</script>'; |
133 |
else echo '<script language="JavaScript">alert(\'Upgrade successfully installed on client #'.$client.' .\')</script>'; |
else echo '<script language="JavaScript">alert(\'Upgrade successfully installed on client #'.$client.' .\')</script>'; |
134 |
echo '</div></pre>'; |
echo '</div></pre>'; |
135 |
} |
} |
136 |
else echo 'unkown operation'; |
else echo 'unknown operation'; |
137 |
echo '</td></tr></table>'; |
echo '</td></tr></table>'; |
138 |
|
|
139 |
?> |
?> |