xref: /onnv-gate/usr/src/cmd/bnu/Uutry (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/usr/bin/sh
2*0Sstevel@tonic-gate#
3*0Sstevel@tonic-gate# CDDL HEADER START
4*0Sstevel@tonic-gate#
5*0Sstevel@tonic-gate# The contents of this file are subject to the terms of the
6*0Sstevel@tonic-gate# Common Development and Distribution License, Version 1.0 only
7*0Sstevel@tonic-gate# (the "License").  You may not use this file except in compliance
8*0Sstevel@tonic-gate# with the License.
9*0Sstevel@tonic-gate#
10*0Sstevel@tonic-gate# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11*0Sstevel@tonic-gate# or http://www.opensolaris.org/os/licensing.
12*0Sstevel@tonic-gate# See the License for the specific language governing permissions
13*0Sstevel@tonic-gate# and limitations under the License.
14*0Sstevel@tonic-gate#
15*0Sstevel@tonic-gate# When distributing Covered Code, include this CDDL HEADER in each
16*0Sstevel@tonic-gate# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17*0Sstevel@tonic-gate# If applicable, add the following below this CDDL HEADER, with the
18*0Sstevel@tonic-gate# fields enclosed by brackets "[]" replaced with your own identifying
19*0Sstevel@tonic-gate# information: Portions Copyright [yyyy] [name of copyright owner]
20*0Sstevel@tonic-gate#
21*0Sstevel@tonic-gate# CDDL HEADER END
22*0Sstevel@tonic-gate#
23*0Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"	/* from SVR4 bnu:Uutry 2.6.1.8 */
24*0Sstevel@tonic-gateexport IFS PATH
25*0Sstevel@tonic-gateIFS="
26*0Sstevel@tonic-gate"
27*0Sstevel@tonic-gatePATH="/usr/bin"
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate#	This shell will start a uucico for the system given.
30*0Sstevel@tonic-gate#	Options:
31*0Sstevel@tonic-gate#	  -xN the debugging level for uucico (-x5 default)
32*0Sstevel@tonic-gate#	  -r  force the removal of the status file
33*0Sstevel@tonic-gate#	The output is put in /tmp/Name where Name is the name
34*0Sstevel@tonic-gate#	of the system name.  A tail -f is performed after uucico is started.
35*0Sstevel@tonic-gate
36*0Sstevel@tonic-gateSTATUS=/var/uucp/.Status
37*0Sstevel@tonic-gate
38*0Sstevel@tonic-gateUUCICO=/usr/lib/uucp/uucico
39*0Sstevel@tonic-gatetty -s
40*0Sstevel@tonic-gateif [ "`pwd`" != "/usr/lib/uucp" -a "$?" = 0 -a -x "./uucico" ]; then
41*0Sstevel@tonic-gate	echo "OK to execute uucico from current directory (`pwd`)? y or n? \c"
42*0Sstevel@tonic-gate	read ans
43*0Sstevel@tonic-gate	if [ "$ans" = "y" ]
44*0Sstevel@tonic-gate	    then
45*0Sstevel@tonic-gate		UUCICO=./uucico
46*0Sstevel@tonic-gate	fi
47*0Sstevel@tonic-gatefi
48*0Sstevel@tonic-gate
49*0Sstevel@tonic-gateREMOVE=""
50*0Sstevel@tonic-gateX="-x5"
51*0Sstevel@tonic-gateSYS=
52*0Sstevel@tonic-gatewhile [ $# -gt 0 ]
53*0Sstevel@tonic-gatedo
54*0Sstevel@tonic-gate	case $1 in
55*0Sstevel@tonic-gate	-c)  shift; CLASS="-c$1"; shift;;
56*0Sstevel@tonic-gate	-c*) CLASS="$1"; shift;;
57*0Sstevel@tonic-gate	-x)  shift; X="-x$1"; shift;;
58*0Sstevel@tonic-gate	-x*) X=$1; shift;;
59*0Sstevel@tonic-gate	-r) REMOVE="-f"; shift;;
60*0Sstevel@tonic-gate	-?) echo "$0: unrecognized flag $1\nUSAGE: $0 [-r] [-xdebug_level] system";exit 1;;
61*0Sstevel@tonic-gate	*) SYS="$1"; shift;;
62*0Sstevel@tonic-gate	esac
63*0Sstevel@tonic-gatedone
64*0Sstevel@tonic-gate
65*0Sstevel@tonic-gateif [ -z "$SYS" ]
66*0Sstevel@tonic-gatethen
67*0Sstevel@tonic-gate	echo "$0:  system name required"
68*0Sstevel@tonic-gate	exit 1
69*0Sstevel@tonic-gatefi
70*0Sstevel@tonic-gate
71*0Sstevel@tonic-gate#  check for existence in Systems file
72*0Sstevel@tonic-gate#  only accept match of full name
73*0Sstevel@tonic-gate#  (important because some names may be prefixes of others!)
74*0Sstevel@tonic-gateXX=
75*0Sstevel@tonic-gateXX=`uuname | grep "^${SYS}$" `
76*0Sstevel@tonic-gateif [ -z "$XX" ]
77*0Sstevel@tonic-gatethen
78*0Sstevel@tonic-gate	echo "Invalid system name \"$SYS\""
79*0Sstevel@tonic-gate	exit
80*0Sstevel@tonic-gatefi
81*0Sstevel@tonic-gate
82*0Sstevel@tonic-gateSTMP=/tmp/$SYS
83*0Sstevel@tonic-gaterm -f $STMP
84*0Sstevel@tonic-gate> $STMP
85*0Sstevel@tonic-gatechmod 622 $STMP
86*0Sstevel@tonic-gate#  remove old status file (can't actually remove, since $STATUS isn't
87*0Sstevel@tonic-gate#  publicly writable, but zero-ing it out works fine)
88*0Sstevel@tonic-gateif [ -n "$REMOVE" ]; then
89*0Sstevel@tonic-gate    cp /dev/null $STATUS/${SYS} 2>/dev/null
90*0Sstevel@tonic-gatefi
91*0Sstevel@tonic-gate
92*0Sstevel@tonic-gateecho "$UUCICO -r1 -s$SYS $CLASS $REMOVE $X >$STMP 2>&1&"
93*0Sstevel@tonic-gate$UUCICO  -r1 -s$SYS $CLASS $REMOVE $X >$STMP 2>&1&
94*0Sstevel@tonic-gate
95*0Sstevel@tonic-gateecho "tmp=$STMP"
96*0Sstevel@tonic-gate#	on heavily loaded systems, may take a moment for uucico
97*0Sstevel@tonic-gate#	to create debug file.
98*0Sstevel@tonic-gateif [ ! -f $STMP ]
99*0Sstevel@tonic-gatethen
100*0Sstevel@tonic-gate	sleep 5
101*0Sstevel@tonic-gatefi
102*0Sstevel@tonic-gatetail -f $STMP
103