#! /bin/bash set -e set -x _clear_service () { systemctl stop $1.service 2>/dev/null || : rm -f /{etc,run,usr/lib}/systemd/system/$1.service rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.d rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.{wants,requires} } clear_services () { for u in $*; do _clear_service $u done systemctl daemon-reload } create_service () { clear_services $1 cat >/etc/systemd/system/$1.service</usr/lib/systemd/system/service.d/override.conf < /usr/lib/systemd/system/$dropin/override.conf check_ok a-b-c ExecCondition "/bin/echo $dropin" done for dropin in service.d a-.service.d a-b-.service.d a-b-c.service.d; do rm -rf /usr/lib/systemd/system/$dropin done clear_services a-b-c } test_template_dropins () { echo "Testing template dropins..." create_services foo bar@ yup@ # Declare some deps to check if the body was loaded cat >>/etc/systemd/system/bar@.service <>/etc/systemd/system/yup@.service </usr/lib/systemd/system/a.service.d/override.conf </usr/lib/systemd/system/a.service.d/wants-b.conf<