From 6d529f4e7081cd9990a10bc2044777e673cc1b37 Mon Sep 17 00:00:00 2001
From: Florian Pose <fp@igh-essen.com>
Date: Wed, 17 May 2006 11:16:32 +0000
Subject: [PATCH] Added status function to RC script.

---
 ethercat.sh | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/ethercat.sh b/ethercat.sh
index efe9d856..30e7585a 100755
--- a/ethercat.sh
+++ b/ethercat.sh
@@ -128,6 +128,26 @@ case "$1" in
 
 	rc_status
 	;;
+
+    status)
+	echo -n "Checking for EtherCAT... "
+
+	# Return value is slightly different for the status command:
+	# 0 - service up and running
+	# 1 - service dead, but /var/run/  pid  file exists
+	# 2 - service dead, but /var/lock/ lock file exists
+	# 3 - service not running (unused)
+	# 4 - service status unknown :-(
+	# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
+
+	lsmod | grep "^ec_master " > /dev/null
+	master_running=$?
+	lsmod | grep "^ec_8139too " > /dev/null
+	device_running=$?
+	test $master_running -eq 0 -a $device_running -eq 0
+
+	rc_status -v
+	;;
 esac
 rc_exit
 
-- 
GitLab