Add man pages and separate properly between global systemd and user systemd services and timers

This commit is contained in:
Alexander Schäferdiek 2022-06-13 11:31:59 +02:00
parent 73382481e2
commit 2fd172fcb1
47 changed files with 157 additions and 45 deletions

View file

@ -1,13 +1,28 @@
# README # README
A collection of scripts and systemd services which might be useful. dotfiles-system is a collection of helper systemd services, systemd timers and
shell scripts for common configuration and tasks like
Use at your own risk. * checking if systemd services and timers are running
* borgmatic backup
* restic backup
* checking if docker containers are running
* batch docker-compose upgrades
* docker housekeeping for removing unused docker containers, volumes and images
* dynamic dns update
* update check for pacman
* memory and disk checks
Provided systemd services mostly support mail notifications if they have failed
via systemd_failure_notify.
See `/usr/share/doc/dotfiles-system` for example configurations which should
be copied inside $HOME or /etc depending on the helper script.
## Installation ## Installation
1. After you pulled, use `./sync` and pick an action which should be self-explaining. 1. Build a `pacman` package for ArchLinux via `makepkg -csi` inside the `dist/` folder (**recommended**).
2. Alternatively, build a `pacman` package for ArchLinux via `makepkg -csi` inside the `dist/` folder. 2. Alternatively, use `./sync` from the git clone and pick an action which should be self-explaining.
## Usage ## Usage
@ -15,7 +30,7 @@ Services and scripts don't depend on each other but have hints that they can be
combined (out-commented line in service files for `systemd_failure_notify@.service` combined (out-commented line in service files for `systemd_failure_notify@.service`
for example). for example).
Examples are given inside `usr/share/doc/`. Examples are given inside `usr/share/doc/dotfiles-system`.
## FAQ ## FAQ

2
_man/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
vendor/
.bundle/

4
_man/Gemfile Normal file
View file

@ -0,0 +1,4 @@
source "https://rubygems.org"
gem "ronn", "~> 0.7.3"

19
_man/Gemfile.lock Normal file
View file

@ -0,0 +1,19 @@
GEM
remote: https://rubygems.org/
specs:
hpricot (0.8.6)
mustache (1.1.1)
rdiscount (2.2.0.2)
ronn (0.7.3)
hpricot (>= 0.8.2)
mustache (>= 0.7.0)
rdiscount (>= 1.5.8)
PLATFORMS
x86_64-linux
DEPENDENCIES
ronn (~> 0.7.3)
BUNDLED WITH
2.3.15

14
_man/README.md Normal file
View file

@ -0,0 +1,14 @@
# README
Build man pages with `ronn`.
- Install Ruby and `gem`
- Install `gem install bundler` or via system package `bundler`
- Execute the following to build and serve via _Jekyll_
```shell
bundle config set --local path 'vendor/bundle'
bundle install
# generate man pages in /usr/share/man/man1
for file in src/*.ronn; do bn=$(basename $file .ronn); bundle exec ronn --pipe < $file > ../usr/share/man/man1/$bn; done
```

View file

@ -0,0 +1,20 @@
# dotfiles-system
dotfiles-system is a collection of helper systemd services, systemd timers and
shell scripts for common configuration and tasks like
* checking if systemd services and timers are running
* borgmatic backup
* restic backup
* checking if docker containers are running
* batch docker-compose upgrades
* docker housekeeping for removing unused docker containers, volumes and images
* dynamic dns update
* update check for pacman
* memory and disk checks
Provided systemd services mostly support mail notifications if they have failed
via systemd_failure_notify.
See `/usr/share/doc/dotfiles-system` for example configurations which should
be copied inside $HOME or /etc depending on the helper script.

View file

View file

