rebuild systemd to use timers.target and BINDIR templates

This commit is contained in:
tengel 2024-03-20 09:32:36 -05:00
parent 12caa51fb5
commit 8843922cee
7 changed files with 33 additions and 82 deletions

View file

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

View file

@ -15,18 +15,9 @@
[Unit]
Description=Run petrified in system mode
After=network-online.target
Requisite=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/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
ExecStart=@BINDIR@/petrified -c /etc/petrified.conf

View file

@ -15,18 +15,9 @@
[Unit]
Description=Run petrified as %u
After=network-online.target
Requisite=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/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
ExecStart=@BINDIR@/petrified -c "%h/.petrifiedrc"

View file

@ -15,5 +15,4 @@ OnCalendar=0/6:00:00
Persistent=true
[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