#!/bin/sh
#
# $Id: fix-modes,v 1.10 1996/07/02 09:18:35 casper Exp casper $
#
# Fix-modes script.
#
# Warning: no locking of the contents file is attempted.
#
# Casper Dik (casper@fwi.uva.nl)
#
umask 022
PATH=/usr/local/etc:`dirname $0`:$PATH
export PATH
# Only works for 5.2-5.5, check the modes program for each new revision
# and adjust script accordingly.
# Probably works for 2.5.1 and later.
case "`uname -r`" in
5.[2345]*) ;;
*)  
	echo "Only supported on Solaris 2.2 thru 2.5" 1>&2 
	exit 1;;
esac

modes > /tmp/changes$$ || {
	echo "modes failed, aborting fix-modes" 1>&2
	rm -f /tmp/changes$$ /tmp/contents
	exit 1
}
if [ -s /tmp/changes$$ ]
then
    find /var/sadm -xdev \( -perm -020 -o -perm -002 \) -print >> /tmp/changes$$
    xargs chmod og-w < /tmp/changes$$
    touch /var/adm/messages
    chmod og-w /var/adm/messages
    set -e
    # Always save old contents file.  The very first one becomes increasingly
    # out of date.  Previously, we saved the very first contents file.
    rm -f /var/sadm/install/contents.org.Z
    mv /var/sadm/install/contents /var/sadm/install/contents.org
    compress /var/sadm/install/contents.org
    mv /tmp/contents /var/sadm/install/contents
    chmod 644 /var/sadm/install/contents
else
    rm -f /tmp/contents
fi
# Our install scripts created these with owner root.
if [ ! -f /var/lp/logs/lpNet ]
then
    touch /var/lp/logs/lpNet /var/lp/logs/lpsched
fi
chown lp /var/lp/logs/lpNet /var/lp/logs/lpsched

rm -f /tmp/changes$$
