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