Except the case pattern there doesn't cope with instance ids in parens. That'd be easy to fix:
if ! status myjob VAR=val | grep -qE '^[^ ]+( \([^)]\))? start/'; then start myjob VAR=val fi
except if the job is stopped, status will complain about "Unknown instance", so I ended up with this:
if initctl list|mawk '$1=="myjob" && $2=="(" INSTANCE ")" && $3~/start\// { exit 1 }' INSTANCE="$id"; then start myjob VAR="$id" fi
Definite interface smell here..
Except the case pattern there doesn't cope with instance ids in parens. That'd be easy to fix:
if ! status myjob VAR=val | grep -qE '^[^ ]+( \([^)]\))? start/'; then
start myjob VAR=val
fi
except if the job is stopped, status will complain about "Unknown instance", so I ended up with this:
if initctl list|mawk '$1=="myjob" && $2=="(" INSTANCE ")" && $3~/start\// { exit 1 }' INSTANCE="$id"; then
start myjob VAR="$id"
fi
Definite interface smell here..