#!/mod/bin/jimsh

package require cgi
source /mod/webif/lib/setup
require queue.class system.class lock

httpheader

set act [cgi_get act -]
set slots [cgi_get slot ""]

if {$act eq "kill" } {
	foreach pid [queue pids] {
		catch {kill $pid}
	}

	if {![catch {acquire_lock webif_autorunq 5}]} {
		foreach slot [split $slots ","] {
			queue hold $slot
		}

		release_lock webif_autorunq
	}
} else {
	foreach slot [split $slots ","] {
		switch -- $act {
		    delete {
			queue delete_by_id $slot
		    }
		    resubmit {
			queue resubmit $slot
		    }
		    hold {
			queue hold $slot
		    }
		}
	}
}

