Annotation of /alx-src/branches/alx-web-070/mageupgrade.php
Parent Directory | Revision Log
Revision 2597 -
(hide annotations)
(download)
Tue Jul 5 16:37:58 2011 UTC (13 years, 2 months ago) by niro
Original Path: alx-src/branches/alx-web-060/mageupgrade.php
File size: 5111 byte(s)
Tue Jul 5 16:37:58 2011 UTC (13 years, 2 months ago) by niro
Original Path: alx-src/branches/alx-web-060/mageupgrade.php
File size: 5111 byte(s)
-show a message if a system if fully upgraded and there are nor updates
1 | niro | 1610 | <? |
2 | |||
3 | niro | 2197 | include('include/dbconn.php'); |
4 | include('include/basesql.php'); | ||
5 | include('include/common-functions.php'); | ||
6 | niro | 1610 | |
7 | niro | 2197 | echo '<table width=100% height=100% style="border:solid black 1px; background-color:#d5e5ff"><tr><td valign=middle align=center>'; |
8 | niro | 1610 | |
9 | niro | 2197 | ?> |
10 | niro | 1610 | |
11 | niro | 2197 | <style type="text/css"> |
12 | div.left { margin-left:20%; } | ||
13 | </style> | ||
14 | niro | 1610 | |
15 | niro | 2197 | <? |
16 | niro | 1610 | |
17 | niro | 2197 | function update_client_settings() |
18 | { | ||
19 | global $client; | ||
20 | niro | 1610 | |
21 | niro | 2197 | // set verbose off |
22 | ssh_editvar('VERBOSE', 'off', '/etc/mage.rc'); | ||
23 | niro | 1629 | |
24 | niro | 2197 | // update rsync server location |
25 | $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'); | ||
26 | ssh_editvar('MAGE_RSYNC', $rsync, '/etc/alxconfig-ng/config.rc'); | ||
27 | ssh_editvar('RSYNC', $rsync, '/etc/mage.rc'); | ||
28 | niro | 1629 | |
29 | niro | 2197 | // update repository server location |
30 | $repository = sqlfirst('select client_locations.repository from client_serials inner join client_locations on client_locations.location=client_serials.location and client_serials.serial='.$client, 'repository'); | ||
31 | ssh_editvar('MAGE_MIRRORS', $repository, '/etc/alxconfig-ng/config.rc'); | ||
32 | ssh_editvar('MIRRORS', $repository, '/etc/mage.rc'); | ||
33 | niro | 1629 | |
34 | niro | 2197 | // update samba update host |
35 | $updateserver = sqlfirst('select client_locations.updateserver from client_serials inner join client_locations on client_locations.location=client_serials.location and client_serials.serial='.$client, 'updateserver'); | ||
36 | ssh_editvar('SMB_UPDATE_HOST', $updateserver, '/etc/alxconfig-ng/config.rc'); | ||
37 | niro | 1629 | |
38 | niro | 2197 | // update samba update user |
39 | $smbusername = sqlfirst('select client_locations.username from client_serials inner join client_locations on client_locations.location=client_serials.location and client_serials.serial='.$client, 'username'); | ||
40 | ssh_editvar('SMB_UPDATE_USER', $smbusername, '/etc/alxconfig-ng/config.rc'); | ||
41 | niro | 1610 | |
42 | niro | 2197 | // update samba update password |
43 | $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'); | ||
44 | ssh_editvar('SMB_UPDATE_PASS', $smbpassword, '/etc/alxconfig-ng/config.rc'); | ||
45 | } | ||
46 | niro | 1610 | |
47 | niro | 2488 | // get alx version info |
48 | $alxinfo = sqlfirst('SELECT * FROM client_version WHERE serial='.$client); | ||
49 | $alxos = $alxinfo[os]; | ||
50 | $alxutils = $alxinfo[utils]; | ||
51 | |||
52 | niro | 2197 | // always update the client settings first |
53 | update_client_settings(); | ||
54 | niro | 1610 | |
55 | niro | 2197 | if($op=="calc") |
56 | { | ||
57 | echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching list of packages to upgrade on client #'.$client.' ('.$ip.')...<br>'); | ||
58 | niro | 2488 | |
59 | 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); | ||
61 | } | ||
62 | else { | ||
63 | niro | 2596 | $out = sshdo('NOCOLORS=true /sbin/mageupgrade --calc-bash | cut -d, -f1-2,4 | sed "s/\(.*\)-r\(.*\)/\1,r\2/"', $ip); |
64 | niro | 2488 | } |
65 | niro | 2197 | echo '<pre>'; |
66 | echo '<table border="0">'; | ||
67 | niro | 2420 | if (array_key_exists("0", $out)) |
68 | niro | 2197 | { |
69 | niro | 2597 | // tell that there are no updates if $out/$i is empty |
70 | if ( $out[1] == "") | ||
71 | niro | 2197 | { |
72 | niro | 2597 | echo "No updates available. The system is fully upgraded."; |
73 | } else { | ||
74 | foreach( $out as $i) | ||
75 | niro | 2595 | { |
76 | niro | 2597 | // element 0 is always 0 |
77 | if ($i=="0") continue; | ||
78 | niro | 1610 | |
79 | niro | 2597 | $row=explode("\n", $i); |
80 | foreach( $row as $x) | ||
81 | { | ||
82 | //ignore empty rows | ||
83 | //(the last one may empty) | ||
84 | if ($x=="") continue; | ||
85 | niro | 2595 | |
86 | niro | 2597 | $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 | niro | 2595 | } |
100 | niro | 2197 | } |
101 | } | ||
102 | else echo 'No updates for client '.$client.' available.'; | ||
103 | echo '</table>'; | ||
104 | echo '</pre>'; | ||
105 | } | ||
106 | elseif($op=="update") | ||
107 | { | ||
108 | echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching new mage database for client #'.$client.' ('.$ip.')...<br>'); | ||
109 | echo '<br>'; | ||
110 | echo '<pre><div align=left class=left>'; | ||
111 | niro | 1610 | |
112 | niro | 2197 | sshdo('NOCOLORS=true /sbin/mage update', $ip); |
113 | niro | 1610 | |
114 | niro | 2197 | echo '</div></pre>'; |
115 | echo '<script language="JavaScript">alert(\'Database-update successfully completed on client #'.$client.' .\')</script>'; | ||
116 | } | ||
117 | elseif($op=="upgrade") | ||
118 | { | ||
119 | echo '<img src="pics/online.gif" align=top> '.strtoupper('Running update-alx on client #'.$client.' ('.$ip.')...<br>'); | ||
120 | echo '<br>'; | ||
121 | echo '<pre><div align=left class=left>'; | ||
122 | niro | 1610 | |
123 | niro | 2197 | # 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); | ||
125 | if($err[0]!=0) | ||
126 | { | ||
127 | echo '"update-alx" missing on client "'.$client.'". Updating mage and alxconfig-ng first ...<br>'; | ||
128 | sshdo('NOCOLORS=true mage install mage', $ip); | ||
129 | sshdo('NOCOLORS=true mage install alxconfig-ng', $ip); | ||
130 | } | ||
131 | $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>'; | ||
133 | else echo '<script language="JavaScript">alert(\'Upgrade successfully installed on client #'.$client.' .\')</script>'; | ||
134 | echo '</div></pre>'; | ||
135 | } | ||
136 | else echo 'unkown operation'; | ||
137 | echo '</td></tr></table>'; | ||
138 | niro | 1610 | |
139 | ?> |
Properties
Name | Value |
---|---|
svn:executable | * |