xref: /illumos-gate/usr/src/cmd/bnu/Uutry (revision 7c478bd9)
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#ident	"%Z%%M%	%I%	%E% SMI"	/* from SVR4 bnu:Uutry 2.6.1.8 */
24*7c478bd9Sstevel@tonic-gateexport IFS PATH
25*7c478bd9Sstevel@tonic-gateIFS="
26*7c478bd9Sstevel@tonic-gate"
27*7c478bd9Sstevel@tonic-gatePATH="/usr/bin"
28*7c478bd9Sstevel@tonic-gate
29*7c478bd9Sstevel@tonic-gate#	This shell will start a uucico for the system given.
30*7c478bd9Sstevel@tonic-gate#	Options:
31*7c478bd9Sstevel@tonic-gate#	  -xN the debugging level for uucico (-x5 default)
32*7c478bd9Sstevel@tonic-gate#	  -r  force the removal of the status file
33*7c478bd9Sstevel@tonic-gate#	The output is put in /tmp/Name where Name is the name
34*7c478bd9Sstevel@tonic-gate#	of the system name.  A tail -f is performed after uucico is started.
35*7c478bd9Sstevel@tonic-gate
36*7c478bd9Sstevel@tonic-gateSTATUS=/var/uucp/.Status
37*7c478bd9Sstevel@tonic-gate
38*7c478bd9Sstevel@tonic-gateUUCICO=/usr/lib/uucp/uucico
39*7c478bd9Sstevel@tonic-gatetty -s
40*7c478bd9Sstevel@tonic-gateif [ "`pwd`" != "/usr/lib/uucp" -a "$?" = 0 -a -x "./uucico" ]; then
41*7c478bd9Sstevel@tonic-gate	echo "OK to execute uucico from current directory (`pwd`)? y or n? \c"
42*7c478bd9Sstevel@tonic-gate	read ans
43*7c478bd9Sstevel@tonic-gate	if [ "$ans" = "y" ]
44*7c478bd9Sstevel@tonic-gate	    then
45*7c478bd9Sstevel@tonic-gate		UUCICO=./uucico
46*7c478bd9Sstevel@tonic-gate	fi
47*7c478bd9Sstevel@tonic-gatefi
48*7c478bd9Sstevel@tonic-gate
49*7c478bd9Sstevel@tonic-gateREMOVE=""
50*7c478bd9Sstevel@tonic-gateX="-x5"
51*7c478bd9Sstevel@tonic-gateSYS=
52*7c478bd9Sstevel@tonic-gatewhile [ $# -gt 0 ]
53*7c478bd9Sstevel@tonic-gatedo
54*7c478bd9Sstevel@tonic-gate	case $1 in
55*7c478bd9Sstevel@tonic-gate	-c)  shift; CLASS="-c$1"; shift;;
56*7c478bd9Sstevel@tonic-gate	-c*) CLASS="$1"; shift;;
57*7c478bd9Sstevel@tonic-gate	-x)  shift; X="-x$1"; shift;;
58*7c478bd9Sstevel@tonic-gate	-x*) X=$1; shift;;
59*7c478bd9Sstevel@tonic-gate	-r) REMOVE="-f"; shift;;
60*7c478bd9Sstevel@tonic-gate	-?) echo "$0: unrecognized flag $1\nUSAGE: $0 [-r] [-xdebug_level] system";exit 1;;
61*7c478bd9Sstevel@tonic-gate	*) SYS="$1"; shift;;
62*7c478bd9Sstevel@tonic-gate	esac
63*7c478bd9Sstevel@tonic-gatedone
64*7c478bd9Sstevel@tonic-gate
65*7c478bd9Sstevel@tonic-gateif [ -z "$SYS" ]
66*7c478bd9Sstevel@tonic-gatethen
67*7c478bd9Sstevel@tonic-gate	echo "$0:  system name required"
68*7c478bd9Sstevel@tonic-gate	exit 1
69*7c478bd9Sstevel@tonic-gatefi
70*7c478bd9Sstevel@tonic-gate
71*7c478bd9Sstevel@tonic-gate#  check for existence in Systems file
72*7c478bd9Sstevel@tonic-gate#  only accept match of full name
73*7c478bd9Sstevel@tonic-gate#  (important because some names may be prefixes of others!)
74*7c478bd9Sstevel@tonic-gateXX=
75*7c478bd9Sstevel@tonic-gateXX=`uuname | grep "^${SYS}$" `
76*7c478bd9Sstevel@tonic-gateif [ -z "$XX" ]
77*7c478bd9Sstevel@tonic-gatethen
78*7c478bd9Sstevel@tonic-gate	echo "Invalid system name \"$SYS\""
79*7c478bd9Sstevel@tonic-gate	exit
80*7c478bd9Sstevel@tonic-gatefi
81*7c478bd9Sstevel@tonic-gate
82*7c478bd9Sstevel@tonic-gateSTMP=/tmp/$SYS
83*7c478bd9Sstevel@tonic-gaterm -f $STMP
84*7c478bd9Sstevel@tonic-gate> $STMP
85*7c478bd9Sstevel@tonic-gatechmod 622 $STMP
86*7c478bd9Sstevel@tonic-gate#  remove old status file (can't actually remove, since $STATUS isn't
87*7c478bd9Sstevel@tonic-gate#  publicly writable, but zero-ing it out works fine)
88*7c478bd9Sstevel@tonic-gateif [ -n "$REMOVE" ]; then
89*7c478bd9Sstevel@tonic-gate    cp /dev/null $STATUS/${SYS} 2>/dev/null
90*7c478bd9Sstevel@tonic-gatefi
91*7c478bd9Sstevel@tonic-gate
92*7c478bd9Sstevel@tonic-gateecho "$UUCICO -r1 -s$SYS $CLASS $REMOVE $X >$STMP 2>&1&"
93*7c478bd9Sstevel@tonic-gate$UUCICO  -r1 -s$SYS $CLASS $REMOVE $X >$STMP 2>&1&
94*7c478bd9Sstevel@tonic-gate
95*7c478bd9Sstevel@tonic-gateecho "tmp=$STMP"
96*7c478bd9Sstevel@tonic-gate#	on heavily loaded systems, may take a moment for uucico
97*7c478bd9Sstevel@tonic-gate#	to create debug file.
98*7c478bd9Sstevel@tonic-gateif [ ! -f $STMP ]
99*7c478bd9Sstevel@tonic-gatethen
100*7c478bd9Sstevel@tonic-gate	sleep 5
101*7c478bd9Sstevel@tonic-gatefi
102*7c478bd9Sstevel@tonic-gatetail -f $STMP
103