mirror of
https://github.com/archlinuxarm/PKGBUILDs.git
synced 2024-11-28 22:57:37 +00:00
Merge pull request #850 from Lekensteyn/fake-hwclock
alarm/fake-hwclock: use systemd timer unit, to 0.3
This commit is contained in:
commit
b43e19b040
6 changed files with 60 additions and 24 deletions
|
@ -1,24 +1,33 @@
|
||||||
# Maintainer: Oleg Rakhmanov <orakhmanov [at] gmail [dot] com>
|
# Maintainer: Oleg Rakhmanov <orakhmanov [at] gmail [dot] com>
|
||||||
|
# Contributor: Peter Wu <peter (at) lekensteyn (dot) nl>
|
||||||
#
|
#
|
||||||
# Reworked Alexander Manning's rc.d script for systemd
|
# Reworked Alexander Manning's rc.d script for systemd
|
||||||
# Reference: http://archplusplus.co.uk/post/31401843803/fake-hwclock-for-arch-linux-arm-on-raspberry-pi
|
# Reference: http://archplusplus.co.uk/post/31401843803/fake-hwclock-for-arch-linux-arm-on-raspberry-pi
|
||||||
|
|
||||||
pkgname=fake-hwclock
|
pkgname=fake-hwclock
|
||||||
pkgver=0.2
|
pkgver=0.3
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="Saves time on shutdown and restores it on boot from a file"
|
pkgdesc="Saves time on shutdown and restores it on boot from a file"
|
||||||
arch=('arm')
|
arch=('any')
|
||||||
license=('GPL')
|
license=('GPL')
|
||||||
install=fake-hwclock.install
|
install=fake-hwclock.install
|
||||||
source=('fake-hwclock.sh'
|
source=('fake-hwclock.sh'
|
||||||
'fake-hwclock.service')
|
'fake-hwclock.service'
|
||||||
|
'fake-hwclock-save.service'
|
||||||
|
'fake-hwclock-save.timer')
|
||||||
|
|
||||||
md5sums=('09cea0ee86071fb86d3cdbc52feabe69'
|
md5sums=('713f9cd5d8dc0073b5eca5dd14de1271'
|
||||||
'8a328ff872a092dcdf86088ae2c20fd3')
|
'fa52aac3db246575c3cc8c1bf608766c'
|
||||||
|
'9f93ed2b74260d204a9c285d35ee2daa'
|
||||||
|
'b2b494cb4ba99eb12df3cb4188902ca4')
|
||||||
|
|
||||||
package() {
|
package() {
|
||||||
mkdir -p "${pkgdir}/usr/lib/systemd/"{scripts,system}
|
install -D -m755 "${srcdir}/fake-hwclock.sh" "${pkgdir}/usr/lib/systemd/scripts/fake-hwclock.sh"
|
||||||
|
for unit in \
|
||||||
cp "${srcdir}/fake-hwclock.sh" "${pkgdir}/usr/lib/systemd/scripts/"
|
fake-hwclock.service \
|
||||||
cp "${srcdir}/fake-hwclock.service" "${pkgdir}/usr/lib/systemd/system/"
|
fake-hwclock-save.service \
|
||||||
|
fake-hwclock-save.timer
|
||||||
|
do
|
||||||
|
install -D -m644 "${srcdir}/$unit" "${pkgdir}/usr/lib/systemd/system/$unit"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
9
alarm/fake-hwclock/fake-hwclock-save.service
Normal file
9
alarm/fake-hwclock/fake-hwclock-save.service
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Periodically saves system time to file
|
||||||
|
After=fake-hwclock.service
|
||||||
|
Requires=fake-hwclock.service
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=/usr/lib/systemd/scripts/fake-hwclock.sh save
|
||||||
|
StandardOutput=null
|
10
alarm/fake-hwclock/fake-hwclock-save.timer
Normal file
10
alarm/fake-hwclock/fake-hwclock-save.timer
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Periodically saves system time to file timer
|
||||||
|
After=fake-hwclock.service
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnActiveSec=15min
|
||||||
|
OnUnitActiveSec=15min
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=fake-hwclock.service
|
|
@ -1,9 +1,8 @@
|
||||||
post_install () {
|
post_install () {
|
||||||
echo "**********************************************************************"
|
echo "To restore the system time on boot, save the time on shutdown and"
|
||||||
echo "To keep fake-hwclock up to date in case of a power failure, add the"
|
echo "periodically save the system time in case of power failure:"
|
||||||
echo "following job to root crontab: "
|
echo " systemctl enable fake-hwclock fake-hwclock-save.timer"
|
||||||
echo "*/15 * * * * /usr/lib/systemd/scripts/fake-hwclock.sh save"
|
echo " systemctl start fake-hwclock"
|
||||||
echo "**********************************************************************"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
post_upgrade () {
|
post_upgrade () {
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Saves time on shutdown and sets it at boot.
|
Description=Restore system time on boot and save it on shutdown
|
||||||
After=sysinit.target
|
After=sysinit.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
ExecStart=/usr/lib/systemd/scripts/fake-hwclock.sh set
|
ExecStart=/usr/lib/systemd/scripts/fake-hwclock.sh load
|
||||||
ExecStop=/usr/lib/systemd/scripts/fake-hwclock.sh save
|
ExecStop=/usr/lib/systemd/scripts/fake-hwclock.sh save
|
||||||
RemainAfterExit=true
|
RemainAfterExit=true
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=sysinit.target
|
WantedBy=sysinit.target
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,37 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
THISFILE=$0
|
THISFILE=$0
|
||||||
|
STATEFILE=$0
|
||||||
|
|
||||||
setclock() {
|
loadclock() {
|
||||||
echo "Setting clock."
|
local savedtime=$(stat -c %Y "$STATEFILE")
|
||||||
MYTIME=$(date -r $THISFILE '+%Y-%m-%d %H:%M:%S')
|
if [ $(date +%s) -lt $savedtime ]; then
|
||||||
date --set="$MYTIME" &>/dev/null
|
echo "Restoring saved system time"
|
||||||
|
date -s @$savedtime
|
||||||
|
else
|
||||||
|
echo "Not restoring old system time"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
saveclock() {
|
saveclock() {
|
||||||
echo "Saving current time."
|
echo "Saving current time."
|
||||||
touch $THISFILE &>/dev/null
|
touch "$STATEFILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
load)
|
||||||
|
loadclock
|
||||||
|
;;
|
||||||
set)
|
set)
|
||||||
setclock
|
echo "'set' is deprecated, use 'load' instead."
|
||||||
|
echo "Consider using the systemd timer unit fake-hwclock-save.timer"
|
||||||
|
loadclock
|
||||||
;;
|
;;
|
||||||
save)
|
save)
|
||||||
saveclock
|
saveclock
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: $THISFILE {set|save}"
|
echo "Usage: $THISFILE {load|save}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue