Merge pull request #17 from toddejohnson/16-metered-net
Add requires to unmetered-connection.service
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Check if the current NetworkManager connection is metered
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/local/sbin/nm-unmetered-connection.sh
|
||||||
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Backup with restic to Backblaze B2
|
Description=Backup with restic to Backblaze B2
|
||||||
OnFailure=status-email-user@%n.service
|
OnFailure=status-email-user@%n.service
|
||||||
|
Requires=nm-unmetered-connection.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Backup with restic on schedule
|
Description=Backup with restic on schedule
|
||||||
|
Requires=nm-unmetered-connection.service
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar=daily
|
OnCalendar=daily
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
Description=Check restic backup Backblaze B2 for errors
|
Description=Check restic backup Backblaze B2 for errors
|
||||||
OnFailure=status-email-user@%n.service
|
OnFailure=status-email-user@%n.service
|
||||||
Conflicts=restic.service
|
Conflicts=restic.service
|
||||||
|
Requires=nm-unmetered-connection.service
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=Check restic backup Backblaze B2 for errors on a schedule
|
Description=Check restic backup Backblaze B2 for errors on a schedule
|
||||||
|
Requires=nm-unmetered-connection.service
|
||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnCalendar=monthly
|
OnCalendar=monthly
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
systemctl is-active dbus.service >/dev/null 2>&1 || exit 0
|
||||||
|
systemctl is-active NetworkManager.service >/dev/null 2>&1 || exit 0
|
||||||
|
|
||||||
|
metered_status=$(dbus-send --system --print-reply=literal \
|
||||||
|
--system --dest=org.freedesktop.NetworkManager \
|
||||||
|
/org/freedesktop/NetworkManager \
|
||||||
|
org.freedesktop.DBus.Properties.Get \
|
||||||
|
string:org.freedesktop.NetworkManager string:Metered \
|
||||||
|
| grep -o ".$")
|
||||||
|
|
||||||
|
if [[ $metered_status =~ (1|3) ]]; then
|
||||||
|
echo Current connection is metered
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
Reference in New Issue
Block a user