Subject: misc/14825: /etc/{daily,weekly,montly} should be unified
To: None <gnats-bugs@gnats.netbsd.org>
From: None <kivinen@ssh.fi>
List: netbsd-bugs
Date: 12/03/2001 16:53:24
>Number:         14825
>Category:       misc
>Synopsis:       setting of rebuild_locatedb=YES in daily.conf does not do anything
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    misc-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 03 06:54:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Tero Kivinen
>Release:        NetBSD 1.5Y
>Organization:
SSH Communications Security
>Environment:
System: NetBSD kaakeli.acr.fi 1.5Y NetBSD 1.5Y (KAAKELI) #47: Wed Oct 31 02:45:43 EET 2001 kivinen@kaakeli.acr.fi:/usr/src/sys/arch/i386/compile/KAAKELI i386
Architecture: i386
Machine: i386
>Description:

	The /etc/{daily,weekly,montly} scripts should be unified so
	that setting for example rebuild_locatedb=YES in daily.conf
	causes the locatedb to be updated daily. I.e all them should
	run the exactly same script, but the configuration parameters
	simply would be different.

>How-To-Repeat:

	Currently rebuild_locatedb=YES is only understood by the
	/etc/weekly. Seting it in /etc/daily.conf or /etc/monthly.conf
	does not affect anything.

>Fix:

	Combine all /etc/{daily,weekly,montly} scripts to one having this
	kind of header (not tested):
----------------------------------------------------------------------
#!/bin/sh -
#
#	$NetBSD: oneinawhile,v 1.8 2000/01/10 17:03:49 ad Exp $
#	from: @(#)oneinawhile	8.1 (Berkeley) 6/9/93
#

export PATH=/bin:/usr/bin:/sbin:/usr/sbin
umask 077

type=`echo $0 | sed 's/.*\///g;'`

if [ -s /etc/$type.conf ]; then
	. /etc/$type.conf
fi

if [ -f /etc/rc.subr ]; then
        . /etc/rc.subr
else
        echo "Can't read /etc/rc.subr; aborting."
        exit 1;
fi

if checkyesno run_only_when_connected_to_ac; then
        if [ `apm -a` == 0 ]; then
                exit 0
        fi
fi

host=`hostname`
date=`date`

echo "To: ${MAILTO:-root}"
echo "Subject: $host $type output for $date"
echo ""

if [ -z "$MAILTO" -o "$USER" != "root" ]; then
	MAILTO=root
fi

----------------------------------------------------------------------

And then all bodies of the /etc/daily, /etc/weekly, and /etc/montly
combined together (removing their headers and footers, and moving some
echo "" and rm -f $TMP $TMP2 etc inside the if checkyesno).

Then the script should have footer like this:
----------------------------------------------------------------------
if [ -f /etc/$type.local ]; then
	echo ""
	echo "Running /etc/$type.local:"
	. /etc/$type.local
fi
----------------------------------------------------------------------

Then remove /etc/{daily,weekly,montly} and create symlinks from them
to /etc/oneinawhile
>Release-Note:
>Audit-Trail:
>Unformatted: