#!/bin/sh -

# 2021-01-14 hostlist's may no longer be supported by IUCS.
#	     I don't really need this anymore anyway.

csaccts='gh.luddy.indiana.edu'
csaccts="$csaccts `${RSHCMD-rsh} $MH -n hostlist -d passwd`"
xxaccts= #`hostlist foreign-passwd`

# ckaccts - check accounts configuration
# Steve Kinzler, steve@kinzler.com, Aug 95
# https://kinzler.com/me/home.html#homedir

case $# in
0)	;;
*)	echo "usage: $0" 1>&2; exit 1;;
esac

tmp=/tmp/ca$$
tmpC=/tmp/caC$$
tmpX=/tmp/caX$$
trap "rm -f $tmp $tmpC $tmpX; exit" 0 1 2 13 15

echo "$csaccts" | tr ' \011' '\012\012' | sort -u | sed '/^$/d' > $tmpC
echo "$xxaccts" | tr ' \011' '\012\012' | sort -u | sed '/^$/d' > $tmpX

hosts -l    cs | hosts -    acct | sort > $tmp
comm -23 $tmp $tmpC | sed '1s/^/Invalid cs accounts:\
/'

hosts -l    cs | hosts - -v acct | sort > $tmp
comm -12 $tmp $tmpC | sed '1s/^/Invalid cs !accounts:\
/'

hosts -l -v cs | hosts - -v acct | sort > $tmp
comm -12 $tmp $tmpX | sed '1s/^/Invalid !cs !accounts:\
/'
