Skip to content

Update systemd services to use ConditionHost= #117

Merged
merged 7 commits into from
Feb 25, 2020

Conversation

pmenzel
Copy link
Contributor

@pmenzel pmenzel commented Feb 11, 2020

Tested by rebooting hypnotoad.

After deployment, the systemctl daemon-reload should be issued, and {/usr}/sbin/startup-hostname be removed on the distmaster.

This will be removed later on, so the script below is not added here.

    $ ls -l --full-time /sbin/startup-hostname
    lrwxrwxrwx 1 root root 26 2014-03-17 11:22:30.000000000 +0100 /sbin/startup-hostname -> /usr/sbin/startup-hostname
    $ ls -l --full-time /usr/sbin/startup-hostname
    -rwxr-xr-x 1 root root 547 2014-05-28 16:04:49.000000000 +0200 /usr/sbin/startup-hostname
    $ more /usr/sbin/startup-hostname
    #! /bin/sh

    # This is a workaround for our systemd version not having ConditionHost=
    # This little helper is called by startup-hostname.service and creates
    #   /node/startup-hostname/HOSTNAME
    # So other services can use
    #   Wants=startup-hostname.service
    #   After=startup-hostname.service
    #   ConditionPathExists=/node/startup-hostname/HOSTNAME
    # to start a unit only on a specific host
    #

    hostname=`uname -n`;hostname=${hostname%%.*}
    mkdir -p /node/startup-hostname
    rm /node/startup-hostname/* 2>/dev/null
    touch /node/startup-hostname/$hostname
Make sure, the file has been actually created.
@pmenzel pmenzel force-pushed the update-systemd-services-to-use-conditionhost branch from 2ea5bbc to a340271 Compare February 11, 2020 15:43
@donald
Copy link
Collaborator

donald commented Feb 13, 2020

Very good. Let me do some testing the next days.

`ConditionHost=` was added in systemd 189, so let’s use it, now that we
are not running systemd 27 anymore.

    $ more /usr/sbin/startup-hostname
    […]
    # This is a workaround for our systemd version not having ConditionHost=
    # This little helper is called by startup-hostname.service and creates
    #   /node/startup-hostname/HOSTNAME
    # So other services can use
    #   Wants=startup-hostname.service
    #   After=startup-hostname.service
    #   ConditionPathExists=/node/startup-hostname/HOSTNAME
    # to start a unit only on a specific host
    #
    […]
@pmenzel pmenzel force-pushed the update-systemd-services-to-use-conditionhost branch from a340271 to e497beb Compare February 25, 2020 13:01
@donald
Copy link
Collaborator

donald commented Feb 25, 2020

Tested on a wtf clone.

@donald donald merged commit c59f488 into master Feb 25, 2020
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants