summaryrefslogblamecommitdiffstats
path: root/trigger.sh
blob: 4d6ad2ca273078c428fe114d782e38e789234274 (plain) (tree)
1
2
3
4
5
6
7
8







                               











                                                                                      









                                    
#!/bin/sh

printer="$1"
queue_dir="$2"
printed_dir=$queue_dir/printed/

mkdir -p $printed_dir

printqueue(){
	ls $queue_dir/new/* 2>/dev/null
}

queuedepth=$(printqueue | wc -l)

if [ ! -c "$printer" ] ; then
	printf "labelprinter is offline, there are %d jobs in queue\n" $queuedepth >&2
	exit 1
fi

for file in $(printqueue); do
	echo printing $file
	./ql570/ql570 $printer $file
	status=$?
	if [ $status -ne 0 ] ; then
		exit $status
	fi
	mv $file $printed_dir
done

exit 0