Am Pakfire weitergearbeitet.
[people/teissler/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
34 &Header::getcgihash(\%pakfiresettings);
35
36 &Header::openpage($Lang::tr{'pakfire configuration'}, 1);
37 &Header::openbigbox('100%', 'left', '', $errormessage);
38
39 if ($pakfiresettings{'ACTION'} eq 'install'){
40 if ("$pakfiresettings{'FORCE'}" eq "on") {
41 system("/usr/local/bin/pakfire", "install", "--non-interactive", "$pakfiresettings{'INSPAKS'}", "&");
42 sleep(1);
43 } else {
44 &Header::openbox("100%", "center", "Abfrage");
45 my @output = `/usr/local/bin/pakfire resolvedeps $pakfiresettings{'INSPAKS'}`;
46 print <<END;
47 <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.
48 <pre>
49 END
50 foreach (@output) {
51 print "$_\n";
52 }
53 print <<END;
54 </pre>
55 <tr><td colspan='2'>Moechten Sie der Installation aller Pakete zustimmen?
56 <tr><td colspan='2'>&nbsp;
57 <tr><td align='right'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
58 <input type='hidden' name='INSPAKS' value='$pakfiresettings{'INSPAKS'}' />
59 <input type='hidden' name='FORCE' value='on' />
60 <input type='hidden' name='ACTION' value='install' />
61 <input type='image' alt='$Lang::tr{'install'}' src='/images/go-next.png' />
62 </form>
63 <td align='left'>
64 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
65 <input type='hidden' name='ACTION' value='' />
66 <input type='image' alt='$Lang::tr{'abort'}' src='/images/dialog-error.png' />
67 </form>
68 </table>
69 END
70 &Header::closebox();
71 &Header::closebigbox();
72 &Header::closepage();
73 exit;
74 }
75 } elsif ($pakfiresettings{'ACTION'} eq 'remove') {
76
77 } elsif ($pakfiresettings{'ACTION'} eq 'update') {
78
79 system("/usr/local/bin/pakfire update --force");
80
81 } elsif ($pakfiresettings{'ACTION'} eq 'unlock') {
82
83 &Pakfire::lock("off");
84
85 } elsif ($pakfiresettings{'ACTION'} eq "$Lang::tr{'save'}") {
86
87 &General::writehash("${General::swroot}/pakfire/settings", \%pakfiresettings);
88 }
89
90 &General::readhash("${General::swroot}/pakfire/settings", \%pakfiresettings);
91
92 my %selected=();
93 my %checked=();
94
95 $checked{'AUTOUPDATE'}{'off'} = '';
96 $checked{'AUTOUPDATE'}{'on'} = '';
97 $checked{'AUTOUPDATE'}{$pakfiresettings{'AUTOUPDATE'}} = "checked='checked'";
98
99 # DPC move error message to top so it is seen!
100 if ($errormessage) {
101 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
102 print "<font class='base'>$errormessage&nbsp;</font>\n";
103 &Header::closebox();
104 }
105
106 if ( -e "/opt/pakfire/pakfire.lock" ) {
107 &Header::openbox("100%", "center", "Aktiv");
108 print <<END;
109 <table>
110 <tr><td>
111 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
112 <input type='hidden' name='ACTION' value='unlock' />
113 <input type='image' src='/images/indicator.gif' alt='$Lang::tr{'aktiv'}' />&nbsp;
114 </form>
115 <td>
116 Pakfire fuehrt gerade eine Aufgabe aus... Bitte warten sie, bis diese erfolgreich beendet wurde.
117 <tr><td colspan='2' align='center'>
118 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
119 <input type='image' alt='$Lang::tr{'reload'}' src='/images/view-refresh.png' />
120 </form>
121 </table>
122 END
123 &Header::closebox();
124 &Header::closebigbox();
125 &Header::closepage();
126 exit;
127 }
128
129 &Header::openbox("100%", "center", "Pakfire");
130
131 print <<END;
132 <table width='100%'>
133 <tr><td width='40%' align="center">Verfuegbare Addons:<br />
134 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
135 <select name="INSPAKS" size="10" multiple>
136 END
137 &Pakfire::dblist("notinstalled", "forweb");
138
139 print <<END;
140 </select>
141 </td>
142 <td width='20%' align="center">
143 <input type='hidden' name='ACTION' value='install' />
144 <input type='image' alt='$Lang::tr{'install'}' src='/images/list-add.png' />
145 </form><br />
146
147 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
148 <input type='hidden' name='ACTION' value='update' />
149 <input type='submit' value='Liste aktualisieren' /><br />
150 </form>
151
152 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
153 <input type='hidden' name='ACTION' value='remove' />
154 <input type='image' alt='$Lang::tr{'remove'}' src='/images/list-remove.png' />
155 </td>
156 <td width='40%' align="center">Installierte Addons:<br />
157 <select name="DELPAKS" size="10" multiple>
158 END
159
160 &Pakfire::dblist("installed", "forweb");
161
162 print <<END;
163 </select>
164 </table></form>
165 <br /><hr /><br />
166 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
167 <table width='100%'>
168 <tr><td width='40%' align="right">Automatische Updates taeglich ausfuehren:
169 <td width='10%' align="left"><input type="checkbox" name="AUTOUPDATE" $checked{'AUTOUPDATE'}{'on'} />
170 <td width='40%' align="right">Test:
171 <td width='10%' align="left"><input type="checkbox" name="AUTOUPDATE" $checked{'AUTOUPDATE'}{'on'} />
172 <tr><td width='100%' colspan="4" align="right"><input type="submit" name="ACTION" value="$Lang::tr{'save'}" />
173 </table>
174 </form>
175 END
176
177 &Header::closebox();
178 &Header::closebigbox();
179 &Header::closepage();