#!/sbin/runscript # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # get this number with 'date +%s' - it's just a fallback sanetime # but really anything is better than the epoch SANETIME="1310410279" SANETIME_FILE=/etc/sanetime depend() { need localmount } write_sanetime() { mkdir -p $(dirname $SANETIME_FILE) echo "$1" > $SANETIME_FILE } dofunc() { local Now Then Now="$(date +%s 2>&1)" if [ -e $SANETIME_FILE ]; then Then="$(cat $SANETIME_FILE)" else Then=$SANETIME fi if [ $Now -gt $Then ]; then write_sanetime $Now else write_sanetime $Then date -s @$Then >/dev/null 2>&1 fi } start() { ebegin "Initializing sanetime" ( dofunc start ) eend $? "Error initializing sanetime" } stop() { ebegin "Saving sanetime" ( dofunc stop ) eend $? "Failed to save sanetime" } # vim:ts=4