@ -1,6 +1,6 @@
pkgname=dotfiles-system-git pkgname=dotfiles-system-git
_pkgname="dotfiles-system" _pkgname="dotfiles-system"
pkgver=r81.da266c6 pkgver=r83.7338248
pkgrel=1 pkgrel=1
pkgdesc="Common system helper scripts" pkgdesc="Common system helper scripts"
arch=('any') arch=('any')

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run borgmatic check for %I utilizing HOME/.config/borgmatic/%I.yml file Description=Run borgmatic check for %I utilizing /etc/borgmatic/%I.yml file
OnFailure=systemd_failure_notify@%n.service OnFailure=systemd_failure_notify@%n.service
Wants=network-online.target Wants=network-online.target
After=network-online.target After=network-online.target
@ -7,7 +7,7 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=borgmatic check --only repository --only archives --syslog-verbosity 1 --config %h/.config/borgmatic/%I.yml ExecStart=borgmatic check --only repository --only archives --syslog-verbosity 1 --config /etc/borgmatic/%I.yml
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin" Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin"
Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh" Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh"
Environment="BORGMATIC_NAME=%I" Environment="BORGMATIC_NAME=%I"

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run borgmatic %I check timer utilizing HOME/.config/borgmatic/%I.yml file Description=Run borgmatic check for %I utilizing /etc/borgmatic/%I.yml file
[Timer] [Timer]
OnCalendar=Wed 21:30:00 OnCalendar=Wed 21:30:00

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run borgmatic create for %I utilizing HOME/.config/borgmatic/%I.yml file Description=Run borgmatic create for %I utilizing /etc/borgmatic/%I.yml file
OnFailure=systemd_failure_notify@%n.service OnFailure=systemd_failure_notify@%n.service
Wants=network-online.target Wants=network-online.target
After=network-online.target After=network-online.target
@ -7,7 +7,7 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=borgmatic create --syslog-verbosity 1 --config %h/.config/borgmatic/%I.yml ExecStart=borgmatic create --syslog-verbosity 1 --config /etc/borgmatic/%I.yml
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin" Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin"
Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh" Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh"
Environment="BORGMATIC_NAME=%I" Environment="BORGMATIC_NAME=%I"

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run borgmatic %I create timer utilizing HOME/.config/borgmatic/%I.yml file Description=Run borgmatic create for %I utilizing /etc/borgmatic/%I.yml file
[Timer] [Timer]
OnCalendar=*-*-* 20:00:00 OnCalendar=*-*-* 20:00:00

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run borgmatic prune for %I utilizing HOME/.config/borgmatic/%I.yml file Description=Run borgmatic prune for %I utilizing /etc/borgmatic/%I.yml file
OnFailure=systemd_failure_notify@%n.service OnFailure=systemd_failure_notify@%n.service
Wants=network-online.target Wants=network-online.target
After=network-online.target After=network-online.target
@ -7,7 +7,7 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=borgmatic prune --syslog-verbosity 1 --config %h/.config/borgmatic/%I.yml ExecStart=borgmatic prune --syslog-verbosity 1 --config /etc/borgmatic/%I.yml
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin" Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin"
Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh" Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh"
Environment="BORGMATIC_NAME=%I" Environment="BORGMATIC_NAME=%I"

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run borgmatic %I prune timer utilizing HOME/.config/borgmatic/%I.yml file Description=Run borgmatic prune for %I utilizing /etc/borgmatic/%I.yml file
[Timer] [Timer]
OnCalendar=Wed 23:00:00 OnCalendar=Wed 23:00:00

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run borgmatic backup for %I utilizing HOME/.config/borgmatic/%I.yml file Description=Run borgmatic backup for %I utilizing /etc/borgmatic/%I.yml file
OnFailure=systemd_failure_notify@%n.service OnFailure=systemd_failure_notify@%n.service
Wants=network-online.target Wants=network-online.target
After=network-online.target After=network-online.target
@ -7,7 +7,7 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=borgmatic --syslog-verbosity 1 --config %h/.config/borgmatic/%I.yml ExecStart=borgmatic --syslog-verbosity 1 --config /etc/borgmatic/%I.yml
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin" Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin"
Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh" Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh"
Environment="BORGMATIC_NAME=%I" Environment="BORGMATIC_NAME=%I"

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run borgmatic %I backup timer utilizing HOME/.config/borgmatic/%I.yml file Description=Run borgmatic backup for %I utilizing /etc/borgmatic/%I.yml file
[Timer] [Timer]
OnCalendar=*-*-* 20:00:00 OnCalendar=*-*-* 20:00:00

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run restic check script for %I utilizing ~/.config/restic/%I-check.sh file using env ~/.config/restic/%I.env Description=Run restic check script for %I utilizing /etc/restic/%I/check.sh file using env /etc/restic/%I/env
OnFailure=systemd_failure_notify@%n.service OnFailure=systemd_failure_notify@%n.service
Wants=network-online.target Wants=network-online.target
After=network-online.target After=network-online.target
@ -7,10 +7,10 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=sh %h/.config/restic/%I-check.sh ExecStart=sh /etc/restic/%I/check.sh
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin" Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin"
Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh" Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh"
EnvironmentFile=%h/.config/restic/%I.env EnvironmentFile=/etc/restic/%I/env
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run restic check script for %I utilizing HOME/.config/restic/%I-check.sh file Description=Run restic check script for %I utilizing /etc/restic/%I/check.sh file using env /etc/restic/%I/env
[Timer] [Timer]
OnCalendar=Wed 22:00:00 OnCalendar=Wed 22:00:00

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run restic create script for %I utilizing ~/.config/restic/%I-create.sh file using env ~/.config/restic/%I.env Description=Run restic create script for %I utilizing /etc/restic/%I/create.sh file using env /etc/restic/%I/env
OnFailure=systemd_failure_notify@%n.service OnFailure=systemd_failure_notify@%n.service
Wants=network-online.target Wants=network-online.target
After=network-online.target After=network-online.target
@ -7,12 +7,12 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=sh %h/.config/restic/%I-create.sh ExecStart=sh /etc/%I/create.sh
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin" Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin"
Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh" Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh"
Environment="RESTIC_FILE_INCLUDE=%h/.config/restic/%I.include" Environment="RESTIC_FILE_INCLUDE=%h/.config/restic/%I.include"
Environment="RESTIC_FILE_EXCLUDE=%h/.config/restic/%I.exclude" Environment="RESTIC_FILE_EXCLUDE=%h/.config/restic/%I.exclude"
EnvironmentFile=%h/.config/restic/%I.env EnvironmentFile=/etc/restic/%I/env
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run restic create script for %I utilizing HOME/.config/restic/%I-create.sh file Description=Run restic create script for %I utilizing /etc/restic/%I/create.sh file using env /etc/restic/%I/env
[Timer] [Timer]
OnCalendar=23:00 OnCalendar=23:00

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run restic prune script for %I utilizing ~/.config/restic/%I-prune.sh file using env ~/.config/restic/%I.env Description=Run restic prune script for %I utilizing /etc/restic/%I-prune.sh file using env /etc/restic/%I/env
OnFailure=systemd_failure_notify@%n.service OnFailure=systemd_failure_notify@%n.service
Wants=network-online.target Wants=network-online.target
After=network-online.target After=network-online.target
@ -7,10 +7,10 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=sh %h/.config/restic/%I-prune.sh ExecStart=sh /etc/restic/%I/prune.sh
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin" Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin"
Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh" Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh"
EnvironmentFile=%h/.config/restic/%I.env EnvironmentFile=/etc/restic/%I/env
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run restic prune script for %I utilizing HOME/.config/restic/%I-prune.sh file Description=Run restic prune script for %I utilizing /etc/restic/%I-prune.sh file using env /etc/restic/%I/env
[Timer] [Timer]
OnCalendar=Wed 23:00:00 OnCalendar=Wed 23:00:00

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run restic check script for %I utilizing ~/.config/restic/%I-check.sh file using env ~/.config/restic/%I.env Description=Run restic check script for %I utilizing ~/.config/restic/%I/check.sh file using env ~/.config/restic/%I/env
OnFailure=systemd_failure_notify@%n.service OnFailure=systemd_failure_notify@%n.service
Wants=network-online.target Wants=network-online.target
After=network-online.target After=network-online.target
@ -7,10 +7,10 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=sh %h/.config/restic/%I-check.sh ExecStart=sh %h/.config/restic/%I/check.sh
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin" Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin"
Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh" Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh"
EnvironmentFile=%h/.config/restic/%I.env EnvironmentFile=%h/.config/restic/%I/env
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run restic check script for %I utilizing HOME/.config/restic/%I-check.sh file Description=Run restic check script for %I utilizing ~/.config/restic/%I/check.sh file using env ~/.config/restic/%I/env
[Timer] [Timer]
OnCalendar=Wed 22:00:00 OnCalendar=Wed 22:00:00

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run restic create script for %I utilizing ~/.config/restic/%I-create.sh file using env ~/.config/restic/%I.env Description=Run restic create script for %I utilizing ~/.config/restic/%I/create.sh file using env ~/.config/restic/%I/env
OnFailure=systemd_failure_notify@%n.service OnFailure=systemd_failure_notify@%n.service
Wants=network-online.target Wants=network-online.target
After=network-online.target After=network-online.target
@ -7,12 +7,12 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=sh %h/.config/restic/%I-create.sh ExecStart=sh %h/.config/restic/%I/create.sh
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin" Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin"
Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh" Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh"
Environment="RESTIC_FILE_INCLUDE=%h/.config/restic/%I.include" Environment="RESTIC_FILE_INCLUDE=%h/.config/restic/%I/include"
Environment="RESTIC_FILE_EXCLUDE=%h/.config/restic/%I.exclude" Environment="RESTIC_FILE_EXCLUDE=%h/.config/restic/%I/exclude"
EnvironmentFile=%h/.config/restic/%I.env EnvironmentFile=%h/.config/restic/%I/env
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run restic create script for %I utilizing HOME/.config/restic/%I-create.sh file Description=Run restic create script for %I utilizing ~/.config/restic/%I/create.sh file using env ~/.config/restic/%I/env
[Timer] [Timer]
OnCalendar=23:00 OnCalendar=23:00

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run restic prune script for %I utilizing ~/.config/restic/%I-prune.sh file using env ~/.config/restic/%I.env Description=Run restic prune script for %I utilizing ~/.config/restic/%I/prune.sh file using env ~/.config/restic/%I/env
OnFailure=systemd_failure_notify@%n.service OnFailure=systemd_failure_notify@%n.service
Wants=network-online.target Wants=network-online.target
After=network-online.target After=network-online.target
@ -7,10 +7,10 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=sh %h/.config/restic/%I-prune.sh ExecStart=sh %h/.config/restic/%I/prune.sh
Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin" Environment="PATH=/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:%h/.bin"
Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh" Environment="SSH_AUTH_SOCK=/run/user/%u/keyring/ssh"
EnvironmentFile=%h/.config/restic/%I.env EnvironmentFile=%h/.config/restic/%I/env
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target

