xref: /titanic_52/usr/src/cmd/bnu/uudemon.admin (revision 269e59f9a28bf47e0f463e64fc5af4a408b73b21)
1#!/usr/bin/sh
2#
3# CDDL HEADER START
4#
5# The contents of this file are subject to the terms of the
6# Common Development and Distribution License, Version 1.0 only
7# (the "License").  You may not use this file except in compliance
8# with the License.
9#
10# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11# or http://www.opensolaris.org/os/licensing.
12# See the License for the specific language governing permissions
13# and limitations under the License.
14#
15# When distributing Covered Code, include this CDDL HEADER in each
16# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17# If applicable, add the following below this CDDL HEADER, with the
18# fields enclosed by brackets "[]" replaced with your own identifying
19# information: Portions Copyright [yyyy] [name of copyright owner]
20#
21# CDDL HEADER END
22#
23#
24# Copyright 1997 Sun Microsystems, Inc.  All rights reserved.
25# Use is subject to license terms.
26#
27#ident	"%Z%%M%	%I%	%E% SMI"
28#
29#	This shell sends uucp status information to an administrator.
30#	It should be started by a line in /var/spool/cron/crontabs/uucp.
31#	e.g.
32#
33# 48 8,12,16 * * * /etc/uucp/uudemon.admin
34#
35
36# return a list of systems defined in /etc/uucp/Systems
37getsystems() {
38if [ ! -f /etc/uucp/Systems ]; then
39  return
40else
41  awk '$1 !~ /^#/ {print $1}' /etc/uucp/Systems
42fi
43}
44
45# return a list of systems defined in /etc/asppp.cf
46getpppsystems() {
47if [ ! -f /etc/asppp.cf ]; then
48  return
49else
50  X=`sed -e 's/#.*$//' /etc/asppp.cf`
51  set -- $X
52  while [ $# -ne 0 ];
53  do
54      if [ "$1" = "peer_system_name" ]; then
55          PPPSYSTEMS="$PPPSYSTEMS $2"
56      fi
57      shift
58  done
59  echo "$PPPSYSTEMS"
60fi
61}
62
63nouucp()
64{
65# run through the systems list, deleting ppp systems
66outstr=""
67for i in `getsystems`
68do
69    del=0
70    for j in `getpppsystems`
71    do
72        if [ "$j" = "$i" ]; then
73            del=1
74        fi
75    done
76    if [ $del -ne 1 ]; then
77        outstr="$outstr $i"
78    fi
79done
80
81# if any names are in $outstr, assume uucp is configured
82
83if [ -n "$outstr" ]; then
84	return 1
85else
86	return 0
87fi
88}
89
90# Start of actual processing. For energystar compatibility,
91# we attempt to do as little I/O as possible, so first check
92# to see if uucp is configured before doing all this work.
93
94if nouucp; then
95	exit 0
96fi
97
98set +e
99
100export PATH
101PATH=/usr/bin
102MAILTO=uucp
103LOGDIR=/var/uucp/.Log
104ULOG=$LOGDIR/uucico
105TMP=/tmp/uu$$
106
107(uustat -p; uustat -q) > $TMP
108if [ -s $TMP ]
109then
110	(echo "Subject: uu-status"; echo; cat $TMP) | mail $MAILTO
111fi
112grep passwd $ULOG/* > $TMP 2> /dev/null
113if [ -s $TMP ]
114then
115	(echo "Subject: passwd check"; echo; cat $TMP) | mail $MAILTO
116fi
117rm $TMP
118