rebuild systemd to use timers.target and BINDIR templates

This commit is contained in:
tengel 2017-11-19 10:09:19 -06:00
parent 0c4aed99a2
commit 1e4bd9a0ce
7 changed files with 33 additions and 82 deletions

View file

@ -14,7 +14,7 @@ DESTDIR ?=
MANPAGES = \ MANPAGES = \
petrified.1 petrified.1
all: doc all: doc build-systemd
doc: $(MANPAGES) doc: $(MANPAGES)
petrified.1: README.pod petrified.1: README.pod
@ -36,26 +36,37 @@ install-doc:
install -Dm0644 extra/petrified.crontab extra/petrified.dispatch \ install -Dm0644 extra/petrified.crontab extra/petrified.dispatch \
extra/petrified.logrotate "$(DESTDIR)$(DOCPREFIX)/petrified/extra" extra/petrified.logrotate "$(DESTDIR)$(DOCPREFIX)/petrified/extra"
install-systemd: build-systemd:
sed -e 's|@BINDIR@|$(BINPREFIX)|' systemd/petrified-system.service.in > \
systemd/petrified-system.service
sed -e 's|@BINDIR@|$(BINPREFIX)|' systemd/petrified-user.service.in > \
systemd/petrified-user.service
clean-systemd:
rm systemd/petrified-system.service systemd/petrified-user.service
install-systemd: build-systemd
# system unit
install -dm0755 "$(DESTDIR)$(LIBPREFIX)/systemd/system" install -dm0755 "$(DESTDIR)$(LIBPREFIX)/systemd/system"
install -Dm0644 systemd/system/petrified.target \ install -Dm0644 systemd/petrified-system.service \
systemd/system/petrified.timer \ "$(DESTDIR)$(LIBPREFIX)/systemd/system/petrified.service"
systemd/system/petrified.service \ install -Dm0644 systemd/petrified.timer \
"$(DESTDIR)$(LIBPREFIX)/systemd/system" "$(DESTDIR)$(LIBPREFIX)/systemd/system/petrified.timer"
# user unit
install -dm0755 "$(DESTDIR)$(LIBPREFIX)/systemd/user" install -dm0755 "$(DESTDIR)$(LIBPREFIX)/systemd/user"
install -Dm0644 systemd/user/petrified.target \ install -Dm0644 systemd/petrified-user.service \
systemd/user/petrified.timer \ "$(DESTDIR)$(LIBPREFIX)/systemd/user/petrified.service"
systemd/user/petrified.service \ install -Dm0644 systemd/petrified.timer \
"$(DESTDIR)$(LIBPREFIX)/systemd/user" "$(DESTDIR)$(LIBPREFIX)/systemd/user/petrified.timer"
uninstall-main: uninstall-main:
$(RM) "$(DESTDIR)$(BINPREFIX)/petrified" \ rm "$(DESTDIR)$(BINPREFIX)/petrified" \
"$(DESTDIR)$(MANPREFIX)/man1/petrified.1" \ "$(DESTDIR)$(MANPREFIX)/man1/petrified.1" \
"$(DESTDIR)$(ETCPREFIX)/petrified.conf" "$(DESTDIR)$(ETCPREFIX)/petrified.conf"
rmdir "$(DESTDIR)$(VARPREFIX)/cache/petrified" rmdir "$(DESTDIR)$(VARPREFIX)/cache/petrified"
uninstall-doc: uninstall-doc:
$(RM) "$(DESTDIR)$(DOCPREFIX)/petrified/README.pod" \ rm "$(DESTDIR)$(DOCPREFIX)/petrified/README.pod" \
"$(DESTDIR)$(DOCPREFIX)/petrified/LICENSE" \ "$(DESTDIR)$(DOCPREFIX)/petrified/LICENSE" \
"$(DESTDIR)$(DOCPREFIX)/petrified/extra/petrified.crontab" \ "$(DESTDIR)$(DOCPREFIX)/petrified/extra/petrified.crontab" \
"$(DESTDIR)$(DOCPREFIX)/petrified/extra/petrified.dispatch" \ "$(DESTDIR)$(DOCPREFIX)/petrified/extra/petrified.dispatch" \
@ -64,14 +75,12 @@ uninstall-doc:
"$(DESTDIR)$(DOCPREFIX)/petrified" \ "$(DESTDIR)$(DOCPREFIX)/petrified" \
uninstall-systemd: uninstall-systemd:
$(RM) "$(DESTDIR)$(LIBPREFIX)/systemd/system/petrified.target" \ rm "$(DESTDIR)$(LIBPREFIX)/systemd/system/petrified.timer" \
"$(DESTDIR)$(LIBPREFIX)/systemd/system/petrified.timer" \ "$(DESTDIR)$(LIBPREFIX)/systemd/system/petrified.service"
"$(DESTDIR)$(LIBPREFIX)/systemd/system/petrified@.service" rm "$(DESTDIR)$(LIBPREFIX)/systemd/user/petrified.timer" \
$(RM) "$(DESTDIR)$(LIBPREFIX)/systemd/user/petrified.target" \ "$(DESTDIR)$(LIBPREFIX)/systemd/user/petrified.service"
"$(DESTDIR)$(LIBPREFIX)/systemd/user/petrified.timer" \
"$(DESTDIR)$(LIBPREFIX)/systemd/user/petrified@.service"
clean: clean: clean-systemd
$(RM) $(MANPAGES) $(RM) $(MANPAGES)
.PHONY: clean doc install uninstall .PHONY: clean doc install uninstall

