From f9f3c50195b7b06d2e42188ff759a27fb7dde98e Mon Sep 17 00:00:00 2001 From: Stefan Wold Date: Thu, 16 Jul 2015 19:47:34 +0200 Subject: [PATCH] systemd: [plugin] add support for upstream unit files Some modules install their own unit files during make install, instead of disabling that behavior we can track those unit files by extending our plugin and query the user for input to enable or disable the service. How? Create a $SCRIPT_DIRECTORY/systemd_units file with the format (one unit per line): daemon.service: A short description here daemon2.socket: A short description here --- system/systemd/plugin.d/systemd.plugin | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/system/systemd/plugin.d/systemd.plugin b/system/systemd/plugin.d/systemd.plugin index bda5f680e..a0026390d 100644 --- a/system/systemd/plugin.d/systemd.plugin +++ b/system/systemd/plugin.d/systemd.plugin @@ -13,16 +13,19 @@ plugin_systemd_configure() { - local SERVICES SERVICE_FLAGGED SERVICE SYSTEMD_SERVICES + local SERVICES SERVICE_FLAGGED SERVICE SYSTEMD_SERVICES DESC debug_msg "plugin_systemd_configure ($@)" SYSTEMD_SERVICES=$(get_module_config SYSTEMD_SERVICES) if [ -d $SCRIPT_DIRECTORY/systemd.d ]; then cd $SCRIPT_DIRECTORY/systemd.d - SERVICES=$(ls -1) + elif [ -f $SCRIPT_DIRECTORY/systemd_units ]; then + SERVICES=$(grep ':' $SCRIPT_DIRECTORY/systemd_units | awk -F': ' '{ print $1 }') + fi + if [ -n "$SERVICES" ]; then for SERVICE in $SERVICES; do # don't ask for '@' services - these should always be installed but # never linked directly. Also ask for new or renamed services. @@ -34,7 +37,12 @@ plugin_systemd_configure() fi continue fi - message "${MESSAGE_COLOR}$SERVICE: $(grep Description= $SERVICE | cut -d= -f2-)${DEFAULT_COLOR}" + if [ -f $SCRIPT_DIRECTORY/systemd.d/$SERVICE ]; then + DESC=$(grep Description= $SCRIPT_DIRECTORY/systemd.d/$SERVICE | cut -d= -f2-) + else + DESC=$(grep "^$SERVICE:" $SCRIPT_DIRECTORY/systemd_units | awk -F': ' '{ print $2 }') + fi + message "${MESSAGE_COLOR}$SERVICE: $DESC${DEFAULT_COLOR}" if query "Invoke $SERVICE via systemd automatically at boot ?" y then SYSTEMD_SERVICES+=" $SERVICE"