160786Sps#!/bin/sh 260786Sps 360786Sps# 460786Sps# install - install a program, script, or datafile 560786Sps# This comes from X11R5; it is not part of GNU. 660786Sps# 760786Sps# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $ 860786Sps# 960786Sps# This script is compatible with the BSD install script, but was written 1060786Sps# from scratch. 1160786Sps# 1260786Sps 1360786Sps 1460786Sps# set DOITPROG to echo to test this script 1560786Sps 1660786Sps# Don't use :- since 4.3BSD and earlier shells don't like it. 1760786Spsdoit="${DOITPROG-}" 1860786Sps 1960786Sps 2060786Sps# put in absolute paths if you don't have them in your path; or use env. vars. 2160786Sps 2260786Spsmvprog="${MVPROG-mv}" 2360786Spscpprog="${CPPROG-cp}" 2460786Spschmodprog="${CHMODPROG-chmod}" 2560786Spschownprog="${CHOWNPROG-chown}" 2660786Spschgrpprog="${CHGRPPROG-chgrp}" 2760786Spsstripprog="${STRIPPROG-strip}" 2860786Spsrmprog="${RMPROG-rm}" 2960786Sps 3060786Spsinstcmd="$mvprog" 3160786Spschmodcmd="" 3260786Spschowncmd="" 3360786Spschgrpcmd="" 3460786Spsstripcmd="" 3560786Spsrmcmd="$rmprog -f" 3660786Spsmvcmd="$mvprog" 3760786Spssrc="" 3860786Spsdst="" 3960786Sps 4060786Spswhile [ x"$1" != x ]; do 4160786Sps case $1 in 4260786Sps -c) instcmd="$cpprog" 4360786Sps shift 4460786Sps continue;; 4560786Sps 4660786Sps -m) chmodcmd="$chmodprog $2" 4760786Sps shift 4860786Sps shift 4960786Sps continue;; 5060786Sps 5160786Sps -o) chowncmd="$chownprog $2" 5260786Sps shift 5360786Sps shift 5460786Sps continue;; 5560786Sps 5660786Sps -g) chgrpcmd="$chgrpprog $2" 5760786Sps shift 5860786Sps shift 5960786Sps continue;; 6060786Sps 6160786Sps -s) stripcmd="$stripprog" 6260786Sps shift 6360786Sps continue;; 6460786Sps 6560786Sps *) if [ x"$src" = x ] 6660786Sps then 6760786Sps src=$1 6860786Sps else 6960786Sps dst=$1 7060786Sps fi 7160786Sps shift 7260786Sps continue;; 7360786Sps esac 7460786Spsdone 7560786Sps 7660786Spsif [ x"$src" = x ] 7760786Spsthen 7860786Sps echo "install: no input file specified" 7960786Sps exit 1 8060786Spsfi 8160786Sps 8260786Spsif [ x"$dst" = x ] 8360786Spsthen 8460786Sps echo "install: no destination specified" 8560786Sps exit 1 8660786Spsfi 8760786Sps 8860786Sps 8960786Sps# If destination is a directory, append the input filename; if your system 9060786Sps# does not like double slashes in filenames, you may need to add some logic 9160786Sps 9260786Spsif [ -d $dst ] 9360786Spsthen 9460786Sps dst="$dst"/`basename $src` 9560786Spsfi 9660786Sps 9760786Sps# Make a temp file name in the proper directory. 9860786Sps 9960786Spsdstdir=`dirname $dst` 100191930Sdelphijdsttmp=$dstdir/_inst.$$_ 10160786Sps 10260786Sps# Move or copy the file name to the temp name 10360786Sps 10460786Sps$doit $instcmd $src $dsttmp 10560786Sps 10660786Sps# and set any options; do chmod last to preserve setuid bits 10760786Sps 10860786Spsif [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi 10960786Spsif [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi 11060786Spsif [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi 11160786Spsif [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi 11260786Sps 11360786Sps# Now rename the file to the real destination. 11460786Sps 11560786Sps$doit $rmcmd $dst 11660786Sps$doit $mvcmd $dsttmp $dst 11760786Sps 11860786Sps 11960786Spsexit 0 120