#! /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 <>/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<