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