1#!/bin/sh 2## 3## install.sh -- install a program, script or datafile 4## 5## Based on `install-sh' from the X Consortium's X11R5 distribution 6## as of 89/12/18 which is freely available. 7## Cleaned up for Apache's Autoconf-style Interface (APACI) 8## by Ralf S. Engelschall <rse@apache.org> 9## 10 11# 12# put in absolute paths if you don't have them in your path; 13# or use env. vars. 14# 15mvprog="${MVPROG-mv}" 16cpprog="${CPPROG-cp}" 17chmodprog="${CHMODPROG-chmod}" 18chownprog="${CHOWNPROG-chown}" 19chgrpprog="${CHGRPPROG-chgrp}" 20stripprog="${STRIPPROG-strip}" 21rmprog="${RMPROG-rm}" 22 23# 24# parse argument line 25# 26instcmd="$mvprog" 27chmodcmd="" 28chowncmd="" 29chgrpcmd="" 30stripcmd="" 31rmcmd="$rmprog -f" 32mvcmd="$mvprog" 33src="" 34dst="" 35while [ ".$1" != . ]; do 36 case $1 in 37 -c) instcmd="$cpprog" 38 shift; continue 39 ;; 40 -m) chmodcmd="$chmodprog $2" 41 shift; shift; continue 42 ;; 43 -o) chowncmd="$chownprog $2" 44 shift; shift; continue 45 ;; 46 -g) chgrpcmd="$chgrpprog $2" 47 shift; shift; continue 48 ;; 49 -s) stripcmd="$stripprog" 50 shift; continue;; 51 *) if [ ".$src" = . ]; then 52 src=$1 53 else 54 dst=$1 55 fi 56 shift; continue 57 ;; 58 esac 59done 60if [ ".$src" = . ]; then 61 echo "install.sh: no input file specified" 62 exit 1 63fi 64if [ ".$dst" = . ]; then 65 echo "install.sh: no destination specified" 66 exit 1 67fi 68 69# 70# If destination is a directory, append the input filename; if 71# your system does not like double slashes in filenames, you may 72# need to add some logic 73# 74if [ -d $dst ]; then 75 dst="$dst/`basename $src`" 76fi 77 78# Make a temp file name in the proper directory. 79dstdir=`dirname $dst` 80dsttmp=$dstdir/#inst.$$# 81 82# Move or copy the file name to the temp name 83$instcmd $src $dsttmp 84 85# And set any options; do chmod last to preserve setuid bits 86if [ ".$chowncmd" != . ]; then $chowncmd $dsttmp; fi 87if [ ".$chgrpcmd" != . ]; then $chgrpcmd $dsttmp; fi 88if [ ".$stripcmd" != . ]; then $stripcmd $dsttmp; fi 89if [ ".$chmodcmd" != . ]; then $chmodcmd $dsttmp; fi 90 91# Now rename the file to the real destination. 92$rmcmd $dst 93$mvcmd $dsttmp $dst 94 95exit 0 96 97