aboutsummaryrefslogtreecommitdiffstats
path: root/bootscripts
diff options
context:
space:
mode:
authorBruce Dubbs <bdubbs@linuxfromscratch.org>2011-10-18 00:03:30 +0000
committerBruce Dubbs <bdubbs@linuxfromscratch.org>2011-10-18 00:03:30 +0000
commit776f1dc3a469a6b2cbd429efad4e40c5eb4466d4 (patch)
treed68d3d1bd3c21b7ea935a4c8b1f28af7433f7adc /bootscripts
parenta09cad523a370d42c3686bbf6f19f524f17f7b2e (diff)
Add statusproc back to bootscripts.
Remove doc/ files when stripping in Chapter 5. Add --noclear to agetty for tty1 in inittab. git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@9636 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689
Diffstat (limited to 'bootscripts')
-rw-r--r--bootscripts/lfs/init.d/sysklogd7
-rw-r--r--bootscripts/lfs/lib/services/init-functions56
2 files changed, 61 insertions, 2 deletions
diff --git a/bootscripts/lfs/init.d/sysklogd b/bootscripts/lfs/init.d/sysklogd
index 72e349744..eb76dfc13 100644
--- a/bootscripts/lfs/init.d/sysklogd
+++ b/bootscripts/lfs/init.d/sysklogd
@@ -63,8 +63,13 @@ case "${1}" in
${0} start
;;
+ status)
+ statusproc /sbin/syslogd
+ statusproc klogd
+ ;;
+
*)
- echo "Usage: ${0} {start|stop|reload|restart}"
+ echo "Usage: ${0} {start|stop|reload|restart|status}"
exit 1
;;
esac
diff --git a/bootscripts/lfs/lib/services/init-functions b/bootscripts/lfs/lib/services/init-functions
index 93931dca9..4ba623adc 100644
--- a/bootscripts/lfs/lib/services/init-functions
+++ b/bootscripts/lfs/lib/services/init-functions
@@ -417,7 +417,12 @@ pidofproc()
if [ -z "${pidfile}" ]; then
# Get the program's basename
prefix=`echo "${program}" | sed 's/[^/]*$//'`
- progname=`echo "${program}" | sed "s@${prefix}@@"`
+
+ if [ -z "${prefix}" ]; then
+ progname="${program}"
+ else
+ progname=`echo "${program}" | sed "s@${prefix}@@"`
+ fi
# If a PID file exists with that name, assume that is it.
if [ -e "/var/run/${progname}.pid" ]; then
@@ -457,6 +462,55 @@ pidofproc()
}
################################################################################
+# statusproc() #
+# Usage: statusproc [-p pidfile] pathname #
+# #
+# Purpose: This function prints the status of a particular daemon to stdout #
+# #
+# Inputs: -p pidfile, use the specified pidfile instead of pidof #
+# pathname, path to the specified program #
+# #
+# Return values: #
+# 0 - Status printed #
+# 1 - Input error. The daemon to check was not specified. #
+################################################################################
+statusproc()
+{
+ if [ "${#}" = "0" ]; then
+ echo "Usage: statusproc {program}"
+ exit 1
+ fi
+
+ if [ -z "${PIDFILE}" ]; then
+ pidlist=`pidofproc -p "${PIDFILE}" $@`
+ else
+ pidlist=`pidofproc $@`
+ fi
+
+ # Trim trailing blanks
+ pidlist=`echo "${pidlist}" | sed -r 's/ +$//'`
+
+ base="${1##*/}"
+
+ if [ -n "${pidlist}" ]; then
+ echo -e "${INFO}${base} is running with Process" \
+ "ID(s) ${pidlist}.${NORMAL}"
+ else
+ if [ -n "${base}" -a -e "/var/run/${base}.pid" ]; then
+ echo -e "${WARNING}${1} is not running but" \
+ "/var/run/${base}.pid exists.${NORMAL}"
+ else
+ if [ -n "${PIDFILE}" -a -e "${PIDFILE}" ]; then
+ echo -e "${WARNING}${1} is not running" \
+ "but ${PIDFILE} exists.${NORMAL}"
+ else
+ echo -e "${INFO}${1} is not running.${NORMAL}"
+ fi
+ fi
+ fi
+}
+
+################################################################################
# timespec() #
# #
# Purpose: An internal utility function to format a timestamp #