? etc/MAKEDEV Index: etc/Makefile =================================================================== RCS file: /cvsroot/src/etc/Makefile,v retrieving revision 1.284 diff -u -u -r1.284 Makefile --- etc/Makefile 8 Mar 2004 05:46:44 -0000 1.284 +++ etc/Makefile 3 Apr 2004 22:06:30 -0000 @@ -84,15 +84,16 @@ BINOWN= root BINGRP= wheel UTMPGRP= utmp -BIN1+= bootptab changelist csh.cshrc csh.login csh.logout daily \ - daily.conf dm.conf floppytab ftpchroot ftpusers \ +BIN1+= bootptab changelist csh.cshrc csh.login csh.logout \ + dm.conf floppytab ftpchroot ftpusers \ gettytab group hosts hosts.lpd inetd.conf lkm.conf locate.conf \ - mailer.conf man.conf monthly monthly.conf mrouted.conf \ + mailer.conf man.conf mrouted.conf \ netconfig networks newsyslog.conf nsswitch.conf ntp.conf \ - passwd.conf phones printcap profile protocols rbootd.conf rc rc.conf \ + passwd.conf periodic periodic.conf periodic.local periodic.subr \ + phones printcap profile protocols rbootd.conf rc rc.conf \ rc.lkm rc.local rc.subr rc.shutdown remote rpc \ security security.conf services shells sysctl.conf syslog.conf \ - weekly weekly.conf wscons.conf \ + wscons.conf \ etc.${MACHINE}/ttys # Use machine-specific disktab if it exists, or the MI one otherwise @@ -260,6 +261,7 @@ ${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m 644 \ ssh/${file} ${DESTDIR}/etc/ssh .endfor + (cd ${.CURDIR}/periodic.d; ${MAKE} install) (cd ${.CURDIR}/powerd; ${MAKE} install) (cd ${.CURDIR}/rc.d; ${MAKE} install) ${ETC_INSTALL_FILE} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ Index: etc/crontab =================================================================== RCS file: /cvsroot/src/etc/crontab,v retrieving revision 1.15 diff -u -u -r1.15 crontab --- etc/crontab 27 Nov 2002 15:09:17 -0000 1.15 +++ etc/crontab 3 Apr 2004 22:06:30 -0000 @@ -15,6 +15,6 @@ 0 * * * * /usr/bin/newsyslog # # do daily/weekly/monthly maintenance -15 3 * * * /bin/sh /etc/daily 2>&1 | tee /var/log/daily.out | sendmail -t -30 4 * * 6 /bin/sh /etc/weekly 2>&1 | tee /var/log/weekly.out | sendmail -t -#30 5 1 * * /bin/sh /etc/monthly 2>&1 | tee /var/log/monthly.out | sendmail -t +15 3 * * * /bin/sh /etc/periodic daily 2>&1 | tee /var/log/daily.out | sendmail -t +30 4 * * 6 /bin/sh /etc/periodic weekly 2>&1 | tee /var/log/weekly.out | sendmail -t +#30 5 1 * * /bin/sh /etc/periodic monthly 2>&1 | tee /var/log/monthly.out | sendmail -t Index: etc/postinstall =================================================================== RCS file: /cvsroot/src/etc/postinstall,v retrieving revision 1.74 diff -u -u -r1.74 postinstall --- etc/postinstall 16 Mar 2004 23:15:40 -0000 1.74 +++ etc/postinstall 3 Apr 2004 22:06:36 -0000 @@ -363,9 +363,29 @@ do_defaults() { [ -n "$1" ] || err 2 "USAGE: do_defaults fix|check" + failed=0 compare_dir $1 ${SRC_DIR}/etc/defaults ${DEST_DIR}/etc/defaults 444 \ - daily.conf monthly.conf rc.conf security.conf weekly.conf + periodic.conf rc.conf security.conf + failed=$(( ${failed} + $? )) + + # check for obsolete defaults files + for f in daily.conf monthly.conf weekly.conf; do + fd=${DEST_DIR}/etc/defaults/${f} + [ ! -e "${fd}" ] && continue + if [ "${op}" = "check" ]; then + msg "Remove obsolete ${fd}" + failed=1 + elif ! rm ${fd}; then + msg "Can't remove obsolete ${fd}" + failed=1 + else + msg "Removed obsolete ${fd}" + fi + done + failed=$(( ${failed} + $? )) + + return ${failed} } # @@ -408,13 +428,40 @@ # # periodic # -additem periodic "/etc/{daily,weekly,monthly,security} being up to date" +additem periodic "/etc/{periodic,security} and /etc/periodic.d/* being up to date" do_periodic() { [ -n "$1" ] || err 2 "USAGE: do_periodic fix|check" + failed=0 compare_dir $1 ${SRC_DIR}/etc ${DEST_DIR}/etc 644 \ - daily weekly monthly security + periodic periodic.subr security + failed=$(( ${failed} + $? )) + + compare_dir ${op} ${SRC_DIR}/etc/periodic.d \ + ${DEST_DIR}/etc/periodic.d 555 \ + check_disks check_mailq check_network check_uucp clean_uucp \ + expire_news find_core purge_accounting rebuild_locatedb \ + run_calendar run_fsck run_msgs run_rdist run_security \ + run_skeyaudit uptime + failed=$(( ${failed} + $? )) + + # check for obsolete periodic files + for f in daily monthly weekly; do + fd=${DEST_DIR}/etc/${f} + [ ! -e "${fd}" ] && continue + if [ "${op}" = "check" ]; then + msg "Remove obsolete ${fd}" + failed=1 + elif ! rm ${fd}; then + msg "Can't remove obsolete ${fd}" + failed=1 + else + msg "Removed obsolete ${fd}" + fi + done + + return ${failed} } # Index: etc/defaults/Makefile =================================================================== RCS file: /cvsroot/src/etc/defaults/Makefile,v retrieving revision 1.2 diff -u -u -r1.2 Makefile --- etc/defaults/Makefile 24 Apr 2002 08:18:45 -0000 1.2 +++ etc/defaults/Makefile 3 Apr 2004 22:06:36 -0000 @@ -1,6 +1,6 @@ # $NetBSD: Makefile,v 1.2 2002/04/24 08:18:45 lukem Exp $ -FILES= daily.conf monthly.conf rc.conf security.conf weekly.conf +FILES= periodic.conf rc.conf security.conf FILESDIR= /etc/defaults FILESMODE= ${NONBINMODE} Index: etc/mtree/NetBSD.dist =================================================================== RCS file: /cvsroot/src/etc/mtree/NetBSD.dist,v retrieving revision 1.259 diff -u -u -r1.259 NetBSD.dist --- etc/mtree/NetBSD.dist 9 Mar 2004 20:09:40 -0000 1.259 +++ etc/mtree/NetBSD.dist 3 Apr 2004 22:06:37 -0000 @@ -23,6 +23,7 @@ ./etc/openssl/certs ./etc/openssl/misc ./etc/openssl/private +./etc/periodic.d ./etc/postfix ./etc/powerd ./etc/powerd/scripts Index: etc/mtree/special =================================================================== RCS file: /cvsroot/src/etc/mtree/special,v retrieving revision 1.79 diff -u -u -r1.79 special --- etc/mtree/special 6 Feb 2004 15:36:53 -0000 1.79 +++ etc/mtree/special 3 Apr 2004 22:06:40 -0000 @@ -34,16 +34,12 @@ ./etc/csh.cshrc type=file mode=0644 ./etc/csh.login type=file mode=0644 ./etc/csh.logout type=file mode=0644 -./etc/daily type=file mode=0644 -./etc/daily.conf type=file mode=0644 ./etc/daily.local type=file mode=0644 optional ./etc/defaultdomain type=file mode=0644 optional ./etc/defaults type=dir mode=0755 -./etc/defaults/daily.conf type=file mode=0444 -./etc/defaults/monthly.conf type=file mode=0444 +./etc/defaults/periodic.conf type=file mode=0444 ./etc/defaults/rc.conf type=file mode=0444 ./etc/defaults/security.conf type=file mode=0444 -./etc/defaults/weekly.conf type=file mode=0444 ./etc/dhclient-enter-hooks type=file mode=0644 optional ./etc/dhclient-exit-hooks type=file mode=0644 optional ./etc/dhclient.conf type=file mode=0644 optional @@ -92,8 +88,6 @@ ./etc/master.passwd type=file mode=0600 tags=nodiff ./etc/mk.conf type=file mode=0644 optional ./etc/moduli type=file mode=0444 -./etc/monthly type=file mode=0644 -./etc/monthly.conf type=file mode=0644 ./etc/monthly.local type=file mode=0644 optional ./etc/mrouted.conf type=file mode=0644 ./etc/mtree type=dir mode=0755 @@ -113,6 +107,27 @@ ./etc/ntp.conf type=file mode=0644 optional ./etc/passwd type=file mode=0644 ./etc/passwd.conf type=file mode=0644 optional +./etc/periodic type=file mode=0644 +./etc/periodic.conf type=file mode=0644 +./etc/periodic.d type=dir mode=0755 +./etc/periodic.d/check_disks type=file mode=0555 +./etc/periodic.d/check_mailq type=file mode=0555 +./etc/periodic.d/check_network type=file mode=0555 +./etc/periodic.d/check_uucp type=file mode=0555 +./etc/periodic.d/clean_uucp type=file mode=0555 +./etc/periodic.d/expire_news type=file mode=0555 +./etc/periodic.d/find_core type=file mode=0555 +./etc/periodic.d/purge_accounting type=file mode=0555 +./etc/periodic.d/rebuild_locatedb type=file mode=0555 +./etc/periodic.d/run_calendar type=file mode=0555 +./etc/periodic.d/run_fsck type=file mode=0555 +./etc/periodic.d/run_msgs type=file mode=0555 +./etc/periodic.d/run_rdist type=file mode=0555 +./etc/periodic.d/run_security type=file mode=0555 +./etc/periodic.d/run_skeyaudit type=file mode=0555 +./etc/periodic.d/uptime type=file mode=0555 +./etc/periodic.local type=file mode=0644 optional +./etc/periodic.subr type=file mode=0644 ./etc/phones type=file mode=0644 ./etc/postfix type=dir mode=0755 optional ./etc/postfix/main.cf type=file mode=0644 optional @@ -253,8 +268,6 @@ ./etc/ttyaction type=file mode=0644 optional ./etc/ttys type=file mode=0644 ./etc/usermgmt.conf type=file mode=0644 optional -./etc/weekly type=file mode=0644 -./etc/weekly.conf type=file mode=0644 ./etc/weekly.local type=file mode=0644 optional ./etc/wscons.conf type=file mode=0644 Index: distrib/sets/comments =================================================================== RCS file: /cvsroot/src/distrib/sets/comments,v retrieving revision 1.4 diff -u -u -r1.4 comments --- distrib/sets/comments 25 Nov 2003 06:28:54 -0000 1.4 +++ distrib/sets/comments 3 Apr 2004 22:06:41 -0000 @@ -305,6 +305,7 @@ etc-sys-defaults default system startup configuration files etc-sys-etc system software configuration files etc-sys-log empty system log files +etc-sys-periodic standard system periodic scripts etc-sys-rc standard system startup scripts etc-sys-root required root file system structure for system software etc-sysutil-etc configuration files for miscellaneous system utilities Index: distrib/sets/deps =================================================================== RCS file: /cvsroot/src/distrib/sets/deps,v retrieving revision 1.1 diff -u -u -r1.1 deps --- distrib/sets/deps 23 Jun 2003 09:02:31 -0000 1.1 +++ distrib/sets/deps 3 Apr 2004 22:06:41 -0000 @@ -296,6 +296,7 @@ etc-sys-defaults base-sys-root etc-sys-etc base-sys-root etc-sys-log base-sys-root +etc-sys-periodic base-sys-root etc-sys-rc base-sys-root etc-sys-root base-sys-root etc-sysutil-etc base-sysutil-bin Index: distrib/sets/descrs =================================================================== RCS file: /cvsroot/src/distrib/sets/descrs,v retrieving revision 1.4 diff -u -u -r1.4 descrs --- distrib/sets/descrs 25 Nov 2003 06:28:54 -0000 1.4 +++ distrib/sets/descrs 3 Apr 2004 22:06:47 -0000 @@ -547,6 +547,7 @@ etc-sys-defaults default system startup configuration files etc-sys-etc system software configuration files etc-sys-log empty system log files +etc-sys-periodic standard system periodic scripts etc-sys-rc standard system startup scripts etc-sys-root required root file system structure for system software etc-sysutil-etc configuration files for miscellaneous system utilities Index: distrib/sets/lists/base/mi =================================================================== RCS file: /cvsroot/src/distrib/sets/lists/base/mi,v retrieving revision 1.472 diff -u -u -r1.472 mi --- distrib/sets/lists/base/mi 1 Apr 2004 21:43:32 -0000 1.472 +++ distrib/sets/lists/base/mi 3 Apr 2004 22:07:09 -0000 @@ -69,6 +69,7 @@ ./etc/openssl/certs base-crypto-root ./etc/openssl/misc base-crypto-root ./etc/openssl/private base-crypto-root +./etc/periodic.d base-sys-root ./etc/postfix base-postfix-bin ./etc/powerd base-sysutil-bin ./etc/powerd/scripts base-sysutil-bin Index: distrib/sets/lists/etc/mi =================================================================== RCS file: /cvsroot/src/distrib/sets/lists/etc/mi,v retrieving revision 1.140 diff -u -u -r1.140 mi --- distrib/sets/lists/etc/mi 6 Feb 2004 15:36:52 -0000 1.140 +++ distrib/sets/lists/etc/mi 3 Apr 2004 22:07:15 -0000 @@ -8,19 +8,20 @@ ./etc/csh.cshrc etc-util-etc ./etc/csh.login etc-util-etc ./etc/csh.logout etc-util-etc -./etc/daily etc-sys-etc -./etc/daily.conf etc-sys-etc +./etc/daily etc-obsolete obsolete +./etc/daily.conf etc-obsolete obsolete ./etc/default etc-obsolete obsolete ./etc/default/daily.conf etc-obsolete obsolete ./etc/default/monthly.conf etc-obsolete obsolete ./etc/default/rc.conf etc-obsolete obsolete ./etc/default/security.conf etc-obsolete obsolete ./etc/default/weekly.conf etc-obsolete obsolete -./etc/defaults/daily.conf etc-sys-defaults -./etc/defaults/monthly.conf etc-sys-defaults +./etc/defaults/daily.conf etc-obsolete obsolete +./etc/defaults/monthly.conf etc-obsolete obsolete +./etc/defaults/periodic.conf etc-sys-defaults ./etc/defaults/rc.conf etc-sys-defaults ./etc/defaults/security.conf etc-sys-defaults -./etc/defaults/weekly.conf etc-sys-defaults +./etc/defaults/weekly.conf etc-obsolete obsolete ./etc/dhclient-script etc-obsolete obsolete ./etc/disktab etc-sysutil-etc ./etc/dm.conf etc-games-etc @@ -59,8 +60,8 @@ ./etc/man.conf etc-man-etc ./etc/master.passwd etc-sys-etc ./etc/moduli etc-secsh-etc crypto -./etc/monthly etc-sys-etc -./etc/monthly.conf etc-sys-etc +./etc/monthly etc-obsolete obsolete +./etc/monthly.conf etc-obsolete obsolete ./etc/motd etc-sys-etc ./etc/mrouted.conf etc-router-etc ./etc/mtree/NetBSD.dist etc-sys-etc @@ -85,6 +86,26 @@ ./etc/obsolete/text etc-obsolete obsolete ./etc/passwd etc-sys-etc ./etc/passwd.conf etc-sys-etc +./etc/periodic etc-sys-periodic +./etc/periodic.conf etc-sys-periodic +./etc/periodic.d/check_disks etc-sys-periodic +./etc/periodic.d/check_mailq etc-sys-periodic +./etc/periodic.d/check_network etc-sys-periodic +./etc/periodic.d/check_uucp etc-sys-periodic +./etc/periodic.d/clean_uucp etc-sys-periodic +./etc/periodic.d/expire_news etc-sys-periodic +./etc/periodic.d/find_core etc-sys-periodic +./etc/periodic.d/purge_accounting etc-sys-periodic +./etc/periodic.d/rebuild_locatedb etc-sys-periodic +./etc/periodic.d/run_calendar etc-sys-periodic +./etc/periodic.d/run_fsck etc-sys-periodic +./etc/periodic.d/run_msgs etc-sys-periodic +./etc/periodic.d/run_rdist etc-sys-periodic +./etc/periodic.d/run_security etc-sys-periodic +./etc/periodic.d/run_skeyaudit etc-sys-periodic +./etc/periodic.d/uptime etc-sys-periodic +./etc/periodic.local etc-sys-periodic +./etc/periodic.subr etc-sys-periodic ./etc/phones etc-uucp-etc ./etc/postfix/README etc-postfix-etc ./etc/postfix/main.cf etc-postfix-etc @@ -233,8 +254,8 @@ ./etc/sysctl.conf etc-sys-etc ./etc/syslog.conf etc-sys-etc ./etc/ttys etc-sys-etc -./etc/weekly etc-sys-etc -./etc/weekly.conf etc-sys-etc +./etc/weekly etc-obsolete obsolete +./etc/weekly.conf etc-obsolete obsolete ./etc/wscons.conf etc-sys-etc ./root/.cshrc etc-root-root ./root/.klogin etc-root-root FILE ADDED TO REPOSITORY: etc/periodic --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic 2004-04-03 23:26:01.000000000 +0200 @@ -0,0 +1,94 @@ +#!/bin/sh - +# +# $NetBSD$ +# +# Copyright (c) 2004 The NetBSD Foundation, Inc. All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal . +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# periodic +# Run the scripts in /etc/periodic.d. +# + +export PATH=/bin:/usr/bin:/sbin:/usr/sbin +umask 077 + +# Include common functions +. /etc/periodic.subr + +# Parse arguments +case $1 in + daily|monthly|weekly) + periodic_frequency=$1 + ;; + *) + err "frequency must be one of daily, monthly or weekly" + ;; +esac + +periodic_mailto= + +# Read the configuration file. +if [ -s /etc/periodic.conf ]; then + . /etc/periodic.conf +elif [ -s /etc/defaults/periodic.conf ]; then + . /etc/defaults/periodic.conf +else + err "cannot open /etc/periodic.conf nor /etc/defaults/periodic.conf" +fi + +# Set default mail address, if none was provided. +[ -z "${periodic_mailto}" -o "$USER" != "root" ] && periodic_mailto=root + +# Mail header. +echo "To: ${periodic_mailto}" +echo "Subject: $(hostname) ${periodic_frequency} output for $(date)" +echo "" + +# Create and enter work directory. +periodic_dir=$(mktemp -d /tmp/periodic.XXXXXX) || exit 1 +trap "/bin/rm -rf ${periodic_dir} ; exit 0" EXIT INT QUIT +cd "${periodic_dir}" || err "cannot cd to ${periodic_dir}". + +# Sort all scripts using rcorder(8) and run them. +files=$(rcorder /etc/periodic.d/*) +periodic_chain=yes +for _periodic_elem in ${files}; do + run_periodic_script ${_periodic_elem} start +done + +[ -s /etc/periodic.local ] && . /etc/periodic.local +[ -s /etc/${periodic_frequency}.local ] && . /etc/${periodic_frequency}.local + +/bin/rm -rf ${periodic_dir} + +exit 0 FILE ADDED TO REPOSITORY: etc/periodic.conf --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.conf 2004-04-03 12:59:41.000000000 +0200 @@ -0,0 +1,10 @@ +# $NetBSD$ +# +# see periodic.conf(5) for more information. + +if [ -r /etc/defaults/periodic.conf ]; then + . /etc/defaults/periodic.conf +fi + +# Add local overrides below +# FILE ADDED TO REPOSITORY: etc/periodic.local --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.local 2004-04-03 22:05:11.000000000 +0200 @@ -0,0 +1,15 @@ +# $NetBSD$ +# +# This file is (nearly) the last thing invoked by /etc/periodic. +# +# It is intended to be edited locally to add site-specific boot-time +# actions, such as starting locally installed daemons. +# +# An alternative option is to create site-specific /etc/periodic.d scripts +# and enable them through /etc/periodic.conf. +# +# Of special interest is the 'periodic_frequency' variable, set before +# running this script, which contains one of this words: 'daily', 'monthly' +# or 'weekly', depending on how /etc/periodic was executed +# + FILE ADDED TO REPOSITORY: etc/periodic.subr --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.subr 2004-04-03 23:54:40.000000000 +0200 @@ -0,0 +1,143 @@ +# $NetBSD$ +# +# Copyright (c) 2004 The NetBSD Foundation, Inc. All rights reserved. +# +# This code is derived from software contributed to The NetBSD Foundation +# by Julio M. Merino Vidal . +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the NetBSD +# Foundation, Inc. and its contributors. +# 4. Neither the name of The NetBSD Foundation nor the names of its +# contributors may be used to endorse or promote products derived +# from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS +# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS +# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# periodic.subr +# Functions used by various periodic scripts. +# + +: ${periodic_chain:=no} +: ${periodic_mailto:=root} + +checkfrequency() +{ + local value + + # Let the user run the periodic.d scripts from the command line. + [ -z "${periodic_frequency}" ] && return 0 + + eval value=\$${1} + case ${value} in + daily|monthly|weekly) + [ ${periodic_frequency} = ${value} ] + ;; + + never|no) + false + ;; + + *) + warn "\$${1} is not set properly - see periodic.conf(5)." + false + ;; + esac +} + +checkyesno() +{ + local value + + eval value=\$${1} + case ${value} in + # "yes", "true", "on", or "1" + [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) + true + ;; + + # "no", "false", "off", or "0" + [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) + false + ;; + + *) + warn "\$${1} is not set properly - see periodic.conf(5)." + false + ;; + esac +} + +err() +{ + echo 1>&2 "${0##*/}: ERROR: $*" + exit 1 +} + +get_tmp_file() +{ + if [ -z "${periodic_dir}" ]; then + periodic_dir=$(mktemp -d /tmp/periodic.XXXXXX) || exit 1 + fi + + mktemp ${periodic_dir}/periodic.XXXXXX +} + +load_periodic_config() +{ + local command=$1 + if [ -z "${command}" ]; then + err 'usage: load_periodic_config command' + fi + + if [ -f /etc/periodic.conf.d/"${command}" ]; then + . /etc/periodic.conf.d/"${command}" + fi +} + +run_periodic_command() +{ + if checkfrequency ${name}; then + if [ ${periodic_chain} = yes ]; then + echo "${name}:" + periodic_${name} + echo "" + else + periodic_${name} + [ -n "${periodic_dir}" -a -d ${periodic_dir} ] && \ + /bin/rm -rf ${periodic_dir} + fi + fi +} + +run_periodic_script() +{ + [ -z "${1}" ] && err 'usage: run_periodic_script file' + + unset name + [ -x ${1} ] && ( . ${1} ) +} + +warn() +{ + echo 1>&2 "${0##*/}: WARNING: $*" +} FILE ADDED TO REPOSITORY: etc/defaults/periodic.conf --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/defaults/periodic.conf 2004-04-03 15:38:51.000000000 +0200 @@ -0,0 +1,46 @@ +# $NetBSD$ +# +# /etc/defaults/periodic.conf -- +# default configuration of /etc/periodic.conf +# +# see periodic.conf(5) for more information. +# +# DO NOT EDIT THIS FILE DIRECTLY; IT MAY BE REPLACED DURING A SYSTEM UPGRADE. +# EDIT /etc/periodic.conf INSTEAD. +# + +# +# Tasks run daily. +# +check_disks=daily +check_mailq=daily +check_network=daily +check_uucp=daily +expire_news=never +find_core=daily +purge_accounting=daily +# calendar uses cpp to expand user calendars. +# calendar -a can be used as a local DOS by making an included file a +# named pipe, thus this is turned off by default. +run_calendar=never +run_fsck=never +run_msgs=daily +run_rdist=daily +run_security=daily +run_skeyaudit=daily +uptime=daily + +# Some settings used by the above tasks. +full_netstat=no +send_empty_security=no +show_remote_fs=no + +# +# Tasks run weekly. +# +clean_uucp=weekly +rebuild_locatedb=weekly + +# +# Tasks run monthly. +# FILE ADDED TO REPOSITORY: etc/periodic.d/Makefile --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/Makefile 2004-04-03 13:51:39.000000000 +0200 @@ -0,0 +1,17 @@ +# $NetBSD$ + +.include + +# if you're adding new scripts, don't forget to update followings. +# src/etc/postinstall +# src/etc/mtree/special +# src/distrib/sets/lists/etc/mi + +FILES= check_disks check_mailq check_network check_uucp \ + clean_uucp expire_news find_core purge_accounting \ + rebuild_locatedb run_calendar run_fsck run_msgs \ + run_rdist run_security run_skeyaudit uptime +FILESDIR= /etc/periodic.d +FILESMODE= ${BINMODE} + +.include FILE ADDED TO REPOSITORY: etc/periodic.d/check_disks --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/check_disks 2004-04-03 22:31:53.000000000 +0200 @@ -0,0 +1,55 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=check_disks + +periodic_check_disks() { + local tmp tmp2 + + tmp=$(get_tmp_file) + tmp2=$(get_tmp_file) + + if checkyesno show_remote_fs; then + df -hi -t nokernfs,procfs,null,fdesc > ${tmp} + else + df -hil -t nokernfs,procfs,null,fdesc > ${tmp} + fi + if [ -s /etc/dumpdates ] ; then + dump -W > ${tmp2} + fi + if [ -s ${tmp} -o -s ${tmp2} ]; then + echo "Checking subsystem status:" + echo "" + echo "disks:" + if [ -s ${tmp} ]; then + cat ${tmp} + echo "" + fi + if [ -s ${tmp2} ]; then + cat ${tmp2} + echo "" + fi + fi + rm -f ${tmp} ${tmp2} + touch ${tmp2} + for dev in `iostat -x | awk '/^raid/ { print $1 }'`; do + raidctl -s ${dev} | awk '/^.*: failed$/ {print $0}' > ${tmp} + if [ -s ${tmp} ]; then + echo "${dev}:" >> ${tmp2} + cat ${tmp} >> ${tmp2} + fi + rm -f ${tmp} + done + if [ -s ${tmp2} ]; then + echo "failed RAIDframe component(s):" + cat ${tmp2} + fi + rm -f ${tmp} ${tmp2} +} + +load_periodic_config "${name}" +run_periodic_command FILE ADDED TO REPOSITORY: etc/periodic.d/check_mailq --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/check_mailq 2004-04-03 22:31:59.000000000 +0200 @@ -0,0 +1,24 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=check_mailq + +periodic_check_mailq() { + local tmp + + tmp=$(get_tmp_file) + + mailq > ${tmp} + if ! grep -q "queue is empty$" ${tmp}; then + echo "mail:" + cat ${tmp} + fi + rm -f ${tmp} +} + +load_periodic_config "${name}" +run_periodic_command FILE ADDED TO REPOSITORY: etc/periodic.d/check_network --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/check_network 2004-04-03 22:32:05.000000000 +0200 @@ -0,0 +1,41 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=check_network + +periodic_check_network() { + local t + + echo "network:" + if checkyesno full_netstat; then + netstat -inv + else + netstat -in | awk 'BEGIN { + ifs[""] = 0; + } + /^[^\*]* / { + if (NR == 1) { + printf("%-8s %10s %6s %10s %6s %6s\n", + $1, $(NF-4), $(NF-3), $(NF-2), $(NF-1), $NF); + next; + } + if (!($1 in ifs)) { + printf("%-8s %10d %6d %10d %6d %6d\n", + $1, $(NF-4), $(NF-3), $(NF-2), $(NF-1), $NF); + ifs[$1] = 1; + } + }' + fi + echo "" + t=/var/rwho/* + if [ "${t}" != '/var/rwho/*' ]; then + ruptime + fi +} + +load_periodic_config "${name}" +run_periodic_command FILE ADDED TO REPOSITORY: etc/periodic.d/check_uucp --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/check_uucp 2004-04-03 22:32:14.000000000 +0200 @@ -0,0 +1,34 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=check_uucp + +periodic_check_uucp() { + local tmp + + tmp=$(get_tmp_file) + + if [ -d /var/spool/uucp -a -f /usr/libexec/uucp/clean.daily ]; then + echo "Cleaning up UUCP:" + su daemon -c /usr/libexec/uucp/clean.daily + fi + + if [ -d /var/spool/uucp ]; then + (cd /tmp; su -m uucp -c "uustat -a") > ${tmp} + if [ -s ${tmp} ]; then + echo "" + echo "uucp:" + cat ${tmp} + fi + + rm -f ${tmp} + fi + rm -f ${tmp} +} + +load_periodic_config "${name}" +run_periodic_command FILE ADDED TO REPOSITORY: etc/periodic.d/clean_uucp --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/clean_uucp 2004-04-03 22:32:16.000000000 +0200 @@ -0,0 +1,18 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=clean_uucp + +periodic_clean_uucp() { + if [ -f /usr/libexec/uucp/clean.weekly ]; then + echo "Cleaning up UUCP:" + su daemon -c /usr/libexec/uucp/clean.weekly + fi +} + +load_periodic_config "${name}" +run_periodic_command FILE ADDED TO REPOSITORY: etc/periodic.d/expire_news --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/expire_news 2004-04-03 00:12:28.000000000 +0200 @@ -0,0 +1,15 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=expire_news + +periodic_expire_news() { + [ -f /etc/news.expire ] && /etc/news.expire +} + +load_periodic_config "${name}" +run_periodic_command FILE ADDED TO REPOSITORY: etc/periodic.d/find_core --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/find_core 2004-04-03 22:32:26.000000000 +0200 @@ -0,0 +1,42 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=find_core + +periodic_find_core() { + local tmp tmp2 + + tmp=$(get_tmp_file) + tmp2=$(get_tmp_file) + + find / \( ! -fstype local -o -fstype rdonly -o -fstype fdesc \ + -o -fstype null \ + -o -fstype kernfs -o -fstype procfs \) -prune -o \ + -name 'lost+found' -prune -o \ + \( -name '*.core' -o -name 'core' \) -type f -print > ${tmp} +# \( -name '[#,]*' -o -name '.#*' -o -name a.out \ +# -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \ +# -a -atime +3 -exec rm -f -- {} \; -a -print > ${tmp} + + egrep '\.core$|^core$' ${tmp} > ${tmp2} + if [ -s ${tmp2} ]; then + echo "Possible core dumps:" + cat ${tmp2} + fi + +# egrep -v '\.core' ${tmp} > ${tmp2} +# if [ -s ${tmp2} ]; then +# echo "" +# echo "Deleted files:" +# cat ${tmp2} +# fi + + rm -f ${tmp} ${tmp2} +} + +load_periodic_config "${name}" +run_periodic_command FILE ADDED TO REPOSITORY: etc/periodic.d/purge_accounting --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/purge_accounting 2004-04-03 22:32:29.000000000 +0200 @@ -0,0 +1,31 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=purge_accounting + +periodic_purge_accounting() { + if [ -f /var/account/acct ]; then + echo "Purging accounting records:" + if [ -f /var/account/acct.0.gz ]; then + mv /var/account/acct.2.gz /var/account/acct.3.gz 2>/dev/null + mv /var/account/acct.1.gz /var/account/acct.2.gz 2>/dev/null + mv /var/account/acct.0.gz /var/account/acct.1.gz 2>/dev/null + else + mv /var/account/acct.2 /var/account/acct.3 2>/dev/null + mv /var/account/acct.1 /var/account/acct.2 2>/dev/null + mv /var/account/acct.0 /var/account/acct.1 2>/dev/null + fi + cp /var/account/acct /var/account/acct.0 + sa -sq + if [ -f /var/account/acct.1.gz ]; then + gzip /var/account/acct.0 + fi + fi +} + +load_periodic_config "${name}" +run_periodic_command FILE ADDED TO REPOSITORY: etc/periodic.d/rebuild_locatedb --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/rebuild_locatedb 2004-04-03 22:32:30.000000000 +0200 @@ -0,0 +1,23 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=rebuild_locatedb + +periodic_rebuild_locatedb() { + if [ -f /var/db/locate.database ]; then + echo "Rebuilding locate database:" + chmod 644 /var/db/locate.database + chown nobody:nobody /var/db/locate.database + nice -5 su -m nobody -c /usr/libexec/locate.updatedb 2>/dev/null + chown root:wheel /var/db/locate.database + else + echo "Not rebuilding locate database; no /var/db/locate.database" + fi +} + +load_periodic_config "${name}" +run_periodic_command FILE ADDED TO REPOSITORY: etc/periodic.d/run_calendar --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/run_calendar 2004-04-03 22:32:32.000000000 +0200 @@ -0,0 +1,24 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=run_calendar + +periodic_run_calendar() { + local tmp + + tmp=$(get_tmp_file) + + calendar -a > ${tmp} 2>&1 + if [ -s ${tmp} ]; then + echo "Running calendar:" + cat ${tmp} + fi + rm -f ${tmp} +} + +load_periodic_config "${name}" +run_periodic_command FILE ADDED TO REPOSITORY: etc/periodic.d/run_fsck --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/run_fsck 2004-04-03 22:32:34.000000000 +0200 @@ -0,0 +1,16 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=run_fsck + +periodic_run_fsck() { + echo "Checking filesystems:" + fsck -n -f | grep -v '^\*\* Phase' +} + +load_periodic_config "${name}" +run_periodic_command FILE ADDED TO REPOSITORY: etc/periodic.d/run_msgs --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/run_msgs 2004-04-03 00:12:41.000000000 +0200 @@ -0,0 +1,15 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=run_msgs + +periodic_run_msgs() { + msgs -c +} + +load_periodic_config "${name}" +run_periodic_command FILE ADDED TO REPOSITORY: etc/periodic.d/run_rdist --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/run_rdist 2004-04-03 00:12:43.000000000 +0200 @@ -0,0 +1,23 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=run_rdist + +periodic_run_rdist() { + if [ -f /etc/Distfile ]; then + echo "Running rdist:" + if [ -d /var/log/rdist ]; then + logf=`date +%Y.%b.%d` + rdist -f /etc/Distfile 2>&1 | tee /var/log/rdist/$logf + else + rdist -f /etc/Distfile + fi + fi +} + +load_periodic_config "${name}" +run_periodic_command FILE ADDED TO REPOSITORY: etc/periodic.d/run_security --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/run_security 2004-04-03 22:28:29.000000000 +0200 @@ -0,0 +1,32 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=run_security + +periodic_run_security() { + local secout + + secout=$(get_tmp_file) + + sh /etc/security > "${secout}" 2>&1 + if [ ! -s "${secout}" ]; then + if checkyesno send_empty_security; then + echo "Nothing to report on $date" > "${secout}" + else + echo "" + echo "Suppressing empty security report." + fi + fi + if [ -s "${secout}" ]; then + mail -s "$(hostname) daily insecurity output for $(date)" \ + ${periodic_mailto} < "${secout}" + fi + rm -f ${secout} +} + +load_periodic_config "${name}" +run_periodic_command FILE ADDED TO REPOSITORY: etc/periodic.d/run_skeyaudit --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/run_skeyaudit 2004-04-03 22:32:41.000000000 +0200 @@ -0,0 +1,18 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=run_skeyaudit + +periodic_run_skeyaudit() { + if [ -s /etc/skeykeys ]; then + echo "Checking remaining s/key OTPs:" + skeyaudit + fi +} + +load_periodic_config "${name}" +run_periodic_command FILE ADDED TO REPOSITORY: etc/periodic.d/uptime --- /dev/null 2004-04-04 00:00:21.000000000 +0200 +++ etc/periodic.d/uptime 2004-04-04 00:06:12.000000000 +0200 @@ -0,0 +1,15 @@ +#!/bin/sh +# +# $NetBSD$ +# + +. /etc/periodic.subr + +name=uptime + +periodic_uptime() { + echo "Uptime: $(uptime)" +} + +load_periodic_config "${name}" +run_periodic_command FILE REMOVED FROM REPOSITORY: etc/daily FILE REMOVED FROM REPOSITORY: etc/daily.conf FILE REMOVED FROM REPOSITORY: etc/monthly FILE REMOVED FROM REPOSITORY: etc/monthly.conf FILE REMOVED FROM REPOSITORY: etc/weekly FILE REMOVED FROM REPOSITORY: etc/weekly.conf FILE REMOVED FROM REPOSITORY: etc/defaults/daily.conf FILE REMOVED FROM REPOSITORY: etc/defaults/monthly.conf FILE REMOVED FROM REPOSITORY: etc/defaults/weekly.conf