include rc.subr and use appropriately

This commit is contained in:
lukem 1998-01-26 12:02:43 +00:00
parent a6fc46b600
commit 8f59ce8e35
5 changed files with 64 additions and 43 deletions

View File

@ -1,15 +1,23 @@
#!/bin/sh -
#
# $NetBSD: daily,v 1.24 1997/10/27 04:18:06 lukem Exp $
# $NetBSD: daily,v 1.25 1998/01/26 12:02:43 lukem Exp $
# @(#)daily 8.2 (Berkeley) 1/25/94
#
PATH=/bin:/usr/bin:/sbin:/usr/sbin
export PATH
host=`hostname`
echo "Subject: $host daily run output"
umask 077
if [ -f /etc/rc.subr ]; then
. /etc/rc.subr
else
echo "Can't read /etc/rc.subr; aborting."
exit 1;
fi
if [ -z "$MAILTO" -o "$USER" != "root" ]; then
MAILTO=root
fi
@ -65,7 +73,7 @@ fi
TMP=daily.$$
TMP2=daily2.$$
if [ "$find_core" != NO ] ; then
if checkyesno find_core; then
find / \( ! -fstype local -o -fstype rdonly -o -fstype fdesc \
-o -fstype kernfs -o -fstype procfs \) -a -prune -o \
-name 'lost+found' -a -prune -o \
@ -91,15 +99,15 @@ if [ "$find_core" != NO ] ; then
rm -f $TMP $TMP2
fi
if [ "$run_msgs" != NO ]; then
if checkyesno run_msgs; then
msgs -c
fi
if [ "$expire_news" != NO -a -f /etc/news.expire ]; then
if checkyesno expire_news && [ -f /etc/news.expire ]; then
/etc/news.expire
fi
if [ "$purge_accounting" != NO -a -f /var/account/acct ]; then
if checkyesno purge_accounting && [ -f /var/account/acct ]; then
echo ""
echo "Purging accounting records:"
mv /var/account/acct.2 /var/account/acct.3
@ -109,7 +117,7 @@ if [ "$purge_accounting" != NO -a -f /var/account/acct ]; then
sa -sq
fi
if [ "$run_calendar" != NO ]; then
if checkyesno run_calendar; then
calendar -a > $TMP
if [ -s $TMP ]; then
echo ""
@ -119,14 +127,14 @@ if [ "$run_calendar" != NO ]; then
rm -f $TMP
fi
if [ "$check_uucp" != NO -a -d /var/spool/uucp -a \
-f /usr/libexec/uucp/clean.daily ]; then
if checkyesno check_uucp && \
[ -d /var/spool/uucp -a -f /usr/libexec/uucp/clean.daily ]; then
echo ""
echo "Cleaning up UUCP:"
su daemon -c /usr/libexec/uucp/clean.daily
fi
if [ "$check_disks" != NO ]; then
if checkyesno check_disks; then
df -k > $TMP
dump W > $TMP2
if [ -s $TMP -o -s $TMP2 ]; then
@ -148,7 +156,7 @@ fi
rm -f $TMP $TMP2
if [ "$check_mailq" != NO ]; then
if checkyesno check_mailq; then
mailq > $TMP
if ! grep -q "^Mail queue is empty$" $TMP; then
echo ""
@ -159,7 +167,7 @@ fi
rm -f $TMP
if [ "$check_uucp" != NO -a -d /var/spool/uucp ]; then
if checkyesno check_uucp && [ -d /var/spool/uucp ]; then
uustat -a > $TMP
if [ -s $TMP ]; then
echo ""
@ -170,7 +178,7 @@ fi
rm -f $TMP
if [ "$check_network" != NO ]; then
if checkyesno check_network; then
echo ""
echo "network:"
netstat -i
@ -181,14 +189,14 @@ if [ "$check_network" != NO ]; then
fi
fi
if [ "$run_fsck" != NO ]; then
if checkyesno run_fsck; then
echo ""
echo "Checking filesystems:"
fsck -n | grep -v '^\*\* Phase'
fi
echo ""
if [ "$run_rdist" != NO -a -f /etc/Distfile ]; then
if checkyesno run_rdist && [ -f /etc/Distfile ]; then
echo "Running rdist:"
if [ -d /var/log/rdist ]; then
logf=`date +%Y.%b.%e`
@ -198,7 +206,7 @@ if [ "$run_rdist" != NO -a -f /etc/Distfile ]; then
fi
fi
if [ "$run_security" != NO ]; then
if checkyesno run_security; then
sh /etc/security 2>&1 | mail -s "$host daily insecurity output" $MAILTO
fi

View File

