cookutils rev 824

handle multiple cook in cooktime
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Aug 06 09:08:56 2016 +0200 (2016-08-06)
parents e9aa5ca73c9a
children 47e7b3037588
files cook web/cooker.cgi
line diff
     1.1 --- a/cook	Fri Jul 29 12:06:02 2016 +0200
     1.2 +++ b/cook	Sat Aug 06 09:08:56 2016 +0200
     1.3 @@ -1888,7 +1888,11 @@
     1.4  		_ 'Cook started for: %s' "<a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log
     1.5  		echo "cook:$pkg" > $command
     1.6  		[ "$lastcooktime" ] &&
     1.7 -		echo "cook:$pkg $lastcooktime $(date +%s)" > $cooktime
     1.8 +		echo "cook:$pkg $lastcooktime $(date +%s)" >> $cooktime
     1.9 +		while read cmd duration start; do
    1.10 +			[ $(($start + $duration)) -lt $(date +%s) ] &&
    1.11 +			echo "sed -i '/^$cmd $duration/d' $cooktime"
    1.12 +		done < $cooktime | sh
    1.13  
    1.14  		# Display and log info if cook process stopped.
    1.15  		# FIXME: gettext not working (in single quotes) here!
     2.1 --- a/web/cooker.cgi	Fri Jul 29 12:06:02 2016 +0200
     2.2 +++ b/web/cooker.cgi	Sat Aug 06 09:08:56 2016 +0200
     2.3 @@ -218,8 +218,8 @@
     2.4  	local state="Not running"
     2.5  	if [ -s "$command" ]; then
     2.6  		state="$(cat $command)"
     2.7 -		if grep -q "^$state" $cooktime ; then
     2.8 -			set -- $(cat $cooktime)
     2.9 +		set -- $(grep "^$state" $cooktime)
    2.10 +		if [ -n "$1" ]; then
    2.11  			state="$state $((($(date +%s)-$3)*100/$2))%"
    2.12  			[ $2 -gt 300 ] && state="$state (should end $(date -u -d @$(($2+$3))))"
    2.13  		fi