Bug 5086 - --lockfile switch is needed for 'status' routine in /etc/init.d/functions
Summary: --lockfile switch is needed for 'status' routine in /etc/init.d/functions
Status: CLOSED FIXED
Alias: None
Product: Sisyphus
Classification: Development
Component: service (show other bugs)
Version: unstable
Hardware: all Linux
: P2 minor
Assignee: placeholder@altlinux.org
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-28 02:52 MSD by evseev
Modified: 2009-05-10 09:32 MSD (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description evseev 2004-08-28 02:52:36 MSD
This patch allows to pass '--lockfile <file>' to status routine.
This is needed when lockfile has custom name.
By default name of lockfile is calculated as previously.
--- /etc/rc.d/init.d/functions.orig	2004-06-27 18:56:13 +0400
+++ /etc/rc.d/init.d/functions	2004-08-28 02:36:12 +0400
@@ -382,11 +382,12 @@
 		return 1
 	fi
 
-	local WHICH BASENAME CMDNAME PIDFILE EXPECT FLAGS
+	local WHICH BASENAME CMDNAME PIDFILE LOCKFILE EXPECT FLAGS
 
 # Process options.
 	CMDNAME=
 	PIDFILE=
+	LOCKFILE=
 	EXPECT=
 	while [ "$1" != "${1##-}" ]; do
 		case "$1" in
@@ -404,6 +405,10 @@
 			PIDFILE="$1"
 			shift
 			;;
+		--lockfile)
+			shift
+			LOCKFILE="$1"
+			shift
 		--expect-user)
 			shift
 			EXPECT="$1"
@@ -432,6 +437,10 @@
 		PIDFILE=
 	fi
 
+	if [ -z "$LOCKFILE" ]; then
+		LOCKFILE="/var/lock/subsys/$BASENAME"
+	fi
+
 	if [ -n "$CMDNAME" -a -z "$PIDFILE" ]; then
 		echo "status: --name is set but --pidfile is not set" >&2
 		return 1
@@ -457,7 +466,7 @@
 		return 1
 	fi
 
-	if [ -f "/var/lock/subsys/$BASENAME" ]; then
+	if [ -f "$LOCKFILE" ]; then
 		echo "$BASENAME is dead, but subsystem is locked"
 		return 2
 	fi



Steps to Reproduce:
1. service snortd start
2. killall -9 snort
3. service snortd status
Actual Results:  
snort is stopped

Expected Results:  
snort is dead, but subsystem is locked
Comment 1 Dmitry V. Levin 2004-09-01 19:30:51 MSD
No, subsystem lockfile names must match startup script names, otherwise system
shutdown procedure will not work properly, see /etc/rc.d/rc for details.
Comment 2 Dmitry V. Levin 2004-09-02 22:54:19 MSD
Well, start_daemon and stop_daemon have --lockfile option.
Comment 3 Dmitry V. Levin 2004-09-04 19:18:22 MSD
Implemented in service-0.5.6-alt1