Skip to content

Instantly share code, notes, and snippets.

@jcaesar
Created March 8, 2022 09:58
Show Gist options
  • Save jcaesar/19654c8de537b895d5d7108438b90a0c to your computer and use it in GitHub Desktop.
Save jcaesar/19654c8de537b895d5d7108438b90a0c to your computer and use it in GitHub Desktop.
pacoffman
#!/usr/bin/env bash
set -euxo pipefail
kernelver="$(pacman -Qi linux-ec2 | grep Version)"
paccache -r
pacman -Syu --noconfirm
if test "$(( $(date +%s) / 86400 % 14 ))" -eq 0 || test "$(pacman -Qi linux-ec2 | grep Version)" != "$kernelver"; then
systemctl reboot
fi
[Unit]
Description=Syu and reboot
[Service]
ExecStart=/usr/local/bin/maintain
Type=oneshot
[Unit]
Description=Syu and reboot
[Timer]
OnCalendar=*-*-* 03:25:00 Asia/Tokyo
[Install]
WantedBy=timers.target
[Unit]
Description=Remove pacman db.lock on startup
[Timer]
OnBootSec=0s
[Install]
WantedBy=timers.target
[Unit]
Description=Remove pacman db.lock
[Service]
ExecStart=/usr/bin/rm -f /var/lib/pacman/db.lck
Type=oneshot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment