source: trunk/third/sysinfo/install.sh @ 12269

Revision 12269, 2.8 KB checked in by ghudson, 26 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12268, which included commits to RCS files with non-trunk default branches.
Line 
1#!/bin/sh
2#
3# $Revision: 1.1.1.2 $
4#
5# This script implements a subset of the normal BSD install(1) program.
6# It's certainly not complete.
7#
8
9Copy=1                                  # Copy src to target
10Strip=0                                 # Strip installed target
11Group=staff                             # Default group
12Mode=0755                               # Default file mode
13dst=""
14src=""
15Prog=$0
16
17#
18# Find the locations of various commands we'll need
19#
20if [ -x /usr/bin/cp ]; then
21        cp=/usr/bin/cp
22elif [ -x /bin/cp ]; then
23        cp=/bin/cp
24else
25        echo "${Prog}: Cannot locate the cp program."
26        exit 1
27fi
28
29if [ -x /usr/bin/mv ]; then
30        mv=/usr/bin/mv
31elif [ -x /bin/mv ]; then
32        mv=/bin/mv
33else
34        echo "${Prog}: Cannot locate the mv program."
35        exit 1
36fi
37
38if [ -x /usr/bin/rm ]; then
39        rm=/usr/bin/rm
40elif [ -x /bin/rm ]; then
41        rm=/bin/rm
42else
43        echo "${Prog}: Cannot locate the rm program."
44        exit 1
45fi
46
47if [ -x /usr/bin/chmod ]; then
48        chmod=/usr/bin/chmod
49elif [ -x /bin/chmod ]; then
50        chmod=/bin/chmod
51else
52        echo "${Prog}: Cannot locate the chmod program."
53        exit 1
54fi
55
56if [ -x /usr/bin/strip ]; then
57        strip=/usr/bin/strip
58elif [ -x /bin/strip ]; then
59        strip=/bin/strip
60elif [ -x /usr/ccs/bin/strip ]; then
61        strip=/usr/ccs/bin/strip
62else
63        echo "${Prog}: Cannot locate the strip program."
64        exit 1
65fi
66
67if [ -x /usr/bin/chgrp ]; then
68        chgrp=/usr/bin/chgrp
69elif [ -x /bin/chgrp ]; then
70        chgrp=/bin/chgrp
71elif [ -x /etc/chgrp ]; then
72        chgrp=/etc/chgrp
73else
74        echo "${Prog}: Cannot locate the chgrp program."
75        exit 1
76fi
77
78if [ -x /usr/etc/chown ]; then
79        chown=/usr/etc/chown
80elif [ -x /usr/sbin/chown ]; then
81        chown=/usr/sbin/chown
82elif [ -x /usr/ucb/chown ]; then
83        chown=/usr/ucb/chown
84elif [ -x /bin/chown ]; then
85        chown=/bin/chown
86elif [ -x /usr/bin/chown ]; then
87        chown=/usr/bin/chown
88elif [ -x /etc/chown ]; then
89        chown=/etc/chown
90else
91        echo "${Prog}: Cannot locate the chown program."
92        exit 1
93fi
94
95#
96# Parse command line options
97#
98while [ x$1 != x ]; do
99    case $1 in
100        -c)     # Option for backwards compatibility
101                shift
102                continue;;
103
104        -m)
105                Mode=$2
106                shift
107                shift
108                continue;;
109
110        -g)
111                Group=$2
112                shift
113                shift
114                continue;;
115
116        -o)
117                Owner=$2
118                shift
119                shift
120                continue;;
121
122        -s)
123                Strip=1
124                shift
125                continue;;
126
127        -*)
128                echo "${Prog}: Unknown option $2."
129                exit 1
130                ;;
131
132        *)
133                if [ x$src = x ]; then
134                        src=$1
135                else
136                        dst=$1
137                fi
138                shift
139                continue;;
140
141    esac
142done
143
144if [ x$src = x ]; then
145        echo "${Prog}: No source file was specified."
146        exit 1
147fi
148if [ x$dst = x ]; then
149        echo "${Prog}: No destination file was specified."
150        exit 1
151fi
152
153if [ -d $dst ]; then
154        base=`basename $src`
155        Target=$dst/$base
156else
157        Target=$dst
158fi
159
160if [ -f $Target ]; then
161        $rm -f $Target
162fi
163
164if [ $Copy -eq 1 ]; then
165        InstallProg=$cp
166else
167        InstallProg=$mv
168fi
169
170$InstallProg $src $Target && {
171        if [ x$Owner != x ]; then
172                $chown $Owner $Target
173        fi
174} && {
175        $chgrp $Group $Target
176} && {
177        $chmod $Mode $Target
178} && {
179        if [ $Strip -gt 0 ]; then
180                $strip $Target
181        fi
182}
183
Note: See TracBrowser for help on using the repository browser.