Merge from vendor branch SENDMAIL:
[dragonfly.git] / contrib / sendmail-8.13.7 / devtools / bin / install.sh
1 #!/bin/sh
2
3 # Copyright (c) 1998, 1999, 2001 Sendmail, Inc. and its suppliers.
4 #       All rights reserved.
5 #
6 # By using this file, you agree to the terms and conditions set
7 # forth in the LICENSE file which can be found at the top level of
8 # the sendmail distribution.
9 #
10 #
11 #       $Id: install.sh,v 8.14 2001/03/16 23:37:31 gshapiro Exp $
12
13 # Set default program
14 program=mv
15 owner=""
16 group=""
17 mode=""
18 strip=""
19
20 # chown program -- ultrix keeps it in /etc/chown and /usr/etc/chown
21 if [ -f /etc/chown ]
22 then
23         chown=/etc/chown
24 elif [ -f /usr/etc/chown ]
25 then
26         chown=/usr/etc/chown
27 else
28         chown=chown
29 fi
30
31 # Check arguments
32 while [ ! -z "$1" ]
33 do
34         case $1
35         in
36           -o)   owner=$2
37                 shift; shift
38                 ;;
39
40           -g)   group=$2
41                 shift; shift
42                 ;;
43
44           -m)   mode=$2
45                 shift; shift
46                 ;;
47
48           -c)   program=cp
49                 shift
50                 ;;
51
52           -s)   strip="strip"
53                 shift
54                 ;;
55
56           -*)   echo $0: Unknown option $1
57                 exit 1
58                 ;;
59
60           *)    break
61                 ;;
62         esac
63 done
64
65 # Check source file
66 if [ -z "$1" ]
67 then
68         echo "Source file required" >&2
69         exit 1
70 elif [ -f $1 -o $1 = /dev/null ]
71 then
72         src=$1
73 else
74         echo "Source file must be a regular file or /dev/null" >&2
75         exit 1
76 fi
77
78 # Check destination
79 if [ -z "$2" ]
80 then
81         echo "Destination required" >&2
82         exit 1
83 elif [ -d $2 ]
84 then
85         srcfile=`basename $src`
86         dst=$2/$srcfile
87 else
88         dst=$2
89 fi
90
91 # Do install operation
92 $program $src $dst
93 if [ $? != 0 ]
94 then
95         exit 1
96 fi
97
98 # Strip if requested
99 if [ ! -z "$strip" ]
100 then
101         $strip $dst
102 fi
103
104 # Change owner if requested
105 if [ ! -z "$owner" ]
106 then
107         $chown $owner $dst
108         if [ $? != 0 ]
109         then
110                 exit 1
111         fi
112 fi
113
114 # Change group if requested
115 if [ ! -z "$group" ]
116 then
117         chgrp $group $dst
118         if [ $? != 0 ]
119         then
120                 exit 1
121         fi
122 fi
123
124 # Change mode if requested
125 if [ ! -z "$mode" ]
126 then
127         chmod $mode $dst
128         if [ $? != 0 ]
129         then
130                 exit 1
131         fi
132 fi
133
134 exit 0