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