Add optional DNS check for network-online.target to user service files
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Alexander Schäferdiek 2022-08-23 18:55:27 +02:00
parent 04b18fefa0
commit b0517cfa44
10 changed files with 17 additions and 2 deletions

View file

@ -51,5 +51,8 @@ the user service before.
systemctl --user link /usr/lib/systemd/system/network-online.target systemctl --user link /usr/lib/systemd/system/network-online.target
``` ```
This would make `network-online.target` available after a _reboot_ to the user This would make `network-online.target` available after a _reboot_ to the user who issued the command.
who issued the command.
### `network-online.target` doesn't recognize DNS correctly
If you like to set `Persistent=true`, then you should probably equip the related `.service` file with a `ExecStartPre=/bin/bash -c 'until host captiveportal.myservermanager.com; do sleep 1; done'` or any domain you think is 100% reachable.

View file

@ -7,6 +7,7 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
#ExecStartPre=/bin/bash -c 'until host captiveportal.myservermanager.com; do sleep 1; done'
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 %h/.config/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"

View file

@ -7,6 +7,7 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
#ExecStartPre=/bin/bash -c 'until host captiveportal.myservermanager.com; do sleep 1; done'
ExecStart=borgmatic create --syslog-verbosity 1 --config %h/.config/borgmatic/%I.yml ExecStart=borgmatic create --syslog-verbosity 1 --config %h/.config/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"

View file

@ -7,6 +7,7 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
#ExecStartPre=/bin/bash -c 'until host captiveportal.myservermanager.com; do sleep 1; done'
ExecStart=borgmatic prune --syslog-verbosity 1 --config %h/.config/borgmatic/%I.yml ExecStart=borgmatic prune --syslog-verbosity 1 --config %h/.config/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"

View file

@ -7,6 +7,7 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
#ExecStartPre=/bin/bash -c 'until host captiveportal.myservermanager.com; do sleep 1; done'
ExecStart=borgmatic --syslog-verbosity 1 --config %h/.config/borgmatic/%I.yml ExecStart=borgmatic --syslog-verbosity 1 --config %h/.config/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"

View file

@ -1,9 +1,13 @@
[Unit] [Unit]
Description=Run check_updates Description=Run check_updates
OnFailure=systemd_failure_notify@%n.service OnFailure=systemd_failure_notify@%n.service
Wants=network-online.target
After=network-online.target
Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
#ExecStartPre=/bin/bash -c 'until host captiveportal.myservermanager.com; do sleep 1; done'
ExecStart=check_updates ExecStart=check_updates
[Install] [Install]

View file

@ -7,6 +7,7 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
#ExecStartPre=/bin/bash -c 'until host captiveportal.myservermanager.com; do sleep 1; done'
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"

View file

@ -7,6 +7,7 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
#ExecStartPre=/bin/bash -c 'until host captiveportal.myservermanager.com; do sleep 1; done'
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"

View file

@ -7,6 +7,7 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
#ExecStartPre=/bin/bash -c 'until host captiveportal.myservermanager.com; do sleep 1; done'
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"

View file

@ -7,6 +7,7 @@ Requires=network-online.target
[Service] [Service]
Type=oneshot Type=oneshot
#ExecStartPre=/bin/bash -c 'until host captiveportal.myservermanager.com; do sleep 1; done'
ExecStart=sh %h/.config/restic/%I/report.sh ExecStart=sh %h/.config/restic/%I/report.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"