35 |
if($op=="calc") |
if($op=="calc") |
36 |
{ |
{ |
37 |
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>'); |
38 |
exec($sshcmd.' '.$ip.' mage uppretend',$out,$err); |
exec($sshcmd.' '.$ip.' NOCOLORS=true /sbin/mage uppretend | egrep "\[.*\]" | sed "s:\[.*\]\ \(.*\):\1:" | sed "s:/:,:" | sed "s:\(.*\)-:\1,:" | sed "s:\(.*\)-:\1,:"',$out,$err); |
39 |
echo '<pre>'; |
echo '<pre>'; |
40 |
echo '<table border="0">'; |
echo '<table border="0">'; |
41 |
if (array_key_exists("0", $out)) |
if (array_key_exists("0", $out)) |
42 |
{ |
{ |
43 |
foreach( $out as $i) |
foreach( $out as $i) |
44 |
{ |
{ |
45 |
|
if(strstr($i,"Magellan") |
46 |
|
{ |
47 |
|
continue; |
48 |
|
} |
49 |
|
if(strstr($i,"dependencies") |
50 |
|
{ |
51 |
|
continue; |
52 |
|
} |
53 |
$item=explode(",",$i); |
$item=explode(",",$i); |
54 |
$pcat=$item[0]; |
$pcat=$item[0]; |
55 |
$pname=$item[1]; |
$pname=$item[1]; |
56 |
$opver=$item[2]; |
$pver=$item[2]; |
57 |
$npver=$item[3]; |
$pbuild=$item[3]; |
58 |
|
|
59 |
echo '<tr><td>'; |
echo '<tr><td>'; |
60 |
echo '<font color=green>'.$pcat.'/'.$pname.'</font>'; |
echo '<font color=green>'.$pcat.'/'.$pname.'</font>'; |
61 |
echo '<td>'; |
echo '<td>'; |
62 |
echo '<font color=blue> [ '.$opver.' -> '.$npver.' ] </font>'; |
echo '<font color=blue> => [ '.$pver.'-'.$pbuild.' ] </font>'; |
63 |
echo '</td>'; |
echo '</td>'; |
64 |
echo '</td></tr>'; |
echo '</td></tr>'; |
65 |
} |
} |
73 |
echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching new mage database for client #'.$client.' ('.$ip.')...<br>'); |
echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching new mage database for client #'.$client.' ('.$ip.')...<br>'); |
74 |
echo '<br>'; |
echo '<br>'; |
75 |
echo '<pre><div align=left class=left>'; |
echo '<pre><div align=left class=left>'; |
|
// hotfix copy a fixed mage.rc |
|
|
//system('scp '.$magerc.' root@'.$ip.':/etc/mage.rc'); |
|
|
// hotfix2 and a config.rc |
|
|
//system('scp '.$configrc.' root@'.$ip.':/etc/alxconfig-ng/config.rc'); |
|
76 |
editvar("VERBOSE","off","/etc/mage.rc"); |
editvar("VERBOSE","off","/etc/mage.rc"); |
77 |
|
|
78 |
// update rsync server location |
// update rsync server location |
79 |
$rsync = sqlfirst('select client_locations.rsync from client_serials inner join client_locations on client_locations.location=client_serials.location and client_serials.serial='.$client, 'rsync'); |
$rsync = sqlfirst('select client_locations.rsync from client_serials inner join client_locations on client_locations.location=client_serials.location and client_serials.serial='.$client, 'client_locations.rsync'); |
|
echo $rsync; |
|
80 |
editvar("MAGE_RSYNC",$rsync,"/etc/alxconfig-ng/config.rc"); |
editvar("MAGE_RSYNC",$rsync,"/etc/alxconfig-ng/config.rc"); |
81 |
editvar("RSYNC",$rsync,"/etc/mage.rc"); |
editvar("RSYNC",$rsync,"/etc/mage.rc"); |
82 |
|
|
96 |
// update samba update password |
// update samba update password |
97 |
$smbpassword = sqlfirst('select client_locations.password from client_serials inner join client_locations on client_locations.location=client_serials.location and client_serials.serial='.$client, 'password'); |
$smbpassword = sqlfirst('select client_locations.password from client_serials inner join client_locations on client_locations.location=client_serials.location and client_serials.serial='.$client, 'password'); |
98 |
editvar("SMB_UPDATE_PASS",$smbpassword,"/etc/alxconfig-ng/config.rc"); |
editvar("SMB_UPDATE_PASS",$smbpassword,"/etc/alxconfig-ng/config.rc"); |
99 |
system($sshcmd.' '.$ip.' "NOCOLORS=true mage update"'); |
system($sshcmd.' '.$ip.' "NOCOLORS=true /sbin/mage update"'); |
100 |
|
|
101 |
echo '</div></pre>'; |
echo '</div></pre>'; |
102 |
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>'; |
106 |
echo '<img src="pics/online.gif" align=top> '.strtoupper('Running update-alx on client #'.$client.' ('.$ip.')...<br>'); |
echo '<img src="pics/online.gif" align=top> '.strtoupper('Running update-alx on client #'.$client.' ('.$ip.')...<br>'); |
107 |
echo '<br>'; |
echo '<br>'; |
108 |
echo '<pre><div align=left class=left>'; |
echo '<pre><div align=left class=left>'; |
|
#echo 'forcing verbose=off <br>'; |
|
|
// hotfix copy a fixed mage.rc |
|
|
//system('scp '.$magerc.' root@'.$ip.':/etc/mage.rc'); |
|
|
// hotfix2 and a config.rc |
|
|
//system('scp '.$configrc.' root@'.$ip.':/etc/alxconfig-ng/config.rc'); |
|
109 |
editvar("VERBOSE","off","/etc/mage.rc"); |
editvar("VERBOSE","off","/etc/mage.rc"); |
110 |
|
|
111 |
// update rsync server location |
// update rsync server location |
132 |
|
|
133 |
|
|
134 |
# 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 |
135 |
exec($sshcmd.' '.$ip.' "[ -x $(which update-alx) ] && exit 0 || exit 1"',$outarr,$err); |
exec($sshcmd.' '.$ip.' "[ -x /usr/sbin/update-alx ] && exit 0 || exit 1"',$outarr,$err); |
136 |
if($err!=0) |
if($err!=0) |
137 |
{ |
{ |
138 |
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>'; |
139 |
system($sshcmd.' '.$ip.' "NOCOLORS=true mage install mage"'); |
system($sshcmd.' '.$ip.' "NOCOLORS=true mage install mage"'); |
140 |
system($sshcmd.' '.$ip.' "NOCOLORS=true mage install alxconfig-ng"'); |
system($sshcmd.' '.$ip.' "NOCOLORS=true mage install alxconfig-ng"'); |
141 |
} |
} |
142 |
//system($sshcmd.' '.$ip.' "NOCOLORS=true update-alx"'); |
exec($sshcmd.' '.$ip.' "NOCOLORS=true /usr/sbin/update-alx && exit 0 || exit 1"',$outarr,$err); |
|
exec($sshcmd.' '.$ip.' "NOCOLORS=true update-alx && exit 0 || exit 1"',$outarr,$err); |
|
143 |
echo '</div></pre>'; |
echo '</div></pre>'; |
144 |
if ($err!=0) echo '<script language="JavaScript">alert(\'Upgrade *failed* on client #'.$client.' .\')</script>'; |
if ($err!=0) echo '<script language="JavaScript">alert(\'Upgrade *failed* on client #'.$client.' .\')</script>'; |
145 |
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>'; |