1*20006a0bStron#!/bin/sh 2*20006a0bStron 3*20006a0bStron# 4*20006a0bStron# install - install a program, script, or datafile 5*20006a0bStron# This comes from X11R5; it is not part of GNU. 6*20006a0bStron# 7*20006a0bStron# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $ 8*20006a0bStron# 9*20006a0bStron# This script is compatible with the BSD install script, but was written 10*20006a0bStron# from scratch. 11*20006a0bStron# 12*20006a0bStron 13*20006a0bStron 14*20006a0bStron# set DOITPROG to echo to test this script 15*20006a0bStron 16*20006a0bStron# Don't use :- since 4.3BSD and earlier shells don't like it. 17*20006a0bStrondoit="${DOITPROG-}" 18*20006a0bStron 19*20006a0bStron 20*20006a0bStron# put in absolute paths if you don't have them in your path; or use env. vars. 21*20006a0bStron 22*20006a0bStronmvprog="${MVPROG-mv}" 23*20006a0bStroncpprog="${CPPROG-cp}" 24*20006a0bStronchmodprog="${CHMODPROG-chmod}" 25*20006a0bStronchownprog="${CHOWNPROG-chown}" 26*20006a0bStronchgrpprog="${CHGRPPROG-chgrp}" 27*20006a0bStronstripprog="${STRIPPROG-strip}" 28*20006a0bStronrmprog="${RMPROG-rm}" 29*20006a0bStron 30*20006a0bStroninstcmd="$mvprog" 31*20006a0bStronchmodcmd="" 32*20006a0bStronchowncmd="" 33*20006a0bStronchgrpcmd="" 34*20006a0bStronstripcmd="" 35*20006a0bStronrmcmd="$rmprog -f" 36*20006a0bStronmvcmd="$mvprog" 37*20006a0bStronsrc="" 38*20006a0bStrondst="" 39*20006a0bStron 40*20006a0bStronwhile [ x"$1" != x ]; do 41*20006a0bStron case $1 in 42*20006a0bStron -c) instcmd="$cpprog" 43*20006a0bStron shift 44*20006a0bStron continue;; 45*20006a0bStron 46*20006a0bStron -m) chmodcmd="$chmodprog $2" 47*20006a0bStron shift 48*20006a0bStron shift 49*20006a0bStron continue;; 50*20006a0bStron 51*20006a0bStron -o) chowncmd="$chownprog $2" 52*20006a0bStron shift 53*20006a0bStron shift 54*20006a0bStron continue;; 55*20006a0bStron 56*20006a0bStron -g) chgrpcmd="$chgrpprog $2" 57*20006a0bStron shift 58*20006a0bStron shift 59*20006a0bStron continue;; 60*20006a0bStron 61*20006a0bStron -s) stripcmd="$stripprog" 62*20006a0bStron shift 63*20006a0bStron continue;; 64*20006a0bStron 65*20006a0bStron *) if [ x"$src" = x ] 66*20006a0bStron then 67*20006a0bStron src=$1 68*20006a0bStron else 69*20006a0bStron dst=$1 70*20006a0bStron fi 71*20006a0bStron shift 72*20006a0bStron continue;; 73*20006a0bStron esac 74*20006a0bStrondone 75*20006a0bStron 76*20006a0bStronif [ x"$src" = x ] 77*20006a0bStronthen 78*20006a0bStron echo "install: no input file specified" 79*20006a0bStron exit 1 80*20006a0bStronfi 81*20006a0bStron 82*20006a0bStronif [ x"$dst" = x ] 83*20006a0bStronthen 84*20006a0bStron echo "install: no destination specified" 85*20006a0bStron exit 1 86*20006a0bStronfi 87*20006a0bStron 88*20006a0bStron 89*20006a0bStron# If destination is a directory, append the input filename; if your system 90*20006a0bStron# does not like double slashes in filenames, you may need to add some logic 91*20006a0bStron 92*20006a0bStronif [ -d $dst ] 93*20006a0bStronthen 94*20006a0bStron dst="$dst"/`basename $src` 95*20006a0bStronfi 96*20006a0bStron 97*20006a0bStron# Make a temp file name in the proper directory. 98*20006a0bStron 99*20006a0bStrondstdir=`dirname $dst` 100*20006a0bStrondsttmp=$dstdir/_inst.$$_ 101*20006a0bStron 102*20006a0bStron# Move or copy the file name to the temp name 103*20006a0bStron 104*20006a0bStron$doit $instcmd $src $dsttmp 105*20006a0bStron 106*20006a0bStron# and set any options; do chmod last to preserve setuid bits 107*20006a0bStron 108*20006a0bStronif [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; fi 109*20006a0bStronif [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; fi 110*20006a0bStronif [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; fi 111*20006a0bStronif [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; fi 112*20006a0bStron 113*20006a0bStron# Now rename the file to the real destination. 114*20006a0bStron 115*20006a0bStron$doit $rmcmd $dst 116*20006a0bStron$doit $mvcmd $dsttmp $dst 117*20006a0bStron 118*20006a0bStron 119*20006a0bStronexit 0 120