#! /bin/sh
# $Id: mkulinks-all,v 1.2 1995/12/06 23:29:42 friedman Exp $
# As of 1995-06-27, this is run nightly by cron on axiom.cli.com.

PATH=/usr/etc:$PATH:/usr/lib
export PATH

# Name by which this script was invoked.
progname=`echo "$0" | sed -e 's/[^\/]*\///g'`

tmpfile="/tmp/$progname$$"

trap 'rm -f "$tmpfile"' 0 1 2 3 15

# The sed script converts whitespace between hostnames in ypmatch output
# into newlines, so that `sort' can sort and unique-ify lines.
for h in `{
            ypmatch sparc netgroup
            ypmatch solaris2 netgroup
          } | sed -ne "s/[ 	][ 	]*/ /g
                       h
                       s/.*//
                       G
                       :l
                       / /{
                         s/^\(.\)\([^ ]*\) /\1\2\1/
                         t l
                       }
                       p" \
            | sort -u`
do
  # 1995-12-06 throckmorton is unstable since we use it to test commercial
  # installations and often leave the canonical /usr/local unmounted.
  # For now, do not attempt to contact that host.
  case "$h" in
    throckmorton ) continue ;;
  esac

  if ping $h 3 > /dev/null 2>&1 ; then
    rsh $h -n /usr/local/etc/mkulinks --errors-to=stdout \
                                      --link-directory=/home \
                                      --perl=/usr/local/bin/perl \
                                      --verbose \
     2>&1 | sed -e "/^Ignoring:/d
                    s/^/[$h] /"
  fi
done > "$tmpfile" 2>&1

if test -s "$tmpfile"; then
  sendmail -oi -t < "$tmpfile" <<__EOF__
From: $progname
To: friedman, cohen
Subject: $progname output
Reply-To: friedman

This is an automated report generated on `hostname`.
To add or remove yourself from the list of recipients of this message, edit
the "To:" field in the message template at the end of the file
"$0".

`cat`
__EOF__
  fi

# eof
