#!/sbin/sh # # CDDL HEADER START # # The contents of this file are subject to the terms of the # Common Development and Distribution License, Version 1.0 only # (the "License"). You may not use this file except in compliance # with the License. # # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE # or http://www.opensolaris.org/os/licensing. # See the License for the specific language governing permissions # and limitations under the License. # # When distributing Covered Code, include this CDDL HEADER in each # file and include the License file at usr/src/OPENSOLARIS.LICENSE. # If applicable, add the following below this CDDL HEADER, with the # fields enclosed by brackets "[]" replaced with your own identifying # information: Portions Copyright [yyyy] [name of copyright owner] # # CDDL HEADER END # # Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T # All Rights Reserved #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.12.1.1 */ # INSTALL COMMAND setvar FLIST = "$ROOT/etc/syslist" setvar DEFAULT = ""$ROOT/bin $ROOT/usr/bin $ROOT/etc $ROOT/lib $ROOT/usr/lib"," FOUND = "","" MOVOLD = """" setvar ECHO = 'echo', PATH = '/usr/bin', FLAG = 'off' setvar USAGE = ""eval echo 'usage: install [options] file [dir1 ...]'; exit 2"" if test $Argc -lt 2 { $USAGE } setvar MFLAG = 'off' setvar UFLAG = 'off' setvar GFLAG = 'off' setvar MODE = '755' setvar GRP = $(expr "\`id\`" : ".*gid=[0-9]*(\(..*\)) .*) setvar GROUP = $(echo $GRP | sed -e 's/) fsid.*//p) setvar OWN = $(expr "\`id\`" : ".*uid=[0-9]*(\(..*\)) .*) setvar OWNER = $(echo $OWN | sed -e 's/) .*//p) if test -z $GROUP { setvar GROUP = $(expr "\`id\`" : ".*gid=\([0-9]*\).*) } if test -z $OWNER { setvar OWNER = $(expr "\`id\`" : ".*uid=\([0-9]*\).*) } if test $OWNER = root { setvar ROOTFLAG = 'on' setvar OWNER = 'bin' setvar GROUP = 'bin' } else { setvar ROOTFLAG = 'off' } for i in [$ifsjoin(ARGV)] { if test $FLAG = on { match $i { with -* echo "install: The -c, -f, -n options each require a directory following!" exit 2 with * setvar FLAG = 'off' continue } } match $i { with -c if test x$ARG = x-d -o x$ARG = x-f { echo "install: -c dir: illegal option with $ARG option!" exit 2 } elif test x$arg = x-i -o x$arg = x-o -o x$arg = x-n { echo "install: -c dir: illegal option with $arg option!" exit 2 } elif test $Argc -lt 3 { echo "install: -c option must have at least 3 args!" exit 2 } else { setvar direct = "$2" setvar FLAG = 'on' setvar ARG = '-c' shift; shift } with -f if test x$ARG = x-d -o x$ARG = x-c { echo "install: -f dir: illegal option with $ARG option!" exit 2 } elif test x$arg = x-i -o x$arg = x-n { echo "install: -f dir: illegal option with $arg option!" exit 2 } elif test $Argc -lt 3 { echo "install: -f option must have at least 3 args!" exit 2 } else { setvar direct = "$2" setvar FLAG = 'on' setvar ARG = '-f' shift; shift } with -i if test x$ARG = x-d -o x$ARG = x-c -o x$ARG = x-f { echo "install: -i: illegal option with $ARG option!" exit 2 } elif test $Argc -lt 3 { echo "install: -i option requires at least 3 args!" exit 2 } else { setvar DEFAULT = """" setvar arg = '-i' shift } with -o if test x$ARG = x-d -o x$ARG = x-c { echo "install: -o: illegal option with $ARG option!" exit 2 } elif test $Argc -lt 2 { $USAGE } else { setvar MOVOLD = 'yes' setvar arg = '-o' shift } with -n if test x$ARG = x-d -o x$ARG = x-c -o x$ARG = x-f { echo "install: -n dir: illegal option with $ARG option!" exit 2 } elif test $Argc -lt 3 { echo "install: -n option requires at least 3 args!" exit 2 } else { setvar LASTRES = "$2" setvar FLAG = 'on' setvar FOUND = 'n' setvar arg = '-n' shift; shift } with -d if test x$ARG = x-c -o x$ARG = x-f { echo "install: -d: illegal option with $ARG option!" exit 2 } elif test x$arg = x-i -o x$arg = x-o -o x$arg = x-n { echo "install: -d: illegal option with $arg option!" exit 2 } else { setvar ARG = '-d' shift } with -s if test $Argc -lt 2 { $USAGE } else { setvar ECHO = ':' shift } with -u if test $ROOTFLAG = off { echo "install: -u option available only to root -- ignored" } else { setvar OWNER = "$2" setvar UFLAG = 'on' $ECHO new owner is $OWNER } setvar FLAG = 'on' shift; shift with -g if test $ROOTFLAG = off { echo "install: -g option available only to root -- ignored" } else { setvar GROUP = "$2" setvar GFLAG = 'on' } setvar FLAG = 'on' shift; shift with -m setvar MODE = "$2" setvar MFLAG = 'on' setvar FLAG = 'on' shift; shift with * break } } if test x$ARG = x-d { if test ! -d $i { mkdir -p $i if test $Status = 0 { $ECHO "directory $i created" chgrp $GROUP $i chown $OWNER $i chmod $MODE $i } else { echo "install: mkdir $i failed " } } else { chgrp $GROUP $i chown $OWNER $i chmod $MODE $i } exit } setvar FILEP = "$i", FILE = $(echo $i | sed -e "s/.*\///) if test x$ARG = x-c -o x$ARG = x-f { match $2 { with -* $USAGE with "" : } if test -f $direct/$FILE -o -f $direct/$FILE/$FILE { match $ARG { with -c echo "install: $FILE already exists in $direct" exit 2 with -f setvar GRP = $(ls -l $direct/$FILE | awk '{print $4}) setvar OWN = $(ls -l $direct/$FILE | awk '{print $3}) if test $MOVOLD = yes { mv -f $direct/$FILE $direct/OLD$FILE cp $direct/OLD$FILE $direct/$FILE if test $Status = 0 { $ECHO "$FILE moved to $direct/OLD$FILE" } else { echo "install: mv $direct/OLD$FILE $direct/$FILE failed" exit 2 } } if cp $FILEP $direct/$FILE { chgrp $GRP $direct/$FILE chown $OWN $direct/$FILE if test $GFLAG = on { chgrp $GROUP $direct/$FILE } if test $MFLAG = on { chmod $MODE $direct/$FILE } if test $UFLAG = on { chown $OWNER $direct/$FILE } $ECHO "$FILEP installed as $direct/$FILE" } else { echo "install: cp $FILEP $direct/$FILE failed " exit 2 } exit } } else { cp $FILEP $direct/$FILE if test $Status = 0 { $ECHO "$FILEP installed as $direct/$FILE" chgrp $GROUP $direct/$FILE chown $OWNER $direct/$FILE chmod $MODE $direct/$FILE } else { echo "install: cp $FILEP $direct/$FILE failed " exit 2 } } exit } shift setvar PUTHERE = """" for i in [$ifsjoin(ARGV)] { match $i { with -* $USAGE } setvar PUTHOLD = $(find $i -follow -name $FILE -type f -print) setvar PUTHERE = $(expr "\`echo $PUTHOLD\`" : '\([^ ]*\)) if test $PUTHERE != "" { break } } if test -r $FLIST -a $PUTHERE = "" { setvar PUTHERE = $(grep "/${FILE}$" $FLIST | sed -n -e '1p) if test $PUTHERE != "" -a $ROOT != "" { setvar PUTHERE = "${ROOT}${PUTHERE}" } } if test $PUTHERE = "" { for i in [$DEFAULT] { setvar PUTHOLD = $(find $i -follow -name $FILE -type f -print) setvar PUTHERE = $(expr "\`echo $PUTHOLD\`" : '\([^ ]*\)) if test $PUTHERE != "" { break } } } if test $PUTHERE != "" { setvar GRP = $(ls -l $PUTHERE | awk '{print $4}) setvar OWN = $(ls -l $PUTHERE | awk '{print $3}) if test $MOVOLD = yes { setvar old = $(echo $PUTHERE | sed -e "s/\/[^\/]*$//) mv -f $PUTHERE $old/OLD$FILE cp $old/OLD$FILE $PUTHERE if test $Status = 0 { $ECHO "old $FILE moved to $old/OLD$FILE" } else { echo "install: cp $direct/OLD$FILE $direct/$FILE failed" exit 2 } } setvar FOUND = 'y' if cp $FILEP $PUTHERE { chgrp $GRP $PUTHERE chown $OWN $PUTHERE if test $GFLAG = on { chgrp $GROUP $PUTHERE } if test $MFLAG = on { chmod $MODE $PUTHERE } if test $UFLAG = on { chown $OWNER $PUTHERE } $ECHO "$FILEP installed as $PUTHERE" break } else { exit 2 } } match $FOUND { with "" echo "install: $FILE was not found anywhere!" exit 2 with y : with n cp $FILEP $LASTRES/$FILE if test $Status = 0 { $ECHO "$FILEP installed as $LASTRES/$FILE by default!" cd $LASTRES chgrp $GROUP $FILE chown $OWNER $FILE chmod $MODE $FILE } else { echo "install: cp $FILEP $LASTRES/$FILE failed" exit 2 } }