#!/bin/sh
# $OpenBSD: INSTALL,v 1.1.1.1 2003/08/23 19:24:50 sturm Exp $
#
# Pre/post-installation setup of anacron

PATH=/bin:/usr/bin:/sbin:/usr/sbin
PREFIX=${PKG_PREFIX:-/usr/local}
SPOOL_DIR=/var/spool/anacron

# Function: set up the anacron spool dir
do_spooldir()
{
    echo "-> Creating anacron spooldir under $SPOOL_DIR"
    if [ ! -d $SPOOL_DIR ]; then
	install -d -o root -g wheel -m 755 $SPOOL_DIR
    fi
}

# Function: tell the user what s/he needs to do to use the port
#	    just installed
#
do_notice()
{
    # Text take from the README file of the anacron-2.3
    # distribution.
    cat <<EOT
+----------
| To start using anacron:
| 
| Create the file ${SYSCONFDIR}/anacrontab (see anacrontab(5) for
| information about its format).
| 
| The following is a simple example which runs the standard
| OpenBSD daily, weekly, and monthly scripts:
| 
| -----Cut
| # ${SYSCONFDIR}/anacrontab example
| SHELL=/bin/sh
| PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
| # format: period delay job-identifier command
| 1  5  cron.daily   sh /etc/daily 2>&1   | tee /var/log/daily.out   | mail -s "\`hostname\` daily output" root
| 7  10 cron.weekly  sh /etc/weekly 2>&1  | tee /var/log/weekly.out  | mail -s "\`hostname\` weekly output" root
| 30 15 cron.monthly sh /etc/monthly 2>&1 | tee /var/log/monthly.out | mail -s "\`hostname\` monthly output" root
| -----Cut
| 
| Comment the invocation of these jobs in root's crontab.
| 
| Invoke anacron from /etc/rc.local like this:
| 
| if [ X"\${anacron}" == X"YES" -a -x ${PREFIX}/sbin/anacron -a -f ${SYSCONFDIR}/anacrontab ]; then
|     echo -n ' anacron'
|     ${PREFIX}/sbin/anacron -s
| fi
| 
| (and add "anacron=YES" to /etc/rc.conf.local)
| 
| If your machine is left running for more than 24h at a time, you
| might also want to invoke anacron from a nightly cron job.
| 
| That's it.
+----------

EOT
}

# Verify/process the command
#
case $2 in
    PRE-INSTALL)
	;;
    POST-INSTALL)
	do_spooldir
	do_notice
	;;
    *)
	echo "Usage: `basename $0` distname <PRE-INSTALL|POST-INSTALL>" >&2
	exit 1
	;;
esac

exit 0
