]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blobdiff - html/cgi-bin/pakfire.cgi
aliases.cgi: Use new system methods
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / pakfire.cgi
index 39389ad0241ec71c5a95eb15446d62dccaa68aa7..631587ce27ae4fdeaea2b67da26306a6dcef67eb 100644 (file)
@@ -49,20 +49,18 @@ sub refreshpage{&Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' cont
 &Header::getcgihash(\%cgiparams);
 
 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
-&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
+&General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color);
 
 &Header::openpage($Lang::tr{'pakfire configuration'}, 1);
 &Header::openbigbox('100%', 'left', '', $errormessage);
 
-if ($cgiparams{'ACTION'} eq 'install'){
+if (($cgiparams{'ACTION'} eq 'install') && (! -e $Pakfire::lockfile)) {
        $cgiparams{'INSPAKS'} =~ s/\|/\ /g;
        if ("$cgiparams{'FORCE'}" eq "on") {
-               my $command = "/usr/local/bin/pakfire install --non-interactive --no-colors $cgiparams{'INSPAKS'} &>/dev/null &";
-               system("$command");
-               system("/bin/sleep 1");
+               &General::system_background("/usr/local/bin/pakfire", "install", "--non-interactive", "--no-colors", $cgiparams{'INSPAKS'});
        } else {
                &Header::openbox("100%", "center", $Lang::tr{'request'});
-               my @output = `/usr/local/bin/pakfire resolvedeps --no-colors $cgiparams{'INSPAKS'}`;
+               my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", $cgiparams{'INSPAKS'});
                print <<END;
                <table><tr><td colspan='2'>$Lang::tr{'pakfire install package'}.$cgiparams{'INSPAKS'}.$Lang::tr{'pakfire possible dependency'}
                <pre>
@@ -93,16 +91,14 @@ END
                &Header::closepage();
                exit;
        }
-} elsif ($cgiparams{'ACTION'} eq 'remove') {
+} elsif (($cgiparams{'ACTION'} eq 'remove') && (! -e $Pakfire::lockfile)) {
 
        $cgiparams{'DELPAKS'} =~ s/\|/\ /g;
        if ("$cgiparams{'FORCE'}" eq "on") {
-               my $command = "/usr/local/bin/pakfire remove --non-interactive --no-colors $cgiparams{'DELPAKS'} &>/dev/null &";
-               system("$command");
-               system("/bin/sleep 1");
+               &General::system_background("/usr/local/bin/pakfire", "remove", "--non-interactive", "--no-colors", $cgiparams{'DELPAKS'});
        } else {
                &Header::openbox("100%", "center", $Lang::tr{'request'});
-               my @output = `/usr/local/bin/pakfire resolvedeps --no-colors $cgiparams{'DELPAKS'}`;
+               my @output = &General::system_output("/usr/local/bin/pakfire", "resolvedeps", "--no-colors", $cgiparams{'DELPAKS'});
                print <<END;
                <table><tr><td colspan='2'>$Lang::tr{'pakfire uninstall package'}.$cgiparams{'DELPAKS'}.$Lang::tr{'pakfire possible dependency'}
                <pre>
@@ -134,14 +130,10 @@ END
                exit;
        }
 
-} elsif ($cgiparams{'ACTION'} eq 'update') {
-
-       system("/usr/local/bin/pakfire update --force --no-colors &>/dev/null &");
-       system("/bin/sleep 1");
-} elsif ($cgiparams{'ACTION'} eq 'upgrade') {
-       my $command = "/usr/local/bin/pakfire upgrade -y --no-colors &>/dev/null &";
-       system("$command");
-       system("/bin/sleep 1");
+} elsif (($cgiparams{'ACTION'} eq 'update') && (! -e $Pakfire::lockfile)) {
+       &General::system_background("/usr/local/bin/pakfire", "update", "--force", "--no-colors");
+} elsif (($cgiparams{'ACTION'} eq 'upgrade') && (!-e $Pakfire::lockfile)) {
+       &General::system_background("/usr/local/bin/pakfire", "upgrade", "-y", "--no-colors");
 } elsif ($cgiparams{'ACTION'} eq "$Lang::tr{'save'}") {
        $pakfiresettings{"TREE"} = $cgiparams{"TREE"};
 
@@ -154,7 +146,7 @@ END
                &General::writehash("${General::swroot}/pakfire/settings", \%pakfiresettings);
 
                # Update lists
-               system("/usr/local/bin/pakfire update --force --no-colors &>/dev/null &");
+               &General::system_background("/usr/local/bin/pakfire", "update", "--force", "--no-colors");
        }
 }
 
@@ -176,14 +168,12 @@ if ($errormessage) {
        &Header::closebox();
 }
 
-my $return = `pidof pakfire`;
-chomp($return);
-if ($return) {
+if (-e $Pakfire::lockfile) {
        &Header::openbox( 'Waiting', 1, "<meta http-equiv='refresh' content='10;'>" );
        print <<END;
        <table>
                <tr><td>
-                               <img src='/images/indicator.gif' alt='$Lang::tr{'aktiv'}' title='$Lang::tr{'aktiv'}' />&nbsp;
+                               <img src='/images/indicator.gif' alt='$Lang::tr{'active'}' title='$Lang::tr{'active'}' />&nbsp;
                        <td>
                                $Lang::tr{'pakfire working'}
                <tr><td colspan='2' align='center'>
@@ -217,7 +207,7 @@ my $packages_update_age = &General::age("/opt/pakfire/db/lists/packages_list.db"
 &Header::openbox("100%", "center", "Pakfire");
 
 print <<END;
-       <table width='95%' cellpadding='5' >
+       <table width='95%' cellpadding='5'>
 END
 if ( -e "/var/run/need_reboot") {
        print "<tr><td align='center' colspan='2'><font color='red'>$Lang::tr{'needreboot'}!</font></td></tr>";
@@ -225,18 +215,21 @@ if ( -e "/var/run/need_reboot") {
 }
 print <<END;
                <tr><td width="50%" bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'pakfire system state'}:</b>
-                               <td width="50%">
+
+                       <td width="50%" bgcolor='$color{'color20'}' align="center"><b>$Lang::tr{'available updates'}:</b></tr>
+
                <tr><td align="center">$Lang::tr{'pakfire core update level'}: $core_release<hr />
                                        $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='hidden' name='ACTION' value='update' /><br />
                                                <input type='submit' value='$Lang::tr{'calamaris refresh list'}' /><br />
                                        </form>
+<br />
                                <td align="center">
-                                <form method='post' action='$ENV{'SCRIPT_NAME'}'>
+                               <form method='post' action='$ENV{'SCRIPT_NAME'}'>
                                        <select name="UPDPAKS" size="5" disabled>
 END
                                                &Pakfire::dblist("upgrade", "forweb");
@@ -250,7 +243,7 @@ END
                <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">
+               <tr><td style="padding:5px 10px 20px 20px" align="center">
                        <p>$Lang::tr{'pakfire install description'}</p>
                        <form method='post' action='$ENV{'SCRIPT_NAME'}'>
                                <select name="INSPAKS" size="10" multiple>
@@ -264,7 +257,7 @@ print <<END;
                                <input type='image' alt='$Lang::tr{'install'}' title='$Lang::tr{'install'}' src='/images/list-add.png' />
                        </form>
 
-               <td align="center">
+               <td style="padding:5px 10px 20px 20px" align="center">
                        <p>$Lang::tr{'pakfire uninstall description'}</p>
                 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
                        <select name="DELPAKS" size="10" multiple>