Updated init-functions to be more thorough in checking pids
This commit is contained in:
2
Makefile
2
Makefile
@@ -18,7 +18,7 @@ DESC = This package supplies the core required init scripts for startup
|
||||
ARCHIVE := ''
|
||||
SRCDIR := $(PWD)/SRC/initscripts
|
||||
PATCHDIR := $(PWD)/SRC/patches
|
||||
VERSION := 1.10-0
|
||||
VERSION := 1.11-0
|
||||
|
||||
include /usr/share/snap/Makefile.snaplinux
|
||||
|
||||
|
||||
@@ -117,9 +117,7 @@ pidofproc() {
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -n "$pidfile" ] && [ ! -r "$pidfile" ]; then
|
||||
return 1
|
||||
elif [ -n "$pidfile" ]; then
|
||||
if [ -r "$pidfile" ]; then
|
||||
pids=$(head -1 $pidfile|sed 's/ \+//g')
|
||||
else
|
||||
pids=$(pidof "$pathname")
|
||||
@@ -189,15 +187,51 @@ status_of_proc() {
|
||||
esac
|
||||
done
|
||||
|
||||
# Here we use LSB as a reference for the return values:
|
||||
#
|
||||
# 0 program is running or service is OK
|
||||
# 1 program is dead and /var/run pid file exists
|
||||
# 2 program is dead and /var/lock lock file exists
|
||||
# 3 program is not running
|
||||
# 4 program or service status is unknown
|
||||
# 5-99 reserved for future LSB use
|
||||
# 100-149 reserved for distribution use
|
||||
# 150-199 reserved for application use
|
||||
# 200-254 reserved
|
||||
#
|
||||
# As you can see however, for now we just support 0, 1, 3 and 4
|
||||
# May do something for 2 at some point, but the other status
|
||||
# codes should not be used here - they're only here for reference
|
||||
|
||||
if [ -n "$pidfile" ]; then
|
||||
pid=$(pidofproc -p "$pidfile" "$pathname");
|
||||
if [ -r "$pidfile" ]; then
|
||||
pid=$(pidofproc -p "$pidfile" "$pathname")
|
||||
|
||||
if [ "$?" -eq 0 ]; then
|
||||
echo "$NAME running with PID: $pid" && return 0
|
||||
else
|
||||
echo "$NAME is not running" && return 1
|
||||
fi
|
||||
else
|
||||
echo "Cannot read pid file ($pidfile)"
|
||||
|
||||
pid=$(pidofproc "$pathname")
|
||||
|
||||
if [ "$?" -eq 0 ]; then
|
||||
echo "$NAME running with PID: $pid"
|
||||
else
|
||||
echo "$NAME is not running"
|
||||
fi
|
||||
|
||||
return 4
|
||||
fi
|
||||
else
|
||||
pid=$(pidofproc "$pathname")
|
||||
fi
|
||||
|
||||
if [ "$?" -ne 0 ]; then
|
||||
echo "$NAME is not runing" && return 1
|
||||
else
|
||||
echo "$NAME running with PID: $pid"
|
||||
if [ "$?" -eq 0 ]; then
|
||||
echo "$NAME running with PID: $pid" && return 0
|
||||
else
|
||||
echo "$NAME is not runing" && return 3
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user