View file

@ -1,5 +1,5 @@
[Unit] [Unit]
Description=Run restic prune script for %I utilizing HOME/.config/restic/%I-prune.sh file Description=Run restic prune script for %I utilizing ~/.config/restic/%I/prune.sh file using env ~/.config/restic/%I/env
[Timer] [Timer]
OnCalendar=Wed 23:00:00 OnCalendar=Wed 23:00:00

View file

@ -11,7 +11,7 @@ if [[ -z "${name}" ]]; then
fi fi
if [[ -z ${encryption} ]]; then if [[ -z ${encryption} ]]; then
encryption=3072; encryption=4096;
fi fi
openssl genrsa -out "${name}" "${encryption}" openssl genrsa -out "${name}" "${encryption}"

View file

@ -0,0 +1,38 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
dotfiles\-system is a collection of helper systemd services, systemd timers and shell scripts for common configuration and tasks like
.
.IP "\(bu" 4
checking if systemd services and timers are running
.
.IP "\(bu" 4
borgmatic backup
.
.IP "\(bu" 4
restic backup
.
.IP "\(bu" 4
checking if docker containers are running
.
.IP "\(bu" 4
batch docker\-compose upgrades
.
.IP "\(bu" 4
docker housekeeping for removing unused docker containers, volumes and images
.
.IP "\(bu" 4
dynamic dns update
.
.IP "\(bu" 4
update check for pacman
.
.IP "\(bu" 4
memory and disk checks
.
.IP "" 0
.
.P
Provided systemd services mostly support mail notifications if they have failed via systemd_failure_notify\.
.
.P
See \fB/usr/share/doc/dotfiles\-system\fR for example configurations which should be copied inside $HOME or /etc depending on the helper script\.