1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253
|
#!/bin/sh
#
# Copyright (c) 1999,2000 WU-FTPD Development Group.
# All rights reserved.
#
# Portions Copyright (c) 1980, 1985, 1988, 1989, 1990, 1991, 1993, 1994
# The Regents of the University of California.
# Portions Copyright (c) 1993, 1994 Washington University in Saint Louis.
# Portions Copyright (c) 1989 Massachusetts Institute of Technology.
# Portions Copyright (c) 1998 Sendmail, Inc.
# Portions Copyright (c) 1983, 1995, 1996, 1997 Eric P. Allman.
# Portions Copyright (c) 1996, 1998 Berkeley Software Design, Inc.
# Portions Copyright (C) 1991, 1992, 1993, 1994, 1995 1996, 1997
# Free Software Foundation, Inc.
# Portions Copyright (c) 1997 Stan Barber.
# Portions Copyright (c) 1997 Kent Landfield.
#
# Use and distribution of this software and its source code are governed by
# the terms and conditions of the WU-FTPD Software License ("LICENSE").
#
# If you did not receive a copy of the license, it may be obtained online at
# http://www.wu-ftpd.org/license.html.
#
# $Id: install,v 1.4 2000/07/01 18:42:38 wuftpd Exp $
#
# install - implementation of BSD install program for SYSV
#
# SYNTAX:
# install [-cs] [-g group] [-m mode] [-o owner] file1 file2
# install [-cs] [-g group] [-m mode] [-o owner] file1 ... directory
# install -d [-g group] [-m mode] [-o owner] directory
#
# RETURN VALUES:
# 0 success
# 1 failure
#
# ----------------------------- INITIALIZATION ------------------------------
ME="`basename $0`"
# ------------------------------- SUBROUTINES -------------------------------
#
# Usage - print usage message
#
Usage()
{
echo "Usage: ${ME} [-cs] [-g group] [-m mode] [-o owner] file1 file2"
echo " ${ME} [-cs] [-g group] [-m mode] [-o owner] file1 ... directory"
echo " ${ME} -d [-g group] [-m mode] [-o owner] directory"
exit 1
}
#
# Warning - print warning message
#
Warning()
{
echo "${ME}: $*"
}
#
# Die - print message and exit with failure
#
Die()
{
echo "${ME}: $*"
exit 1
}
# ------------------------------- MAIN PROGRAM -----------------------------
#
# We always need at least two arguments
#
if [ $# -lt 2 ]
then
Usage
fi
#
# Process command line options
#
for ARG in $*; do
if [ "${FLAG}" = "on" ]; then
case ${ARG} in
-*)
Die "The -g, -m and -o flags each require an argument following"
exit 1
;;
*)
FLAG=off
continue
;;
esac
fi
case ${ARG} in
-cs | -s)
STRIP=on
shift
;;
-g)
GRP=$2
FLAG=on
shift 2
;;
-m)
MODE=$2
FLAG=on
shift 2
;;
-o)
OWNER=$2
FLAG=on
shift 2
;;
-d)
MKDIR=on
shift
;;
-c)
# For backward compatibility only; ignore
shift
;;
-*)
Warning "unknown option ${ARG}"
Usage
;;
*)
break
;;
esac
done
#
# We always need at least one filename
#
if [ $# -lt 1 ]
then
Usage
fi
#
# Find out what the target is
#
FILES=$*
NARGS=$#
set `echo ${FILES}`
i=1
while [ $i -lt ${NARGS} ]; do
FLS="${FLS} $1"
shift
i=`expr $i + 1`
done
TARGET=$1
#
# If more than one file specified, target must be a directory
#
if [ $i -gt 2 ]
then
if [ ! -d ${TARGET} ]
then
Usage
fi
fi
#
# If -d flag was present, see if directory exists. If not create it.
# If group and/or mode and/or owner specified, set them for target
#
if [ "${MKDIR}" = "on" ]
then
if [ ! -d ${TARGET} ]
then
mkdir -p ${TARGET}
fi
if [ "${GRP}" != "" ]
then
chgrp ${GRP} ${TARGET}
fi
if [ "${MODE}" != "" ]
then
chmod ${MODE} ${TARGET}
fi
if [ "${OWNER}" != "" ]
then
# This fails on early releases of IRIX so, we'll just let chown speak here
# and we'll not bother.
# if [ "`id -un`" != "root" ]
# then
# Warning "-o: must be superuser to change owner"
# else
chown ${OWNER} ${TARGET}
# fi
fi
fi
#
# Process each file, taking the command line options into account
# If the target is a directory, set modes for file in that directory,
# otherwise set modes for file.
#
for FILE in ${FLS}
do
if [ "${STRIP}" = "on" ]
then
strip ${FILE}
fi
cp ${FILE} ${TARGET}
if [ "${GRP}" != "" ]
then
if [ ! -d ${TARGET} ]
then
chgrp ${GRP} ${TARGET}
else
chgrp ${GRP} ${TARGET}/${FILE}
fi
fi
if [ "${MODE}" != "" ]
then
if [ ! -d ${TARGET} ]
then
chmod ${MODE} ${TARGET}
else
chmod ${MODE} ${TARGET}/${FILE}
fi
fi
if [ "${OWNER}" != "" ]
then
# This fails on early releases of IRIX so, we'll just let chown speak here
# and we'll not bother.
# if [ "`id -un`" != "root" ]
# then
# Warning "-o: must be superuser to change owner"
# elif [ ! -d ${TARGET} ]
if [ ! -d ${TARGET} ]
then
chown ${OWNER} ${TARGET}
else
chown ${OWNER} ${TARGET}/${FILE}
fi
fi
done
|