]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/cgi-bin/pakfire.cgi
Fixed language string on pakfire.cgi.
[people/teissler/ipfire-2.x.git] / html / cgi-bin / pakfire.cgi
old mode 100644 (file)
new mode 100755 (executable)
index 2116062..da761f0
@@ -44,29 +44,40 @@ $pakfiresettings{'INSPAKS'} = '';
 $pakfiresettings{'DELPAKS'} = '';
 $pakfiresettings{'AUTOUPDATE'} = 'off';
 $pakfiresettings{'AUTOUPGRADE'} = 'off';
+$pakfiresettings{'HEALTHCHECK'} = 'on';
 $pakfiresettings{'UUID'} = 'on';
 
+sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='1;'>" );print "<center><img src='/images/clock.gif' alt='' /><br/><font color='red'>$Lang::tr{'pagerefresh'}</font></center>";&Header::closebox();}
+
 &Header::getcgihash(\%pakfiresettings);
+
 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
 
 &Header::openpage($Lang::tr{'pakfire configuration'}, 1);
 &Header::openbigbox('100%', 'left', '', $errormessage);
 
+# check if reboot is necessary
+my $reboot = 0;
+if (`find /var/run/need_reboot 2>/dev/null`) {
+       $reboot = 1;    
+}
+
 if ($pakfiresettings{'ACTION'} eq 'install'){
        $pakfiresettings{'INSPAKS'} =~ s/\|/\ /g;
        if ("$pakfiresettings{'FORCE'}" eq "on") {
                my $command = "/usr/local/bin/pakfire install --non-interactive --no-colors $pakfiresettings{'INSPAKS'} &>/dev/null &";
                system("$command");
-               sleep(2);
+               system("/bin/sleep 1");
        } else {
-               &Header::openbox("100%", "center", "Abfrage");
+               &Header::openbox("100%", "center", $Lang::tr{'request'});
        my @output = `/usr/local/bin/pakfire resolvedeps --no-colors $pakfiresettings{'INSPAKS'}`;
                print <<END;
                <table><tr><td colspan='2'>$Lang::tr{'pakfire install package'}.$pakfiresettings{'INSPAKS'}.$Lang::tr{'pakfire possible dependency'}
-               <pre>           
+               <pre>
 END
                foreach (@output) {
+                 $_ =~ s/\\e\[[0-1]\;[0-9]+m//g;
                        print "$_\n";
                }
                print <<END;
@@ -97,15 +108,16 @@ END
        if ("$pakfiresettings{'FORCE'}" eq "on") {
                my $command = "/usr/local/bin/pakfire remove --non-interactive --no-colors $pakfiresettings{'DELPAKS'} &>/dev/null &";
                system("$command");
-               sleep(2);
+               system("/bin/sleep 1");
        } else {
-               &Header::openbox("100%", "center", "Abfrage");
+               &Header::openbox("100%", "center", $Lang::tr{'request'});
        my @output = `/usr/local/bin/pakfire resolvedeps --no-colors $pakfiresettings{'DELPAKS'}`;
                print <<END;
                <table><tr><td colspan='2'>$Lang::tr{'pakfire uninstall package'}.$pakfiresettings{'DELPAKS'}.$Lang::tr{'pakfire possible dependency'}
-               <pre>           
+               <pre>
 END
                foreach (@output) {
+                 $_ =~ s/\\e\[[0-1]\;[0-9]+m//g;
                        print "$_\n";
                }
                print <<END;
@@ -132,25 +144,25 @@ END
        }
 
 } elsif ($pakfiresettings{'ACTION'} eq 'update') {
-       
-       system("/usr/local/bin/pakfire update --force --no-colors &>/dev/null");
 
+       system("/usr/local/bin/pakfire update --force --no-colors &>/dev/null &");
+       system("/bin/sleep 1");
 } elsif ($pakfiresettings{'ACTION'} eq 'upgrade') {
-       
-       system("/usr/local/bin/pakfire upgrade -y --no-colors &>/dev/null");
-       
+       my $command = "/usr/local/bin/pakfire upgrade -y --no-colors &>/dev/null &";
+       system("$command");
+       system("/bin/sleep 1");
 } elsif ($pakfiresettings{'ACTION'} eq "$Lang::tr{'save'}") {
 
-       if ($pakfiresettings{'AUTOUPDATE'} == "on") {
-               system("/usr/local/bin/pakfire enable updates");
+       if ($pakfiresettings{'AUTOUPDATE'} eq 'on') {
+               system("/usr/local/bin/pakfire enable updates >/dev/null 2>&1");
        } else {
-               system("/usr/local/bin/pakfire disable updates");
+               system("/usr/local/bin/pakfire disable updates  >/dev/null 2>&1");
        }
-       
-       if ($pakfiresettings{'AUTOUPGRADE'} == "on") {
-               system("/usr/local/bin/pakfire enable upgrades");
+
+       if ($pakfiresettings{'AUTOUPGRADE'} eq 'on') {
+               system("/usr/local/bin/pakfire enable upgrades >/dev/null 2>&1");
        } else {
-               system("/usr/local/bin/pakfire disable upgrades");
+               system("/usr/local/bin/pakfire disable upgrades >/dev/null 2>&1");
        }
 
        &General::writehash("${General::swroot}/pakfire/settings", \%pakfiresettings);
@@ -167,6 +179,9 @@ $checked{'AUTOUPDATE'}{$pakfiresettings{'AUTOUPDATE'}} = "checked='checked'";
 $checked{'AUTOUPGRADE'}{'off'} = '';
 $checked{'AUTOUPGRADE'}{'on'} = '';
 $checked{'AUTOUPGRADE'}{$pakfiresettings{'AUTOUPGRADE'}} = "checked='checked'";
+$checked{'HEALTHCHECK'}{'off'} = '';
+$checked{'HEALTHCHECK'}{'on'} = '';
+$checked{'HEALTHCHECK'}{$pakfiresettings{'HEALTHCHECK'}} = "checked='checked'";
 $checked{'UUID'}{'off'} = '';
 $checked{'UUID'}{'on'} = '';
 $checked{'UUID'}{$pakfiresettings{'UUID'}} = "checked='checked'";
@@ -194,7 +209,7 @@ if ($return) {
                        </form>
                <tr><td colspan='2' align='left'><pre>
 END
-       my @output = `tail -20 /var/log/pakfire.log`;
+       my @output = `grep pakfire /var/log/messages | tail -20`;
        foreach (@output) {
                print "$_";
        }
@@ -206,9 +221,10 @@ END
        &Header::closebigbox();
        &Header::closepage();
        exit;
+       refreshpage();
 }
 
-my $core_release = `cat /opt/pakfire/db/core/mine`;
+my $core_release = `cat /opt/pakfire/db/core/mine 2>/dev/null`;
 chomp($core_release);
 my $core_update_age = &General::age("/opt/pakfire/db/core/mine");
 my $corelist_update_age = &General::age("/opt/pakfire/db/lists/core-list.db");
@@ -218,17 +234,23 @@ my $packages_update_age = &General::age("/opt/pakfire/db/lists/packages_list.db"
 &Header::openbox("100%", "center", "Pakfire");
 
 print <<END;
-       <table width='100%' cellpadding='5' >
+       <table width='95%' cellpadding='5' >
+END
+if ($reboot == 1) {
+       print "<tr><td align='center' colspan='2'><font color='red'>$Lang::tr{'needreboot'}!</font></td></tr>";
+       print "<tr><td colspan='2'>&nbsp;</font></td></tr>"
+}
+print <<END;
                <tr><td width="50%" bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire system state'}:</b>
                                <td width="50%">
                <tr><td align="center">$Lang::tr{'pakfire core update level'}: $core_release<hr />
-                                       $Lang::tr{'pakfire last update'} $core_update_age ago<br />
-                                       $Lang::tr{'pakfire last serverlist update'} $server_update_age ago<br />
-                                       $Lang::tr{'pakfire last core list update'} $corelist_update_age ago<br />
-                                       $Lang::tr{'pakfire last package update'} $packages_update_age ago
+                                       $Lang::tr{'pakfire last update'} $core_update_age $Lang::tr{'pakfire ago'}<br />
+                                       $Lang::tr{'pakfire last serverlist update'} $server_update_age $Lang::tr{'pakfire ago'}<br />
+                                       $Lang::tr{'pakfire last core list update'} $corelist_update_age $Lang::tr{'pakfire ago'}<br />
+                                       $Lang::tr{'pakfire last package update'} $packages_update_age $Lang::tr{'pakfire ago'}
                                        <form method='post' action='$ENV{'SCRIPT_NAME'}'>
                                                <input type='hidden' name='ACTION' value='update' />
-                                               <input type='submit' value='Liste aktualisieren' /><br />
+                                               <input type='submit' value='$Lang::tr{'calamaris refresh list'}' /><br />
                                        </form>
                                <td align="center">
                                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
@@ -241,17 +263,17 @@ END
                                        <input type='hidden' name='ACTION' value='upgrade' />
                                        <input type='image' alt='$Lang::tr{'upgrade'}' src='/images/document-save.png' />
                                 </form>
-               
+
                <tr><td colspan="2"><!-- Just an empty line -->&nbsp;
                <tr><td bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire available addons'}</b>
                                <td bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire installed addons'}</b>
                <tr><td align="center">
-                       <p>($Lang::tr{'pakfire install description'}</p>
-                       <form method='post' action='$ENV{'SCRIPT_NAME'}'>       
+                       <p>$Lang::tr{'pakfire install description'}</p>
+                       <form method='post' action='$ENV{'SCRIPT_NAME'}'>
                                <select name="INSPAKS" size="10" multiple>
 END
                        &Pakfire::dblist("notinstalled", "forweb");
-               
+
 print <<END;
                                </select>
                                <br />
@@ -260,7 +282,7 @@ print <<END;
                        </form>
 
                <td align="center">
-                       <p>($Lang::tr{'pakfire uninstall description'}</p>
+                       <p>$Lang::tr{'pakfire uninstall description'}</p>
                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
                        <select name="DELPAKS" size="10" multiple>
 END
@@ -281,16 +303,21 @@ END
 
 print <<END;
        <form method='post' action='$ENV{'SCRIPT_NAME'}'>
-               <table width='100%'>
-                       <tr><td colspan='4' bgcolor='$color{'color20'}'><b>$Lang::tr{'basic options'}</b>
-                       <tr><td width='40%' align="right">$Lang::tr{'pakfire update daily'}
-                                       <td width='10%' align="left"><input type="checkbox" name="AUTOUPDATE" $checked{'AUTOUPDATE'}{'on'} />
-                                       <td width='40%' align="right">$Lang::tr{'pakfire register'} 
-                                       <td width='10%' align="left"><input type="checkbox" name="UUID" $checked{'UUID'}{'on'} />
-                       <tr><td width='40%' align="right">$Lang::tr{'pakfire core update auto'}
-                                       <td width='10%' align="left"><input type="checkbox" name="AUTOUPGRADE" $checked{'AUTOUPGRADE'}{'on'} />
-                                       <td width='50%' colspan="2">&nbsp;
-                       <tr><td width='100%' colspan="4" align="center"><input type="submit" name="ACTION" value="$Lang::tr{'save'}" />
+               <table width='95%'>
+                       <tr><td colspan='2' bgcolor='$color{'color20'}'><b>$Lang::tr{'basic options'}</b></td></tr>
+                       <tr><td align='left' width='45%'>$Lang::tr{'pakfire update daily'}</td><td width="55%" align="left">
+          on <input type='radio' name='AUTOUPDATE' value='on' $checked{'AUTOUPDATE'}{'on'} /> |
+          <input type='radio' name='AUTOUPDATE' value='off' $checked{'AUTOUPDATE'}{'off'} /> off </td></tr>
+                       <tr><td align='left' width='45%'>$Lang::tr{'pakfire core update auto'}</td><td align="left">
+          on <input type='radio' name='AUTOUPGRADE' value='on' $checked{'AUTOUPGRADE'}{'on'} /> |
+          <input type='radio' name='AUTOUPGRADE' value='off' $checked{'AUTOUPGRADE'}{'off'} /> off </td></tr>
+                       <tr><td align='left' width='45%'>$Lang::tr{'pakfire health check'}</td><td align="left">
+          on <input type='radio' name='HEALTHCHECK' value='on' $checked{'HEALTHCHECK'}{'on'} /> |
+          <input type='radio' name='HEALTHCHECK' value='off' $checked{'HEALTHCHECK'}{'off'} /> off </td></tr>          
+                       <tr><td align='left' width='45%'>$Lang::tr{'pakfire register'}</td><td align="left">
+          on <input type='radio' name='UUID' value='on' $checked{'UUID'}{'on'} /> |
+          <input type='radio' name='UUID' value='off' $checked{'UUID'}{'off'} /> off </td></tr>
+                       <tr><td colspan="2" align="center"><input type="submit" name="ACTION" value="$Lang::tr{'save'}" /></td></tr>
                </table>
        </form>
 END