Samba-Update auf neues Patchlevel. Jaja, die Sicherheitsluecken oder sowas...
[ipfire-2.x.git] / html / cgi-bin / pakfire.cgi
CommitLineData
3ea75603
MT
1#!/usr/bin/perl
2#
78331e30 3# IPFire CGIs
3ea75603 4#
78331e30 5# This file is part of the IPFire Project
3ea75603
MT
6#
7# This code is distributed under the terms of the GPL
8#
3ea75603
MT
9#
10
11use strict;
12
13# enable only the following on debugging purpose
1bd42c89
MT
14use warnings;
15use CGI::Carp 'fatalsToBrowser';
3ea75603 16
986e08d9 17require '/var/ipfire/general-functions.pl';
3ea75603
MT
18require "${General::swroot}/lang.pl";
19require "${General::swroot}/header.pl";
1bd42c89 20require "/opt/pakfire/lib/functions.pl";
3ea75603
MT
21
22my %pakfiresettings=();
23my $errormessage = '';
24
25&Header::showhttpheaders();
26
27$pakfiresettings{'ACTION'} = '';
28$pakfiresettings{'VALID'} = '';
29
1bd42c89
MT
30$pakfiresettings{'INSPAKS'} = '';
31$pakfiresettings{'DELPAKS'} = '';
32$pakfiresettings{'AUTOUPDATE'} = '';
4b122800 33$pakfiresettings{'UUID'} = '';
3ea75603
MT
34
35&Header::getcgihash(\%pakfiresettings);
36
1bd42c89
MT
37&Header::openpage($Lang::tr{'pakfire configuration'}, 1);
38&Header::openbigbox('100%', 'left', '', $errormessage);
3ea75603 39
957363eb 40if ($pakfiresettings{'ACTION'} eq 'install'){
5b2a12ff
MT
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>
50END
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>
70END
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
1bd42c89 88 &General::writehash("${General::swroot}/pakfire/settings", \%pakfiresettings);
4b122800 89
3ea75603
MT
90}
91
92&General::readhash("${General::swroot}/pakfire/settings", \%pakfiresettings);
93
3ea75603
MT
94my %selected=();
95my %checked=();
96
1bd42c89
MT
97$checked{'AUTOUPDATE'}{'off'} = '';
98$checked{'AUTOUPDATE'}{'on'} = '';
99$checked{'AUTOUPDATE'}{$pakfiresettings{'AUTOUPDATE'}} = "checked='checked'";
4b122800
MT
100$checked{'UUID'}{'off'} = '';
101$checked{'UUID'}{'on'} = '';
102$checked{'UUID'}{$pakfiresettings{'UUID'}} = "checked='checked'";
3ea75603
MT
103
104# DPC move error message to top so it is seen!
105if ($errormessage) {
106 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
107 print "<font class='base'>$errormessage&nbsp;</font>\n";
108 &Header::closebox();
5b2a12ff
MT
109}
110
111if ( -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>
127END
128 &Header::closebox();
129 &Header::closebigbox();
130 &Header::closepage();
131 exit;
132}
3ea75603 133
1bd42c89
MT
134&Header::openbox("100%", "center", "Pakfire");
135
136print <<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>
141END
142 &Pakfire::dblist("notinstalled", "forweb");
143
144print <<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'}'>
5b2a12ff 153 <input type='hidden' name='ACTION' value='update' />
1bd42c89
MT
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>
957363eb 163END
5b2a12ff
MT
164
165 &Pakfire::dblist("installed", "forweb");
166
167print <<END;
1bd42c89
MT
168 </select>
169 </table></form>
170 <br /><hr /><br />
4b122800
MT
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>
176END
177
178 &Pakfire::dblist("upgrade", "forweb");
179
180print <<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 />
1bd42c89
MT
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'} />
4b122800
MT
190 <td width='40%' align="right">Registrierung am Master-Server:
191 <td width='10%' align="left"><input type="checkbox" name="UUID" $checked{'UUID'}{'on'} />
1bd42c89
MT
192 <tr><td width='100%' colspan="4" align="right"><input type="submit" name="ACTION" value="$Lang::tr{'save'}" />
193 </table>
194 </form>
195END
196
3ea75603 197&Header::closebox();
3ea75603 198&Header::closebigbox();
3ea75603 199&Header::closepage();