summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: e3c1468562158a8698ef5626c04f675fc93e31cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# Maintainer:  Chris Severance aur.severach aATt spamgourmet dott com

pkgname='dmesg-shutdown'
pkgver='1.0.0'
pkgrel='1'
pkgdesc='record dmesg on every shutdown'
arch=('any')
url='https://unix.stackexchange.com/questions/284598/systemd-how-to-execute-script-at-shutdown-only-not-at-reboot'
license=('GPL')
depends=('systemd')
options=('!strip')
install="${pkgname}-install.sh"

package() {
  install -Dm644 <(cat << EOF
[Unit]
Description=Record dmesg on every shutdown
Conflicts=reboot.target
After=network.target

[Service]
Type=oneshot
ExecStart=/usr/bin/true
ExecStop=/usr/bin/bash /usr/lib/${pkgname}.sh
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF
  ) "${pkgdir}/usr/lib/systemd/system/${pkgname}.service"

  install -Dm644 <(cat << EOF
#!/usr/bin/bash

/usr/bin/dmesg > /root/dmesg.\$(date +"%F_%H-%M-%S").txt
sync
EOF
  ) "${pkgdir}/usr/lib/${pkgname}.sh"
}