Sophie

Sophie

distrib > Mandriva > 2009.1 > i586 > media > main-release-src > by-pkgid > 4090922c88d76dcb9d3d77a391885b7d > files > 8

anacron-2.3-30mdv2009.1.src.rpm

#!/bin/bash
# wait for 3:02 when /etc/crontab runs cron.daily
if [ `date +%H` -le 4 ]; then
    exit 0;
fi

#delay - more computers on one line don't receive updates at the same time
[ -f /etc/sysconfig/crontab ] && . /etc/sysconfig/crontab
if [ ! -z "$DELAY" ]; then
    if [ "$DELAY" != "0" ]; then
    # Create md5sum of hostname (static over system lifetime)
        md5sum="`echo ${HOSTNAME} | md5sum`"

        # Extract the first 3 hexdigits (12 Bit: 0-4095)
        hexvalue="${md5sum:0:3}"

        # Create decimal value
        decvalue="`printf "%d" "0x${hexvalue}"`"

        # Divide delay by factor
        T_DELAY=$[ ${decvalue} / ${DELAY} ]
        sleep $T_DELAY
    fi
fi
# in case anacron is already running,
# there will be log (daemon won't be running twice).
if test -x /usr/bin/on_ac_power; then
	/usr/bin/on_ac_power &> /dev/null
	if test $? -eq 1; then
		exit 0
	fi
fi
/usr/sbin/anacron -s