[Lunar-commits] <lunar-tools> lservices: Sort services by name

Stefan Wold ratler at lunar-linux.org
Sat Aug 4 16:34:09 CEST 2012


commit b9d5947b7f0835b97a6944733f419b92d1183a79
Author: Stefan Wold <ratler at lunar-linux.org>
Date: Sat, 04 Aug 2012 07:34:09 -0700
URL: https://github.com/lunar-linux/lunar-tools/commit/b9d5947b7f0835b97a6944733f419b92d1183a79

lservices: Sort services by name
---
  lservices/lservices                                          +6/-6     
  1 files changed, 6 insertions (+), 6 deletions (-)

--- a/lservices/lservices
+++ b/lservices/lservices
@@ -169,21 +169,21 @@ service_menu_systemd() {(
 )}
 
 list_systemd_services() {(
-  for SERVICE in $(find $MOONBASE -name "*.service" -o -name "*.socket" ! -regex "$MOONBASE/zlocal/.*" ); do
+  for SERVICE in $(find $MOONBASE -name "*.service" -o -name "*.socket" ! -regex "$MOONBASE/zlocal/.*" | sed 's;.*/;;' | sort); do
     echo $SERVICE | grep -q @ && continue
-    [ -f "$SYSTEMDUNITDIR/${SERVICE##*/}" ] || continue
-    DESCRIPTION=$(grep 'Description=' $SERVICE | cut -d= -f2-)
-    if systemctl -q is-enabled ${SERVICE##*/}; then
+    [ -f "$SYSTEMDUNITDIR/$SERVICE" ] || continue
+    DESCRIPTION=$(grep 'Description=' $SYSTEMDUNITDIR/$SERVICE | cut -d= -f2-)
+    if systemctl -q is-enabled $SERVICE; then
       FLAG="+"
     else
       FLAG="-"
     fi
-    if systemctl -q is-active ${SERVICE##*/}; then
+    if systemctl -q is-active $SERVICE; then
       FLAG+="1"
     else
       FLAG+="0"
     fi
-    echo "${SERVICE##*/}"
+    echo "$SERVICE"
     echo "$FLAG $DESCRIPTION"
   done
 )}




More information about the Lunar-commits mailing list