# -*- mode: shell-script; -*-

start on stopped mountall

script
    if [ -f /var/preferences/com.palm.netclock/time_saver ]; then
        date -n -S -s $(cat /var/preferences/com.palm.netclock/time_saver)
    elif [ -f /etc/version ]; then
        # version is in format YYYYMMDDHHmm.  Coerce to the
        # MMDDHHmmYYYY date expects
        SETFORMAT=$(sed 's/^\(....\)\(........\)$/\2\1/' /etc/version)
        if [ -n "$SETFORMAT" ]; then
            # compare as seconds
            TIMESTAMP=$(date -d $SETFORMAT "+%s")
            CURRENT=$(date "+%s")
            if [ 0$CURRENT -lt 0$TIMESTAMP ]; then
                date -s $SETFORMAT
                date -n -s $SETFORMAT
            fi
        fi
    fi
end script
