Subject: [alpine-devel] [PATCH] testing/sems/sems.initd: allow multiple sems instances

From: Nathan Angelacos <[email-masked]>
Date: Fri, 8 Apr 2011 05:28:50 +0000

---
 testing/sems/sems.initd |   26 ++++++++++++++++++--------
 1 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/testing/sems/sems.initd b/testing/sems/sems.initd
index 9cf98a1..0e96f8a 100644
--- a/testing/sems/sems.initd
+++ b/testing/sems/sems.initd
@@ -1,8 +1,17 @@
 #!/sbin/runscript
+# SIP Express Media Server configuration file
+# Follows Gentoo/AlpineLinux standards 
+# GPL 2 License - N. Angelacos 2011
 
+CONFDIR="/etc/sems"
+SVC="${SVCNAME#*.}"
+if [ -n "${SVC}" ] && [ "${SVCNAME}" != "sems" ]; then
+        SEMSPID="/var/run/sems/${SVC}.pid"
+	else
+        SEMSPID="/var/run/sems/sems.pid"
+	fi
+SEMSCONF="${CONFDIR}/${SVC}.conf"
 daemon=/usr/sbin/sems
-pidfile=/var/run/sems/sems.pid
-conffile=/etc/sems/sems.conf
 
 depend() {
 	need net
@@ -10,18 +19,19 @@ depend() {
 }
 
 start() {
-	ebegin "Starting sems"
-	start-stop-daemon --start --quiet --pidfile $pidfile --exec $daemon \
+	ebegin "Starting  ${SVCNAME}"
+	echo $SEMSPID   $SEMSCONF
+	start-stop-daemon --start --quiet --pidfile $SEMSPID --exec $daemon \
 		-- \
 		-u sems \
 		-g sems \
-		-P $pidfile \
-		-f $conffile
+		-P $SEMSPID \
+		-f $SEMSCONF
 	eend $?
 }
 
 stop() {
-	ebegin "Stopping sems"
-	start-stop-daemon --stop --quiet --pidfile $pidfile
+	ebegin "Stopping  ${SVCNAME}"
+	start-stop-daemon --stop --quiet --pidfile $SEMSPID
 	eend $?
 }
-- 
1.7.4.2

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---