mirror of
https://github.com/Stunkymonkey/dotfiles.git
synced 2025-05-24 11:04:41 +02:00
[systemd] switch cron borg notification to systemd
This commit is contained in:
parent
0cbc67116c
commit
dbd6704926
5 changed files with 36 additions and 17 deletions
|
@ -1,17 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
## */10 * * * * ~/.dotfiles/cron/borg-notify.sh
|
|
||||||
|
|
||||||
LAST=$(tail -1 ~/.borgbackup.log)
|
|
||||||
|
|
||||||
DIF=$((($(date -d "now" +%s) - $(date -d $LAST +%s)) / 86400))
|
|
||||||
|
|
||||||
if [ $DIF -ge 7 ] ; then
|
|
||||||
export DISPLAY=:0
|
|
||||||
for proc in $(pgrep -u $USER); do
|
|
||||||
if grep -z DBUS_SESSION_BUS_ADDRESS /proc/$proc/environ; then
|
|
||||||
export DBUS_SESSION_BUS_ADDRESS="$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$proc/environ | sed -e 's/DBUS_SESSION_BUS_ADDRESS=//')"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
notify-send -i drive-harddisk Borg-Backup "Your last backup was $DIF days ago.\nPlease make a new one."
|
|
||||||
fi
|
|
4
systemd/borg-notify-install.sh
Executable file
4
systemd/borg-notify-install.sh
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cp borg-notify.service borg-notify.timer ~/.config/systemd/user/
|
||||||
|
systemctl enable borg-notify.timer --user
|
6
systemd/borg-notify.service
Normal file
6
systemd/borg-notify.service
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Borg-notification
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=/home/felix/.dotfiles/systemd/borg-notify.sh
|
||||||
|
Type=oneshot
|
17
systemd/borg-notify.sh
Executable file
17
systemd/borg-notify.sh
Executable file
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
LAST=$(tail -1 ~/.borgbackup.log)
|
||||||
|
|
||||||
|
DIF=$((($(date -d "now" +%s) - $(date -d "$LAST" +%s)) / 86400))
|
||||||
|
|
||||||
|
if [ $DIF -ge 7 ] ; then
|
||||||
|
export DISPLAY=:0
|
||||||
|
for proc in $(pgrep -u "$USER"); do
|
||||||
|
if grep -z DBUS_SESSION_BUS_ADDRESS /proc/"$proc"/environ; then
|
||||||
|
export DBUS_SESSION_BUS_ADDRESS
|
||||||
|
DBUS_SESSION_BUS_ADDRESS="$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/"$proc"/environ | sed -e 's/DBUS_SESSION_BUS_ADDRESS=//')"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
notify-send -i drive-harddisk Borg-Backup "Your last backup was $DIF days ago.\nPlease make a new one."
|
||||||
|
fi
|
9
systemd/borg-notify.timer
Normal file
9
systemd/borg-notify.timer
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=10 min borg-notification
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnBootSec=1min
|
||||||
|
OnUnitActiveSec=10min
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
Loading…
Add table
Add a link
Reference in a new issue