Annotation of /alx-src/branches/alx-web-060/mageupgrade.php
Parent Directory | Revision Log
Revision 2197 -
(hide annotations)
(download)
Tue Jun 7 18:27:24 2011 UTC (13 years, 3 months ago) by niro
File size: 4406 byte(s)
Tue Jun 7 18:27:24 2011 UTC (13 years, 3 months ago) by niro
File size: 4406 byte(s)
-fixed whitepaces -use sshdo() for all client actions
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 | 2197 | // always update the client settings first |
48 | update_client_settings(); | ||
49 | niro | 1610 | |
50 | niro | 2197 | if($op=="calc") |
51 | { | ||
52 | echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching list of packages to upgrade on client #'.$client.' ('.$ip.')...<br>'); | ||
53 | $out = sshdo('NOCOLORS=true /sbin/mage uppretend | egrep "\[.*\]" | sed "s:\[.*\]\ \(.*\):\1:" | sed "s:/:,:" | sed "s:\(.*\)-:\1,:" | sed "s:\(.*\)-:\1,:"', $ip); | ||
54 | echo '<pre>'; | ||
55 | echo '<table border="0">'; | ||
56 | if (array_key_exists("0", $out[1])) | ||
57 | { | ||
58 | foreach( $out[1] as $i) | ||
59 | { | ||
60 | $item=explode(",",$i); | ||
61 | $pcat=$item[0]; | ||
62 | $pname=$item[1]; | ||
63 | $pver=$item[2]; | ||
64 | $pbuild=$item[3]; | ||
65 | niro | 1610 | |
66 | niro | 2197 | echo '<tr><td>'; |
67 | echo '<font color=green>'.$pcat.'/'.$pname.'</font>'; | ||
68 | echo '<td>'; | ||
69 | echo '<font color=blue> => [ '.$pver.'-'.$pbuild.' ] </font>'; | ||
70 | echo '</td>'; | ||
71 | echo '</td></tr>'; | ||
72 | } | ||
73 | } | ||
74 | else echo 'No updates for client '.$client.' available.'; | ||
75 | echo '</table>'; | ||
76 | echo '</pre>'; | ||
77 | } | ||
78 | elseif($op=="update") | ||
79 | { | ||
80 | echo '<img src="pics/online.gif" align=top> '.strtoupper('Fetching new mage database for client #'.$client.' ('.$ip.')...<br>'); | ||
81 | echo '<br>'; | ||
82 | echo '<pre><div align=left class=left>'; | ||
83 | niro | 1610 | |
84 | niro | 2197 | sshdo('NOCOLORS=true /sbin/mage update', $ip); |
85 | niro | 1610 | |
86 | niro | 2197 | echo '</div></pre>'; |
87 | echo '<script language="JavaScript">alert(\'Database-update successfully completed on client #'.$client.' .\')</script>'; | ||
88 | } | ||
89 | elseif($op=="upgrade") | ||
90 | { | ||
91 | echo '<img src="pics/online.gif" align=top> '.strtoupper('Running update-alx on client #'.$client.' ('.$ip.')...<br>'); | ||
92 | echo '<br>'; | ||
93 | echo '<pre><div align=left class=left>'; | ||
94 | niro | 1610 | |
95 | niro | 2197 | # check if /usr/sbin/update-alx exists, if not update mage-alx and alxconfig-alx first |
96 | $err = sshdo('[ -x /usr/sbin/update-alx ]', $ip); | ||
97 | if($err[0]!=0) | ||
98 | { | ||
99 | echo '"update-alx" missing on client "'.$client.'". Updating mage and alxconfig-ng first ...<br>'; | ||
100 | sshdo('NOCOLORS=true mage install mage', $ip); | ||
101 | sshdo('NOCOLORS=true mage install alxconfig-ng', $ip); | ||
102 | } | ||
103 | $err = sshdo('NOCOLORS=true /usr/sbin/update-alx', $ip); | ||
104 | if ($err[0]!=0) echo '<script language="JavaScript">alert(\'Upgrade *failed* on client #'.$client.' .\')</script>'; | ||
105 | else echo '<script language="JavaScript">alert(\'Upgrade successfully installed on client #'.$client.' .\')</script>'; | ||
106 | echo '</div></pre>'; | ||
107 | } | ||
108 | else echo 'unkown operation'; | ||
109 | echo '</td></tr></table>'; | ||
110 | niro | 1610 | |
111 | ?> |
Properties
Name | Value |
---|---|
svn:executable | * |