2021-04-19 11:26:43 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
rundir=${CIC_RUNDIR:-/run}
|
2021-04-19 13:41:53 +02:00
|
|
|
unit=${CIC_UNIT:-$HOSTNAME}
|
2021-04-19 11:26:43 +02:00
|
|
|
|
2021-04-19 13:41:53 +02:00
|
|
|
read p < $rundir/$unit/pid
|
2021-04-19 11:26:43 +02:00
|
|
|
|
|
|
|
if [ -z $p ]; then
|
2021-04-19 13:41:53 +02:00
|
|
|
>&2 echo unit $unit has no pid
|
2021-04-19 11:26:43 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -d /proc/$p ]; then
|
2021-04-19 13:41:53 +02:00
|
|
|
>&2 echo unit $unit reports non-existent pid $p
|
2021-04-19 11:26:43 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-04-19 13:41:53 +02:00
|
|
|
>&2 echo unit $unit has pid $p
|
2021-04-19 11:26:43 +02:00
|
|
|
|
2021-04-19 13:41:53 +02:00
|
|
|
if [ ! -f $rundir/$unit/error ]; then
|
|
|
|
>&2 echo unit $unit has unspecified state
|
2021-04-19 11:26:43 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-04-19 13:41:53 +02:00
|
|
|
read e 2> /dev/null < $rundir/$unit/error
|
2021-04-19 11:26:43 +02:00
|
|
|
if [ -z $e ]; then
|
2021-04-19 13:41:53 +02:00
|
|
|
>&2 echo unit $unit has unspecified state
|
2021-04-19 11:26:43 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-04-19 13:41:53 +02:00
|
|
|
>&2 echo unit $unit has error $e
|
2021-04-19 11:26:43 +02:00
|
|
|
|
|
|
|
if [ $e -gt 0 ]; then
|
|
|
|
exit 1;
|
|
|
|
fi
|