#! /bin/sh
# /etc/init.d/anacron: start anacron
#

PATH=/bin:/usr/bin:/sbin:/usr/sbin

test -f /usr/sbin/anacron || exit 0

case "$1" in
  start)
    if test -x /usr/bin/on_ac_power 
    then
        /usr/bin/on_ac_power >/dev/null
        if test $? -eq 1
        then
          echo "Starting anac(h)ronistic cron: deferred while on battery power."
	  exit 0
        fi
    fi

    # on_ac_power doesn't exist, on_ac_power returns 0 (ac power being used)
    # or on_ac_power returns 255 (undefined, desktop machine without APM)
    echo -n "Starting anac(h)ronistic cron: anacron"
    anacron -s
    echo "."
    ;;
  restart|force-reload|stop)
  	# nothing to do
    :
    ;;
  *)
    echo "Usage: /etc/init.d/anacron start"
    exit 1
    ;;
esac

exit 0
