add systemd service, timer files

This commit is contained in:
ray 2020-02-17 16:21:39 +00:00
parent 49f47cb990
commit 5438db66ed
5 changed files with 57 additions and 4 deletions

View File

@ -1,11 +1,26 @@
#!/bin/sh #!/bin/sh
_user_id=$(id -u) _user_id=$(id -u)
if ! [ "$_user_id" -eq 0 ] ; then if [ "$_user_id" -eq 0 ] ; then
echo "pacman-update-count.sh: insufficient priviliges: must be run as root" echo "pacman-update-count.sh: error - must be run as normal user, not root"
exit 1 exit 1
fi fi
cp ./notify-updates /usr/local/bin/ sudo cp ./notify-updates /usr/local/bin/
cp ./pacman-update-count /usr/local/bin/ sudo cp ./pacman-update-count /usr/local/bin/
sudo cp ./pacman-update-count.* /etc/systemd/system/
mkdir -p ~/.config/systemd/user
cp ./update-notifier.* ~/.config/systemd/user
sudo systemctl daemon-reload
sudo systemctl enable pacman-update-count.timer
sudo systemctl start pacman-update-count.timer
systemctl --user enable update-notifier.timer
systemctl --user start update-notifier.timer

View File

@ -0,0 +1,9 @@
[Unit]
Description=Update package update count (used by update-notifier)
[Service]
ExecStart=/usr/local/bin/pacman-update-count
[Install]
WantedBy=default.target

10
pacman-update-count.timer Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=Periodically run pacman-update-count
[Timer]
OnBootSec=55minutes
OnActiveSec=1sec
OnUnitActiveSec=110minutes
[Install]
WantedBy=timers.target

9
update-notifier.service Normal file
View File

@ -0,0 +1,9 @@
[Unit]
Description=Notify when updates are available
[Service]
ExecStart=/usr/local/bin/notify-updates -n
[Install]
WantedBy=default.target

10
update-notifier.timer Normal file
View File

@ -0,0 +1,10 @@
[Unit]
Description=Periodically run update-notifier
[Timer]
OnBootSec=1hour
OnActiveSec=1sec
OnUnitActiveSec=2hours
[Install]
WantedBy=timers.target