Samba-Update auf neues Patchlevel. Jaja, die Sicherheitsluecken oder sowas...
[ipfire-2.x.git] / html / cgi-bin / pakfire.cgi
1 #!/usr/bin/perl
2 #
3 # IPFire CGIs
4 #
5 # This file is part of the IPFire Project
6
7 # This code is distributed under the terms of the GPL
8 #
9 #
10
11 use strict;
12
13 # enable only the following on debugging purpose
14 use warnings;
15 use CGI::Carp 'fatalsToBrowser';
16
17 require '/var/ipfire/general-functions.pl';
18 require "${General::swroot}/lang.pl";
19 require "${General::swroot}/header.pl";
20 require "/opt/pakfire/lib/functions.pl";
21
22 my %pakfiresettings=();
23 my $errormessage = '';
24
25 &Header::showhttpheaders();
26
27 $pakfiresettings{'ACTION'} = '';
28 $pakfiresettings{'VALID'} = '';
29
30 $pakfiresettings{'INSPAKS'} = '';
31 $pakfiresettings{'DELPAKS'} = '';
32 $pakfiresettings{'AUTOUPDATE'} = '';
33 $pakfiresettings{'UUID'} = '';
34
35 &Header::getcgihash(\%pakfiresettings);
36
37 &Header::openpage($Lang::tr{'pakfire configuration'}, 1);
38 &Header::openbigbox('100%', 'left', '', $errormessage);
39
40 if ($pakfiresettings{'ACTION'} eq 'install'){
41         if ("$pakfiresettings{'FORCE'}" eq "on") {
42                 system("/usr/local/bin/pakfire", "install", "--non-interactive", "$pakfiresettings{'INSPAKS'}", "&");
43                 sleep(1);
44         } else {
45                 &Header::openbox("100%", "center", "Abfrage");
46                 my @output = `/usr/local/bin/pakfire resolvedeps $pakfiresettings{'INSPAKS'}`;
47                 print <<END;
48                 <table><tr><td colspan='2'>Sie maechten folgende Pakete installieren: $pakfiresettings{'INSPAKS'}. Moeglicherweise haben diese Pakete Abhaengigkeiten, d.h. andere Pakete muessen zusaetzlich installiert werden. Dazu sehen sie unten eine Liste.
49                 <pre>           
50 END
51                 foreach (@output) {
52                         print "$_\n";
53                 }
54                 print <<END;
55                 </pre>
56                 <tr><td colspan='2'>Moechten Sie der Installation aller Pakete zustimmen?
57                 <tr><td colspan='2'>&nbsp;
58                 <tr><td align='right'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
59                                                         <input type='hidden' name='INSPAKS' value='$pakfiresettings{'INSPAKS'}' />
60                                                         <input type='hidden' name='FORCE' value='on' />
61                                                         <input type='hidden' name='ACTION' value='install' />
62                                                         <input type='image' alt='$Lang::tr{'install'}' src='/images/go-next.png' />
63                                                 </form>
64                                 <td align='left'>
65                                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
66                                                         <input type='hidden' name='ACTION' value='' />
67                                                         <input type='image' alt='$Lang::tr{'abort'}' src='/images/dialog-error.png' />
68                                                 </form>
69                 </table>
70 END
71                 &Header::closebox();
72                 &Header::closebigbox();
73                 &Header::closepage();
74                 exit;
75         }
76 } elsif ($pakfiresettings{'ACTION'} eq 'remove') {
77
78 } elsif ($pakfiresettings{'ACTION'} eq 'update') {
79         
80         system("/usr/local/bin/pakfire update --force");
81
82 } elsif ($pakfiresettings{'ACTION'} eq 'unlock') {
83         
84         &Pakfire::lock("off");
85         
86 } elsif ($pakfiresettings{'ACTION'} eq "$Lang::tr{'save'}") {
87
88         &General::writehash("${General::swroot}/pakfire/settings", \%pakfiresettings);
89
90 }
91
92 &General::readhash("${General::swroot}/pakfire/settings", \%pakfiresettings);
93
94 my %selected=();
95 my %checked=();
96
97 $checked{'AUTOUPDATE'}{'off'} = '';
98 $checked{'AUTOUPDATE'}{'on'} = '';
99 $checked{'AUTOUPDATE'}{$pakfiresettings{'AUTOUPDATE'}} = "checked='checked'";
100 $checked{'UUID'}{'off'} = '';
101 $checked{'UUID'}{'on'} = '';
102 $checked{'UUID'}{$pakfiresettings{'UUID'}} = "checked='checked'";
103
104 # DPC move error message to top so it is seen!
105 if ($errormessage) {
106         &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
107         print "<font class='base'>$errormessage&nbsp;</font>\n";
108         &Header::closebox();
109 }
110
111 if ( -e "/opt/pakfire/pakfire.lock" ) {
112         &Header::openbox("100%", "center", "Aktiv");
113         print <<END;
114         <table>
115                 <tr><td>
116                         <form method='post' action='$ENV{'SCRIPT_NAME'}'>
117                                 <input type='hidden' name='ACTION' value='unlock' />
118                                 <input type='image' src='/images/indicator.gif' alt='$Lang::tr{'aktiv'}' />&nbsp;
119                         </form>
120                         <td>
121                                 Pakfire fuehrt gerade eine Aufgabe aus... Bitte warten sie, bis diese erfolgreich beendet wurde.
122                 <tr><td colspan='2' align='center'>
123                         <form method='post' action='$ENV{'SCRIPT_NAME'}'>
124                                 <input type='image' alt='$Lang::tr{'reload'}' src='/images/view-refresh.png' />
125                         </form>
126         </table>
127 END
128         &Header::closebox();
129         &Header::closebigbox();
130         &Header::closepage();
131         exit;
132 }
133
134 &Header::openbox("100%", "center", "Pakfire");
135
136 print <<END;
137         <table width='100%'>
138                 <tr><td width='40%' align="center">Verfuegbare Addons:<br />
139                         <form method='post' action='$ENV{'SCRIPT_NAME'}'>
140                                 <select name="INSPAKS" size="10" multiple>
141 END
142                         &Pakfire::dblist("notinstalled", "forweb");
143                 
144 print <<END;
145                                 </select>
146                 </td>
147                 <td width='20%' align="center">
148                                 <input type='hidden' name='ACTION' value='install' />
149                                 <input type='image' alt='$Lang::tr{'install'}' src='/images/list-add.png' />
150                         </form><br />
151                         
152                         <form method='post' action='$ENV{'SCRIPT_NAME'}'>
153                                 <input type='hidden' name='ACTION' value='update' />
154                                 <input type='submit' value='Liste aktualisieren' /><br />
155                         </form>
156                         
157                         <form method='post' action='$ENV{'SCRIPT_NAME'}'>
158                                 <input type='hidden' name='ACTION' value='remove' />
159                                 <input type='image' alt='$Lang::tr{'remove'}' src='/images/list-remove.png' />
160                 </td>
161                 <td width='40%' align="center">Installierte Addons:<br />
162                         <select name="DELPAKS" size="10" multiple>
163 END
164
165                         &Pakfire::dblist("installed", "forweb");
166
167 print <<END;
168                 </select>
169         </table></form>
170                 <br /><hr /><br />
171         <form method='post' action='$ENV{'SCRIPT_NAME'}'>
172         <table width='100%'>
173                 <tr><td colspan='2'>Zur Verfuegung stehende Updates:
174                 <tr><td width='20%'>&nbsp;<td width='60%' align='center'>
175                         <select name="UPDPAKS" size="5" disabled>
176 END
177
178                         &Pakfire::dblist("upgrade", "forweb");
179
180 print <<END;
181                         </select>
182                 <td width='20%' align='center' valign='middle'><input type='hidden' name='ACTION' value='upgrade' />
183                         <input type='image' alt='$Lang::tr{'upgrade'}' src='/images/document-save.png' />
184         </table></form>
185                 <br /><hr /><br />
186         <form method='post' action='$ENV{'SCRIPT_NAME'}'>
187                 <table width='100%'>
188                         <tr><td width='40%' align="right">Automatische Updates taeglich ausfuehren:
189                                         <td width='10%' align="left"><input type="checkbox" name="AUTOUPDATE" $checked{'AUTOUPDATE'}{'on'} />
190                                         <td width='40%' align="right">Registrierung am Master-Server: 
191                                         <td width='10%' align="left"><input type="checkbox" name="UUID" $checked{'UUID'}{'on'} />
192                         <tr><td width='100%' colspan="4" align="right"><input type="submit" name="ACTION" value="$Lang::tr{'save'}" />                                  
193                 </table>
194         </form>
195 END
196
197 &Header::closebox();
198 &Header::closebigbox();
199 &Header::closepage();