Add alarm/fake-hwclock

This commit is contained in:
moonman 2013-12-21 03:56:45 -07:00
parent 51e439c53b
commit 1c5fb136c5
3 changed files with 63 additions and 0 deletions

View file

@ -0,0 +1,23 @@
# Maintainer: Oleg Rakhmanov <orakhmanov [at] gmail [dot] com>
#
# 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
pkgname=fake-hwclock
pkgver=0.1
pkgrel=1
pkgdesc="Saves time on shutdown and restores it on boot from a file"
arch=('arm')
license=('GPL')
source=('savesettime.sh'
'fake-hwclock.service')
md5sums=('8264f56630b0ed3299b51a43f3854285'
'555ce36333857e6ee56c98daa7df2f5f')
package() {
mkdir -p "${pkgdir}/usr/lib/systemd/"{scripts,system}
cp "${srcdir}/savesettime.sh" "${pkgdir}/usr/lib/systemd/scripts/"
cp "${srcdir}/fake-hwclock.service" "${pkgdir}/usr/lib/systemd/system/"
}

View file

@ -0,0 +1,13 @@
[Unit]
Description=Sets time to what it was at last shutdown.
After=sysinit.target
[Service]
Type=oneshot
ExecStart=/usr/lib/systemd/scripts/savesettime.sh set
RemainAfterExit=true
ExecStop=/usr/lib/systemd/scripts/savesettime.sh save
[Install]
WantedBy=sysinit.target

View file

@ -0,0 +1,27 @@
#!/bin/bash
MYSELF=$0
setclock() {
echo "Setting hardware clock \n"
MYTIME=$(date -r $MYSELF '+%Y-%m-%d %r')
date --set="$MYTIME" &>/dev/null
}
saveclock() {
echo "Saving current time \n"
touch $MYSELF &>/dev/null
}
case "$1" in
set)
setclock
;;
save)
saveclock
;;
*)
echo "Usage: $MYSELF {set|save}"
exit 1
;;
esac