xref: /minix3/crypto/external/bsd/openssl/dist/util/install.sh (revision ebfedea0ce5bbe81e252ddf32d732e40fb633fae)
1*ebfedea0SLionel Sambuc#!/bin/sh
2*ebfedea0SLionel Sambuc#
3*ebfedea0SLionel Sambuc# install - install a program, script, or datafile
4*ebfedea0SLionel Sambuc# This comes from X11R5; it is not part of GNU.
5*ebfedea0SLionel Sambuc#
6*ebfedea0SLionel Sambuc# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
7*ebfedea0SLionel Sambuc#
8*ebfedea0SLionel Sambuc# This script is compatible with the BSD install script, but was written
9*ebfedea0SLionel Sambuc# from scratch.
10*ebfedea0SLionel Sambuc#
11*ebfedea0SLionel Sambuc
12*ebfedea0SLionel Sambuc
13*ebfedea0SLionel Sambuc# set DOITPROG to echo to test this script
14*ebfedea0SLionel Sambuc
15*ebfedea0SLionel Sambucdoit="${DOITPROG:-}"
16*ebfedea0SLionel Sambuc
17*ebfedea0SLionel Sambuc
18*ebfedea0SLionel Sambuc# put in absolute paths if you don't have them in your path; or use env. vars.
19*ebfedea0SLionel Sambuc
20*ebfedea0SLionel Sambucmvprog="${MVPROG:-mv}"
21*ebfedea0SLionel Sambuccpprog="${CPPROG:-cp}"
22*ebfedea0SLionel Sambucchmodprog="${CHMODPROG:-chmod}"
23*ebfedea0SLionel Sambucchownprog="${CHOWNPROG:-chown}"
24*ebfedea0SLionel Sambucchgrpprog="${CHGRPPROG:-chgrp}"
25*ebfedea0SLionel Sambucstripprog="${STRIPPROG:-strip}"
26*ebfedea0SLionel Sambucrmprog="${RMPROG:-rm}"
27*ebfedea0SLionel Sambuc
28*ebfedea0SLionel Sambucinstcmd="$mvprog"
29*ebfedea0SLionel Sambucchmodcmd=""
30*ebfedea0SLionel Sambucchowncmd=""
31*ebfedea0SLionel Sambucchgrpcmd=""
32*ebfedea0SLionel Sambucstripcmd=""
33*ebfedea0SLionel Sambucrmcmd="$rmprog -f"
34*ebfedea0SLionel Sambucsrc=""
35*ebfedea0SLionel Sambucdst=""
36*ebfedea0SLionel Sambuc
37*ebfedea0SLionel Sambucwhile [ x"$1" != x ]; do
38*ebfedea0SLionel Sambuc    case $1 in
39*ebfedea0SLionel Sambuc	-c) instcmd="$cpprog"
40*ebfedea0SLionel Sambuc	    shift
41*ebfedea0SLionel Sambuc	    continue;;
42*ebfedea0SLionel Sambuc
43*ebfedea0SLionel Sambuc	-m) chmodcmd="$chmodprog $2"
44*ebfedea0SLionel Sambuc	    shift
45*ebfedea0SLionel Sambuc	    shift
46*ebfedea0SLionel Sambuc	    continue;;
47*ebfedea0SLionel Sambuc
48*ebfedea0SLionel Sambuc	-o) chowncmd="$chownprog $2"
49*ebfedea0SLionel Sambuc	    shift
50*ebfedea0SLionel Sambuc	    shift
51*ebfedea0SLionel Sambuc	    continue;;
52*ebfedea0SLionel Sambuc
53*ebfedea0SLionel Sambuc	-g) chgrpcmd="$chgrpprog $2"
54*ebfedea0SLionel Sambuc	    shift
55*ebfedea0SLionel Sambuc	    shift
56*ebfedea0SLionel Sambuc	    continue;;
57*ebfedea0SLionel Sambuc
58*ebfedea0SLionel Sambuc	-s) stripcmd="$stripprog"
59*ebfedea0SLionel Sambuc	    shift
60*ebfedea0SLionel Sambuc	    continue;;
61*ebfedea0SLionel Sambuc
62*ebfedea0SLionel Sambuc	*)  if [ x"$src" = x ]
63*ebfedea0SLionel Sambuc	    then
64*ebfedea0SLionel Sambuc		src=$1
65*ebfedea0SLionel Sambuc	    else
66*ebfedea0SLionel Sambuc		dst=$1
67*ebfedea0SLionel Sambuc	    fi
68*ebfedea0SLionel Sambuc	    shift
69*ebfedea0SLionel Sambuc	    continue;;
70*ebfedea0SLionel Sambuc    esac
71*ebfedea0SLionel Sambucdone
72*ebfedea0SLionel Sambuc
73*ebfedea0SLionel Sambucif [ x"$src" = x ]
74*ebfedea0SLionel Sambucthen
75*ebfedea0SLionel Sambuc	echo "install:  no input file specified"
76*ebfedea0SLionel Sambuc	exit 1
77*ebfedea0SLionel Sambucfi
78*ebfedea0SLionel Sambuc
79*ebfedea0SLionel Sambucif [ x"$dst" = x ]
80*ebfedea0SLionel Sambucthen
81*ebfedea0SLionel Sambuc	echo "install:  no destination specified"
82*ebfedea0SLionel Sambuc	exit 1
83*ebfedea0SLionel Sambucfi
84*ebfedea0SLionel Sambuc
85*ebfedea0SLionel Sambuc
86*ebfedea0SLionel Sambuc# if destination is a directory, append the input filename; if your system
87*ebfedea0SLionel Sambuc# does not like double slashes in filenames, you may need to add some logic
88*ebfedea0SLionel Sambuc
89*ebfedea0SLionel Sambucif [ -d $dst ]
90*ebfedea0SLionel Sambucthen
91*ebfedea0SLionel Sambuc	dst="$dst"/`basename $src`
92*ebfedea0SLionel Sambucfi
93*ebfedea0SLionel Sambuc
94*ebfedea0SLionel Sambuc
95*ebfedea0SLionel Sambuc# get rid of the old one and mode the new one in
96*ebfedea0SLionel Sambuc
97*ebfedea0SLionel Sambuc$doit $rmcmd $dst
98*ebfedea0SLionel Sambuc$doit $instcmd $src $dst
99*ebfedea0SLionel Sambuc
100*ebfedea0SLionel Sambuc
101*ebfedea0SLionel Sambuc# and set any options; do chmod last to preserve setuid bits
102*ebfedea0SLionel Sambuc
103*ebfedea0SLionel Sambucif [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; fi
104*ebfedea0SLionel Sambucif [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; fi
105*ebfedea0SLionel Sambucif [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; fi
106*ebfedea0SLionel Sambucif [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; fi
107*ebfedea0SLionel Sambuc
108*ebfedea0SLionel Sambucexit 0
109