View file

@ -15,18 +15,9 @@
[Unit] [Unit]
Description=Run petrified in system mode Description=Run petrified in system mode
After=network-online.target After=network-online.target
Requisite=network-online.target
[Service] [Service]
Type=simple Type=simple
ExecStart=/usr/bin/petrified -c /etc/petrified.conf ExecStart=@BINDIR@/petrified -c /etc/petrified.conf
# A target is being provided in the case where the advanced
# admin wants to override this unit with multiple config files
# for multiple interfaces. In this use case, *both* the custom
# service units and the timer are enabled with systemctl (as each
# custom unit will not be called "petrified.service", instead
# something like "petrified-wlp3s0.service")
[Install]
WantedBy=petrified.target

View file

@ -15,18 +15,9 @@
[Unit] [Unit]
Description=Run petrified as %u Description=Run petrified as %u
After=network-online.target After=network-online.target
Requisite=network-online.target
[Service] [Service]
Type=simple Type=simple
ExecStart=/usr/bin/petrified -c "%h/.petrifiedrc" ExecStart=@BINDIR@/petrified -c "%h/.petrifiedrc"
# A target is being provided in the case where the advanced
# admin wants to override this unit with multiple config files
# for multiple interfaces. In this use case, *both* the custom
# service units and the timer are enabled with systemctl (as each
# custom unit will not be called "petrified.service", instead
# something like "petrified-wlp3s0.service")
[Install]
WantedBy=petrified.target

View file

@ -15,5 +15,4 @@ OnCalendar=0/6:00:00
Persistent=true Persistent=true
[Install] [Install]
WantedBy=multi-user.target WantedBy=timers.target

View file

@ -1,10 +0,0 @@
#
# /usr/lib/systemd/system/petrified.target
#
# Note: If using a target to run mutliple service units, remember
# to enable both the multiple unit files and the single timer.
#
[Unit]
Description=Petrified units via timers

View file

@ -1,10 +0,0 @@
#
# /usr/lib/systemd/user/petrified.target
#
# Note: If using a target to run mutliple service units, remember
# to enable both the multiple unit files and the single timer.
#
[Unit]
Description=Petrified units via timers as %u

View file

@ -1,19 +0,0 @@
#
# /usr/lib/systemd/user/petrified.timer
#
# Note: Only one timer is needed if running multiple service
# units for multiple interfaces. No need to duplicate.
#
[Unit]
Description=Petrified update every 6 hours as %u
[Timer]
Unit=petrified.service
OnActiveSec=0s
OnCalendar=0/6:00:00
Persistent=true
[Install]
WantedBy=multi-user.target