Skip to content

Commit

Permalink
systemd: [plugin] add support for upstream unit files
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ratler committed Jul 16, 2015
1 parent 0a3c099 commit f9f3c50
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions system/systemd/plugin.d/systemd.plugin
Expand Up @@ -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.
Expand All @@ -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"
Expand Down

0 comments on commit f9f3c50

Please sign in to comment.