xref: /onnv-gate/usr/src/cmd/bnu/Cvt (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!/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#
24*0Sstevel@tonic-gate# Copyright 1988 Sun Microsystems, Inc.  All rights reserved.
25*0Sstevel@tonic-gate# Use is subject to license terms.
26*0Sstevel@tonic-gate#
27*0Sstevel@tonic-gate#ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate
29*0Sstevel@tonic-gate# NOTE:	This script has probably outlived its usefulness, but in
30*0Sstevel@tonic-gate#	case it hasn't, it still references "old" pathnames,
31*0Sstevel@tonic-gate#	allowing it to work on any system.
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gate#	execute this as root and in the /usr/spool/uucp directory.
34*0Sstevel@tonic-gate#	execute
35*0Sstevel@tonic-gate#	    Cvt
36*0Sstevel@tonic-gate#	This will create required directories and move the
37*0Sstevel@tonic-gate#	C. and D. files to the proper place.
38*0Sstevel@tonic-gate#
39*0Sstevel@tonic-gate#	use this after running the SetUp script.
40*0Sstevel@tonic-gate#
41*0Sstevel@tonic-gate#	use -n option to tell what will be done, but without doing it
42*0Sstevel@tonic-gate#
43*0Sstevel@tonic-gate# NOTE!!
44*0Sstevel@tonic-gate#	It does not take care of X. files yet.
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gateset +e
47*0Sstevel@tonic-gateSPOOL=/usr/spool/uucp
48*0Sstevel@tonic-gateTMP=/tmp/CVT
49*0Sstevel@tonic-gate
50*0Sstevel@tonic-gateNC=`ls $SPOOL/C. | grep -c "^C."`
51*0Sstevel@tonic-gateif [ $NC -eq 0 ]
52*0Sstevel@tonic-gatethen
53*0Sstevel@tonic-gate  echo "There are no old C. files in /usr/spool/uucp/C."
54*0Sstevel@tonic-gate  echo "exiting"
55*0Sstevel@tonic-gate  exit
56*0Sstevel@tonic-gatefi
57*0Sstevel@tonic-gate
58*0Sstevel@tonic-gateecho "
59*0Sstevel@tonic-gateThis shell (Cvt) will attempt to take the old C. and D. files
60*0Sstevel@tonic-gatethat are in $SPOOL and put them in the proper directories for
61*0Sstevel@tonic-gatethe new version of uucp.
62*0Sstevel@tonic-gate
63*0Sstevel@tonic-gateIf the files are not moved, they will never get executed after the
64*0Sstevel@tonic-gatenew uucp is installed.
65*0Sstevel@tonic-gate
66*0Sstevel@tonic-gateThere are $NC C. files in $SPOOL.
67*0Sstevel@tonic-gate
68*0Sstevel@tonic-gateDo you wish to continue (Type y to continue)? \
69*0Sstevel@tonic-gate\c"
70*0Sstevel@tonic-gate
71*0Sstevel@tonic-gateread A
72*0Sstevel@tonic-gateif [ x$A != "xy" ]; then exit; fi
73*0Sstevel@tonic-gate
74*0Sstevel@tonic-gatewhile [ $# -gt 0 ]
75*0Sstevel@tonic-gatedo
76*0Sstevel@tonic-gate	case $1 in
77*0Sstevel@tonic-gate	-n)	ECHO=echo
78*0Sstevel@tonic-gate		shift
79*0Sstevel@tonic-gate		;;
80*0Sstevel@tonic-gate
81*0Sstevel@tonic-gate	*)	break
82*0Sstevel@tonic-gate		;;
83*0Sstevel@tonic-gate
84*0Sstevel@tonic-gate	esac
85*0Sstevel@tonic-gatedone
86*0Sstevel@tonic-gate
87*0Sstevel@tonic-gatecd $SPOOL/C.
88*0Sstevel@tonic-gatefor i in C*
89*0Sstevel@tonic-gatedo
90*0Sstevel@tonic-gate# S is the 6 character system name
91*0Sstevel@tonic-gate# E is the last 5 characters of C. name
92*0Sstevel@tonic-gate
93*0Sstevel@tonic-gate  echo Processing: $i
94*0Sstevel@tonic-gate  S=`echo $i | sed "s/..\(.*\)....../\1/"`
95*0Sstevel@tonic-gate  E=`echo $i | sed "s/.*\(.....\)/\1/"`
96*0Sstevel@tonic-gate  DIR=
97*0Sstevel@tonic-gate  DIR=`uuname | grep "^$S"`
98*0Sstevel@tonic-gate  if [ -z "$DIR" ]
99*0Sstevel@tonic-gate  then
100*0Sstevel@tonic-gate	echo "*****Warning: There is no system=$S in the /etc/uucp/Systems file. ******"
101*0Sstevel@tonic-gate	DIR=$S
102*0Sstevel@tonic-gate  fi
103*0Sstevel@tonic-gate  DIR=`echo $DIR | sed "s/ .*//"`
104*0Sstevel@tonic-gate  if [ ! -d $SPOOL/$DIR ]
105*0Sstevel@tonic-gate	then
106*0Sstevel@tonic-gate	    $ECHO  mkdir $SPOOL/$DIR
107*0Sstevel@tonic-gate	    $ECHO  chmod 755 $SPOOL/$DIR
108*0Sstevel@tonic-gate	    $ECHO  chown uucp $SPOOL/$DIR
109*0Sstevel@tonic-gate  fi
110*0Sstevel@tonic-gate
111*0Sstevel@tonic-gate    cat $i | while read AA ; do
112*0Sstevel@tonic-gate	D=`echo $AA | cut -d" " -f6`
113*0Sstevel@tonic-gate	if [ -n "$D" -a -f "$SPOOL/D./$D" ]
114*0Sstevel@tonic-gate	    then $ECHO mv $SPOOL/D./$D $SPOOL/$DIR/$D
115*0Sstevel@tonic-gate	elif [ -n "$D" -a -f "$SPOOL/D.`uuname -l`/$D" ]
116*0Sstevel@tonic-gate	    then $ECHO mv $SPOOL/D.`uuname -l`/$D $SPOOL/$DIR/$D
117*0Sstevel@tonic-gate	fi
118*0Sstevel@tonic-gate    done
119*0Sstevel@tonic-gate    S=`echo $DIR | sed "s/\(.......\).*/\1/"`
120*0Sstevel@tonic-gate    $ECHO mv $i $SPOOL/$DIR/C.$S$E
121*0Sstevel@tonic-gate
122*0Sstevel@tonic-gatedone
123