diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..2bdf81d --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,60 @@ +# Petrified Changelog + +Project Home: https://github.com/troyengel/petrified + +## [2.0.1] - 2017-11-19 +- Add `CHANGELOG.md` to project +- Update README / man for new systemd things +- Rebuild systemd again to use timers.target (#4) + - Remove petrified.target design completely + - Instanced units can be created manually using systemd overrides +- Use templates to build systemd units ExexStart path (#4) + - Unit files to install are now templates built by Makefile + - Path is determined by `PREFIX=` semantics (packaging standard) +- Readjust copyright date, US Copyright Law is first year published + +## [2.0.0] - 2017-11-19 +- Implement FreeDNS APIv2 alongside APIv1 with dynamic API guess (#5) + - Default config is to guess which API based on key length + - Specific API version can be coded into config, see `DDNS_API` + - See comments in `petrified.conf` for details on new settings +- Add new `LOG_QUIET` option to not emit if IP hasn't changed (#4) +- Update shebang to be BSD portable (bin/bash -> bin/env bash) + +## [1.0.6] - 2016-01-24 +- Rebuild systemd design for timers and target (#3) +- Fix systemd `OnCalendar` implementation +- Add systemd `OnActiveSec` to timer on startup +- Deprecate Arch build - AUR started using git +- Update / enhance docs and man page + +## [1.0.5] - 2015-03-08 +- Fix bad perlpod char +- Add cleanup routine to bad IP exit clause +- Update / enhance Makefile + +## [1.0.4] - 2014-12-01 +- Fix bad month macro in logfile entries (@IanMReed) + +## [1.0.3] - 2014-01-24 +- Add Makefile to project +- Convert `README.md` to `README.pod` for multi-use +- Add petrified.1 man page built from README.pod +- Update / enhance Arch `PKGBUILD` things +- Change logrotate to not install systemwide + +## [1.0.2] - 2014-11-22 +- Documentation updates and enhancements +- First addition of systemd timers (#1) +- Reorganize file layout (move things to subdirs) +- Add better examples for (f)cron, logrotate, etc. +- Add security / permissions check of config file + - Contains API key, should be kept protected + +## [1.0.1] - 2014-09-07 +- First release of working version +- First tagged release for packagers + +## [1.0.0] - unreleased / untagged +- First commits to build project + diff --git a/Makefile b/Makefile index bbbf5c7..b33b4fa 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.pod b/README.pod index cbef50e..d29ca75 100644 --- a/README.pod +++ b/README.pod @@ -63,35 +63,31 @@ configuration. user: systemctl --user --now enable petrified.timer systemctl --user list-timers petrified.timer -A target of C is pre-configured if multuple interfaces are -to be configured; per standard systemd methodology the existing service unit -is first customized either at the system or user level, then all custom units -and the timer are started/enabled. - -For example at the system level if two interfaces are to be used, it might -look like: +Multiple interfaces can be configured using the standard systemd semantics +of unit overrides, which might look like this: /etc/systemd/system/petrified-iface1.service -------------------------------------------- .include /usr/lib/systemd/system/petrified.service [Service] + ExecStart= ExecStart=/usr/bin/petrified -c /etc/petrified-iface1.conf - /etc/systemd/system/petrified-iface2.service +The first C is intentional, needed to negate the existing value +first before defining a new value (systemd design for ExecStart override). + +A corresponding new timer is then created to call this unit as it may be +desireable to run different interfaces on different time schedules, which +might then look like this: + + /etc/systemd/system/petrified-iface1.timer -------------------------------------------- - .include /usr/lib/systemd/system/petrified.service - [Service] - ExecStart=/usr/bin/petrified -c /etc/petrified-iface2.conf + .include /usr/lib/systemd/system/petrified.timer + [Timer] + Unit=petrified-iface1.service + OnCalendar=0/8:00:00 -Then both customized service units are enabled, as well as the timer unit: - - systemctl --now enable petrified-iface1.service - systemctl --now enable petrified-iface2.service - systemctl --now enable petrified.timer - -The per user configuration looks the same and is usually configured in the -F<~/.config/systemd/user/> space in the home directory. The provided units -for the service contain the connection to the target pre-configured. +This timer will now operate the new custom unit when it's enabled. =over 4 @@ -101,8 +97,6 @@ L L -L - =back =head1 DEPENDENCIES @@ -143,7 +137,7 @@ LOG file (if feature enabled - default: no) =head1 AUTHOR -Copyright (c) 2015 Troy Engel +Copyright (c) 2014 Troy Engel GPLv3 - see LICENSE for details diff --git a/petrified b/petrified index 77fccf2..35de715 100755 --- a/petrified +++ b/petrified @@ -1,8 +1,8 @@ #!/usr/bin/env bash # ## petrified - bash client to update dynamic DNS at freedns.afraid.org -## Copyright (c) 2015 Troy Engel -## Version: 2.0.0 +## Copyright (c) 2014 Troy Engel +## Version: 2.0.1 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/petrified.1 b/petrified.1 index 2aaff62..fd684a0 100644 --- a/petrified.1 +++ b/petrified.1 @@ -129,7 +129,7 @@ .\" ======================================================================== .\" .IX Title "PETRIFIED 1" -.TH PETRIFIED 1 "2017-09-29" "petrified 2.0.0" "Petrified Manual" +.TH PETRIFIED 1 "2017-11-19" "petrified 2.0.1" "Petrified Manual" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l @@ -191,46 +191,40 @@ configuration. \& systemctl \-\-user list\-timers petrified.timer .Ve .PP -A target of \f(CW\*(C`petrified.target\*(C'\fR is pre-configured if multuple interfaces are -to be configured; per standard systemd methodology the existing service unit -is first customized either at the system or user level, then all custom units -and the timer are started/enabled. +Multiple interfaces can be configured using the standard systemd semantics +of unit overrides, which might look like this: .PP -For example at the system level if two interfaces are to be used, it might -look like: -.PP -.Vb 5 +.Vb 6 \& /etc/systemd/system/petrified\-iface1.service \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- \& .include /usr/lib/systemd/system/petrified.service \& [Service] +\& ExecStart= \& ExecStart=/usr/bin/petrified \-c /etc/petrified\-iface1.conf -\& -\& /etc/systemd/system/petrified\-iface2.service +.Ve +.PP +The first \f(CW\*(C`ExecStart=\*(C'\fR is intentional, needed to negate the existing value +first before defining a new value (systemd design for ExecStart override). +.PP +A corresponding new timer is then created to call this unit as it may be +desireable to run different interfaces on different time schedules, which +might then look like this: +.PP +.Vb 6 +\& /etc/systemd/system/petrified\-iface1.timer \& \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- -\& .include /usr/lib/systemd/system/petrified.service -\& [Service] -\& ExecStart=/usr/bin/petrified \-c /etc/petrified\-iface2.conf +\& .include /usr/lib/systemd/system/petrified.timer +\& [Timer] +\& Unit=petrified\-iface1.service +\& OnCalendar=0/8:00:00 .Ve .PP -Then both customized service units are enabled, as well as the timer unit: -.PP -.Vb 3 -\& systemctl \-\-now enable petrified\-iface1.service -\& systemctl \-\-now enable petrified\-iface2.service -\& systemctl \-\-now enable petrified.timer -.Ve -.PP -The per user configuration looks the same and is usually configured in the -\&\fI~/.config/systemd/user/\fR space in the home directory. The provided units -for the service contain the connection to the target pre-configured. +This timer will now operate the new custom unit when it's enabled. .IP "\fBSee also:\fR" 4 .IX Item "See also:" .Sp -.Sp - .SH "DEPENDENCIES" .IX Header "DEPENDENCIES" .Vb 7 @@ -261,7 +255,7 @@ Per-user configuration file \&\s-1LOG\s0 file (if feature enabled \- default: no) .SH "AUTHOR" .IX Header "AUTHOR" -Copyright (c) 2015 Troy Engel +Copyright (c) 2014 Troy Engel .PP GPLv3 \- see \s-1LICENSE\s0 for details .SH "SUPPORT" diff --git a/systemd/system/petrified.service b/systemd/petrified-system.service.in similarity index 52% rename from systemd/system/petrified.service rename to systemd/petrified-system.service.in index 6922ed6..8062241 100644 --- a/systemd/system/petrified.service +++ b/systemd/petrified-system.service.in @@ -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 diff --git a/systemd/user/petrified.service b/systemd/petrified-user.service.in similarity index 52% rename from systemd/user/petrified.service rename to systemd/petrified-user.service.in index b586596..70ffe0a 100644 --- a/systemd/user/petrified.service +++ b/systemd/petrified-user.service.in @@ -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" diff --git a/systemd/system/petrified.timer b/systemd/petrified.timer similarity index 91% rename from systemd/system/petrified.timer rename to systemd/petrified.timer index d48f4ca..c8ad392 100644 --- a/systemd/system/petrified.timer +++ b/systemd/petrified.timer @@ -15,5 +15,4 @@ OnCalendar=0/6:00:00 Persistent=true [Install] -WantedBy=multi-user.target - +WantedBy=timers.target diff --git a/systemd/system/petrified.target b/systemd/system/petrified.target deleted file mode 100644 index 49f5c61..0000000 --- a/systemd/system/petrified.target +++ /dev/null @@ -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 - diff --git a/systemd/user/petrified.target b/systemd/user/petrified.target deleted file mode 100644 index 184f036..0000000 --- a/systemd/user/petrified.target +++ /dev/null @@ -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 - diff --git a/systemd/user/petrified.timer b/systemd/user/petrified.timer deleted file mode 100644 index d1c5d95..0000000 --- a/systemd/user/petrified.timer +++ /dev/null @@ -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 -