[Lunar-commits] <moonbase> systemd: Make SysV support optional (you should not want it) and add plugin for services handling.

Auke Kok sofar at foo-projects.org
Sun Apr 24 23:10:07 CEST 2011


commit 29027e231303e141396b71d2d7d5b8a6aab3b787
Author: Auke Kok <sofar at foo-projects.org>
Date:   Sun Apr 24 23:10:07 2011 +0200

    systemd: Make SysV support optional (you should not want it) and add plugin for services handling.
---
 zbeta/systemd/BUILD                   |    4 +-
 zbeta/systemd/CONFIGURE               |    2 +
 zbeta/systemd/plugin.d/systemd.plugin |   78 +++++++++++++++++++++++++++++++++
 3 files changed, 81 insertions(+), 3 deletions(-)

diff --git a/zbeta/systemd/BUILD b/zbeta/systemd/BUILD
index 65bf5f4..a56c03c 100644
--- a/zbeta/systemd/BUILD
+++ b/zbeta/systemd/BUILD
@@ -2,9 +2,7 @@
 
   sedit "s:/usr/local:/usr:"  configure  &&
 
-  OPTS+=" --with-distro=other \
-          --with-sysvinit-path=/etc/init.d \
-          --with-sysvrcd-path=/etc"         &&
+  OPTS+=" --with-distro=other" &&
 
   default_build
 
diff --git a/zbeta/systemd/CONFIGURE b/zbeta/systemd/CONFIGURE
new file mode 100644
index 0000000..70d361f
--- /dev/null
+++ b/zbeta/systemd/CONFIGURE
@@ -0,0 +1,2 @@
+
+mquery SYSV_COMPAT "Enable SysV compatibility?" y "--with-sysvinit-path=/etc/init.d --with-sysvrcd-path=/etc" ""
diff --git a/zbeta/systemd/plugin.d/systemd.plugin b/zbeta/systemd/plugin.d/systemd.plugin
new file mode 100644
index 0000000..dc06546
--- /dev/null
+++ b/zbeta/systemd/plugin.d/systemd.plugin
@@ -0,0 +1,78 @@
+#!/bin/bash
+#############################################################
+#                                                           #
+# systemd.plugin - handling of systemd service files        #
+#                                                           #
+#############################################################
+#                                                           #
+# Copyright 2011 by Auke Kok under GPLv2                    #
+#                                                           #
+#############################################################
+
+
+plugin_systemd_configure()
+{
+  local SERVICES SERVICE SYSTEMD_SERVICES
+  debug_msg "plugin_systemd_configure ($@)"
+  if ! grep -q SYSTEMD_SERVICES $DEPENDS_CONFIG/$MODULE && 
+      [ -d $SCRIPT_DIRECTORY/systemd.d ]; then
+    cd $SCRIPT_DIRECTORY/systemd.d
+
+    SERVICES=$(ls -1)
+
+    SYSTEMD_SERVICES=
+    for SERVICE in $SERVICES; do
+      if query "Invoke $SERVICE via systemd automatically at boot ?"  y
+      then
+        SYSTEMD_SERVICES+=" $SERVICE"
+      else
+        systemctl disable $SERVICE
+	systemctl stop $SERVICE
+      fi
+    done
+    cd $SCRIPT_DIRECTORY
+
+    set_module_config "SYSTEMD_SERVICES" "$SYSTEMD_SERVICES"
+  fi
+  return 2
+}
+
+
+plugin_systemd_post_build()
+{
+  local SERVICES SERVICE
+  debug_msg "plugin_systemd_post_build ($@)"
+
+  if [ -d $SCRIPT_DIRECTORY/systemd.d ]; then
+    invoke_installwatch
+    verbose_msg "handling systemd.d services" | tee -a $C_LOG
+    cd $SCRIPT_DIRECTORY/systemd.d
+    SERVICES=$(ls -1)
+
+    for SERVICE in $SERVICES; do
+      /usr/bin/install -g 0 -o 0 -m 0755 $SERVICE /lib/systemd/system/$SERVICE
+    done
+    cd $SCRIPT_DIRECTORY
+    devoke_installwatch
+  fi
+
+  systemctl daemon-reload
+
+  for SERVICE in $SYSTEMD_SERVICES; do
+    systemctl disable $SERVICE
+    invoke_installwatch
+    systemctl enable $SERVICE
+    devoke_installwatch
+
+    # start-or-restart it
+    if [ "${LUNAR_RESTART_SERVICES:=on}" == "on" ]; then
+      systemctl restart $SERVICE
+    fi
+
+  done
+  return 2
+}
+
+
+plugin_register BUILD_CONFIGURE plugin_systemd_configure
+plugin_register BUILD_POST_BUILD plugin_systemd_post_build


More information about the Lunar-commits mailing list