@ -1,6 +1,6 @@
#!/bin/sh -
#
# $NetBSD: netstart,v 1.50 1998/01/24 19:12:54 veego Exp $
# $NetBSD: netstart,v 1.51 1998/01/26 12:02:47 lukem Exp $
# from: @(#)netstart 8.1 (Berkeley) 7/23/93
if [ -f /etc/rc.subr ]; then
@ -33,7 +33,7 @@ if [ -n "$domainname" ]; then
fi
# Flush all routes just to make sure it is clean
if [ "$flushroutes" = YES ]; then
if checkyesno flushroutes; then
route flush
fi
@ -91,7 +91,7 @@ if [ "$net_interfaces" != NO ]; then
ifconfig $int $args
done) < /etc/ifconfig.$int
else
if [ "$auto_ifconfig" != YES ]; then
if ! checkyesno auto_ifconfig; then
echo
echo "WARNING: /etc/ifconfig.$int missing " \
"and ifconfig_$int not set; " \

14
etc/rc
View File

@ -1,4 +1,4 @@
# $NetBSD: rc,v 1.99 1998/01/24 19:12:55 veego Exp $
# $NetBSD: rc,v 1.100 1998/01/26 12:02:50 lukem Exp $
# originally from: @(#)rc 8.2 (Berkeley) 3/17/94
# System startup script run by init on autoboot
@ -119,9 +119,9 @@ for fs in /usr /var $critical_filesystems; do
done
# Network Address Translation...
if [ "$ipnat" != NO ] && [ -f /etc/ipnat.conf ]; then
if checkyesno ipnat && [ -f /etc/ipnat.conf ]; then
echo 'installing NAT rules ... '
if [ "$ipfilter" = NO ] || [ ! -f /etc/ipf.conf ]; then
if ! checkyesno ipfilter || [ ! -f /etc/ipf.conf ]; then
ipf -E -Fa
fi
ipnat -F -f /etc/ipnat.conf
@ -133,7 +133,7 @@ fi
swapctl -A -t noblk
# Check for no swap, and warn about it unless that is desired.
if [ "$no_swap" != YES ]; then
if ! checkyesno no_swap; then
swapctl -s | grep 'no swap devices configured' > /dev/null && \
echo "WARNING: no swap space configured!"
fi
@ -242,7 +242,7 @@ if checkyesno nfs_server; then
echo -n > /var/db/mountdtab
echo -n ' mountd'; mountd $mountd_flags
echo -n ' nfsd'; nfsd $nfsd_flags
nfs_locking=MAYBE
nfs_locking=YES
else
echo
logger -s "WARNING: /etc/exports not readable; " \
@ -252,10 +252,10 @@ fi
if checkyesno nfs_client; then
echo -n ' nfsiod'; nfsiod $nfsiod_flags
nfs_locking=MAYBE
nfs_locking=YES
fi
if [ "$nfs_locking" != NO ]; then
if checkyesno nfs_locking; then
if checkyesno statd; then
echo -n ' rpc.statd'; rpc.statd $statd_flags
fi

View File

