aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2024-08-09 11:40:17 +0200
committerPatrick Spek <p.spek@tyil.nl>2024-08-09 11:40:17 +0200
commit14875f61c46f73616468c05778d9f4e163d8cd09 (patch)
tree06bc03bf8a31251401f069c49468bf2aca1dbf1c
parentef315f6777620d44a16bc48b3e602ba1725cf095 (diff)
downloadbashtard-14875f61c46f73616468c05778d9f4e163d8cd09.tar.gz
bashtard-14875f61c46f73616468c05778d9f4e163d8cd09.tar.bz2
Add systemd service
-rw-r--r--CHANGELOG.md6
-rw-r--r--Makefile9
-rw-r--r--README.md6
-rw-r--r--share/svc/systemd/bashtard.service10
-rw-r--r--share/svc/systemd/bashtard.timer10
5 files changed, 40 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1680fac..4003ffb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [UNRELEASED]
+### Added
+
+- Bashtard now bundles an example `.service` and example `.timer` file for use
+ with Systemd. They can be installed separetely with the `make` target
+ `install-svc-systemd`.
+
### Fixed
- `config_subkeys` and `config_subkeys_for` should now leave off the `&` at the
diff --git a/Makefile b/Makefile
index 917c26c..53b8642 100644
--- a/Makefile
+++ b/Makefile
@@ -21,6 +21,13 @@ all:
install: bin lib share
+install-svc-systemd:
+ mkdir -pv -- "$(PREFIX)$(ETCDIR)/systemd/system"
+ cp -rv -- \
+ share/svc/systemd/bashtard.service \
+ share/svc/systemd/bashtard.timer \
+ "$(PREFIX)$(ETCDIR)/systemd/system"
+
uninstall:
rm -fv -- "$(PREFIX)$(DESTDIR)/bin/bashtard"
rm -rfv -- "$(PREFIX)$(DESTDIR)/lib/bashtard"
@@ -107,4 +114,4 @@ share:
share/os.d \
"$(PREFIX)$(DESTDIR)/share/bashtard"
-.PHONY: all install uninstall pkg-debian qa bin lib man share
+.PHONY: all install install-svc-systemd uninstall pkg-debian qa bin lib man share
diff --git a/README.md b/README.md
index f8a2e1c..a7da9e9 100644
--- a/README.md
+++ b/README.md
@@ -56,6 +56,12 @@ command for each playbook that is used on the machine.
If you want to do updates on a regular basis, you should configure your
preferred cron system to do so.
+#### Systemd
+
+Bashtard contains an example `.service` and accompanying `.timer`, found in the
+`share/svc/systemd` directory. These can be installed separately with `make
+install-svc-systemd`.
+
### Playbooks
These are the essential components for doing the actual work. Playbooks are
diff --git a/share/svc/systemd/bashtard.service b/share/svc/systemd/bashtard.service
new file mode 100644
index 0000000..b2794a0
--- /dev/null
+++ b/share/svc/systemd/bashtard.service
@@ -0,0 +1,10 @@
+[Unit]
+Description = Run bashtard sync action
+After = network-online.target
+
+[Service]
+Type = oneshot
+ExecStart = /bin/sh -c "/usr/bin/bashtard sync"
+
+[Install]
+WantedBy = multi-user.target
diff --git a/share/svc/systemd/bashtard.timer b/share/svc/systemd/bashtard.timer
new file mode 100644
index 0000000..01335e6
--- /dev/null
+++ b/share/svc/systemd/bashtard.timer
@@ -0,0 +1,10 @@
+[Unit]
+Description = Run Bashtard on schedule
+
+[Timer]
+OnStartupSec = 120
+OnUnitInactiveSec = 1800
+RandomizedDelaySec = 300
+
+[Install]
+WantedBy = timers.target