[Lunar-commits] r27023 - lunar-tools/trunk/lservices

Stefan Wold ratler at lunar-linux.org
Wed Sep 10 20:21:30 CEST 2008


Author: ratler
Date: 2008-09-10 20:21:30 +0200 (Wed, 10 Sep 2008)
New Revision: 27023

Modified:
   lunar-tools/trunk/lservices/lservices
Log:
lservices will now properly detect removed init.d scripts again. Removed some unused cruft.

Modified: lunar-tools/trunk/lservices/lservices
===================================================================
--- lunar-tools/trunk/lservices/lservices	2008-08-18 17:08:55 UTC (rev 27022)
+++ lunar-tools/trunk/lservices/lservices	2008-09-10 18:21:30 UTC (rev 27023)
@@ -11,10 +11,6 @@
 
 
 service_is_started() {
-  P=$(find $MOONBASE/*/*/init.d/ -type f -name $1 )
-  SECTION=$(echo $P | sed "s:$MOONBASE::g" | cut -d/ -f2)
-  MODULE=$(echo $P | sed "s:$MOONBASE::g" | cut -d/ -f3)
-
   PIDF=$(grep '^# pidfile: ' /etc/init.d/$1 | cut -d: -f2 | sed 's/ //g' )
   if [ -z "$PIDF" ] ; then
     if grep -q '^# processname: ' /etc/init.d/$1 ; then
@@ -40,10 +36,6 @@
   #  add       add the service to the startup sequence (currently removed)
 
   while true ; do
-    P=$(find $MOONBASE/*/*/init.d/ -type f -name $1 )
-    SECTION=$(echo $P | sed "s:$MOONBASE::g" | cut -d/ -f2)
-    MODULE=$(echo $P | sed "s:$MOONBASE::g" | cut -d/ -f3)
-
     PIDF=$(grep '^# pidfile: ' /etc/init.d/$1 | cut -d: -f2 | sed 's/ //g' )
     if [ -z "$PIDF" ] ; then
       if grep -q '^# processname: ' /etc/init.d/$1 ; then
@@ -77,7 +69,7 @@
     if [ $? != 0 ] ; then
       return
     fi
-  
+
     case $action in
       start  )
         /etc/init.d/$1 start
@@ -103,24 +95,22 @@
 list_initd_services() {
  (
   unset IFS
-  for SERVICE in $(find /etc/init.d/ -type f -exec basename {} \; | sort) ; do
-    if grep -q '^# chkconfig: ' /etc/init.d/$SERVICE ; then
-      DESCRIPTION="$(grep '^# description: ' /etc/init.d/$SERVICE | sed -e 's/^# description: //g' -e 's/\\/.../' -e 's/\t/ /g')"
-      if service_is_enabled $SERVICE ; then
-        FLAG="+"
-      else
-        FLAG="-"
-      fi
-      if service_is_started $SERVICE ; then
-        FLAG="${FLAG}1"
-      else
-        FLAG="${FLAG}0"
-      fi
-      echo "$SERVICE"
-      echo "$FLAG $DESCRIPTION"
+  for SERVICE in $(grep '^# chkconfig: [^-]' /etc/init.d/* | cut -d: -f1) ; do
+    DESCRIPTION="$(grep '^# description: ' $SERVICE | sed -e 's/^# description: //g' -e 's/\\/.../' -e 's/\t/ /g')"
+    if service_is_enabled ${SERVICE##*/} ; then
+      FLAG="+"
+    else
+      FLAG="-"
     fi
+    if service_is_started ${SERVICE##*/} ; then
+      FLAG="${FLAG}1"
+    else
+      FLAG="${FLAG}0"
+    fi
+    echo "${SERVICE##*/}"
+    echo "$FLAG $DESCRIPTION"
   done
- )
+  )
 }
 
 



More information about the Lunar-commits mailing list