@ -1,11 +1,18 @@
#!/bin/sh -
#
# $NetBSD: security,v 1.30 1997/10/08 16:13:44 mycroft Exp $
# $NetBSD: security,v 1.31 1998/01/26 12:02:55 lukem Exp $
# from: @(#)security 8.1 (Berkeley) 6/9/93
#
PATH=/sbin:/usr/sbin:/bin:/usr/bin
if [ -f /etc/rc.subr ]; then
. /etc/rc.subr
else
echo "Can't read /etc/rc.subr; aborting."
exit 1;
fi
umask 077
if [ -s /etc/security.conf ]; then
@ -40,7 +47,7 @@ awk -F: '{ print $1 " " $3 }' $MP | sort -k2n > $MPBYUID
awk -F: '{ print $1 " " $9 }' $MP | sort -k2 > $MPBYPATH
# Check the master password file syntax.
if [ "$check_passwd" = YES ]; then
if checkyesno check_passwd; then
awk '
BEGIN {
while ( getline < "/etc/shells" > 0 ) {
@ -118,7 +125,7 @@ else
fi
# Check the group file syntax.
if [ "$check_group" = YES ]; then
if checkyesno check_group; then
GRP=/etc/group
awk -F: '{
if ($0 ~ /^[ ]*$/) {
@ -151,7 +158,7 @@ fi
# The check for the root paths is problematical -- it's likely to fail
# in other environments. Once the shells have been modified to warn
# of '.' in the path, the path tests should go away.
if [ "$check_rootdotfiles" = YES ]; then
if checkyesno check_rootdotfiles; then
> $OUTPUT
rhome=`csh -fc "echo ~root"`
umaskset=no
@ -247,7 +254,7 @@ end-of-sh
fi
# Root and uucp should both be in /etc/ftpusers.
if [ "$check_ftpusers" = YES ]; then
if checkyesno check_ftpusers; then
> $OUTPUT
list="uucp "`awk '$2 == 0 { print $1 }' $MPBYUID`
for i in $list; do
@ -262,14 +269,14 @@ if [ "$check_ftpusers" = YES ]; then
fi
# Uudecode should not be in the /etc/aliases file.
if [ "$check_aliases" = YES ]; then
if checkyesno check_aliases; then
if egrep '^[^#]*(uudecode|decode).*\|' /etc/aliases; then
printf "\nEntry for uudecode in /etc/aliases file.\n"
fi
fi
# Files that should not have + signs.
if [ "$check_rhosts" = YES ]; then
if checkyesno check_rhosts; then
list="/etc/hosts.equiv /etc/hosts.lpd"
for f in $list ; do
if [ -f $f ] && egrep '\+' $f > /dev/null ; then
@ -308,7 +315,7 @@ fi
# Check home directories. Directories should not be owned by someone else
# or writeable.
if [ "$check_homes" = YES ]; then
if checkyesno check_homes; then
while read uid homedir; do
if [ -d ${homedir}/ ] ; then
file=`ls -ldgT ${homedir}`
@ -376,7 +383,7 @@ if [ "$check_homes" = YES ]; then
fi
# Mailboxes should be owned by user and unreadable.
if [ "$check_varmail" = YES ]; then
if checkyesno check_varmail; then
ls -l /var/mail | sed 1d | \
awk '$3 != $9 \
{ print "user " $9 " mailbox is owned by " $3 }
@ -388,7 +395,7 @@ if [ "$check_varmail" = YES ]; then
fi
fi
if [ "$check_nfs" = YES ]; then
if checkyesno check_nfs; then
if [ -f /etc/exports ]; then
# File systems should not be globally exported.
awk '{
@ -416,7 +423,7 @@ if [ "$check_nfs" = YES ]; then
fi
# Display any changes in setuid files and devices.
if [ "$check_devices" = YES ]; then
if checkyesno check_devices; then
> $ERR
(find / \( ! -fstype local -o -fstype fdesc -o -fstype kernfs \
-o -fstype procfs \) -a -prune -o \
@ -571,7 +578,7 @@ fi
# the hacker can modify the tree specification to match the replaced binary.
# For details on really protecting yourself against modified binaries, see
# the mtree(8) manual page.
if [ "$check_mtree" = YES ]; then
if checkyesno check_mtree; then
mtree -e -p / -f /etc/mtree/special > $OUTPUT
if [ -s $OUTPUT ]; then
printf "\nChecking special files and directories.\n"
@ -597,7 +604,7 @@ fi
# List of files that get backed up and checked for any modifications. Each
# file is expected to have two backups, /var/backups/file.{current,backup}.
# Any changes cause the files to rotate.
if [ "$check_changelist" = YES ] && [ -s /etc/changelist ] ; then
if checkyesno check_changelist && [ -s /etc/changelist ] ; then
for file in `egrep -v "^#|$MP" /etc/changelist`; do
CUR=/var/backups/`basename $file`.current
BACK=/var/backups/`basename $file`.backup

View File

@ -1,16 +1,22 @@
#!/bin/sh -
#
# $NetBSD: weekly,v 1.9 1997/10/27 04:11:40 lukem Exp $
# $NetBSD: weekly,v 1.10 1998/01/26 12:02:58 lukem Exp $
# from: @(#)weekly 8.2 (Berkeley) 1/2/94
#
PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/libexec
export PATH
host=`hostname`
echo "Subject: $host weekly run output"
umask 077
host=`hostname`
echo "Subject: $host weekly run output"
if [ -f /etc/rc.subr ]; then
. /etc/rc.subr
else
echo "Can't read /etc/rc.subr; aborting."
exit 1;
fi
if [ -s /etc/weekly.conf ]; then
. /etc/weekly.conf
@ -45,7 +51,7 @@ fi
# rm -rf $TDIR
#fi
if [ "$clean_uucp" = YES ] && [ -f /usr/libexec/uucp/clean.weekly ]; then
if checkyesno clean_uucp && [ -f /usr/libexec/uucp/clean.weekly ]; then
echo ""
echo "Cleaning up UUCP:"
su daemon -c /usr/libexec/uucp/clean.weekly
@ -53,7 +59,7 @@ fi
echo ""
echo ""
if [ "$rebuild_locatedb" = YES ] && [ -f /var/db/locate.database ]; then
if checkyesno rebuild_locatedb && [ -f /var/db/locate.database ]; then
echo "Rebuilding locate database:"
chmod 644 /var/db/locate.database
chown nobody.nobody /var/db/locate.database