Whamcloud - gitweb
Create lustre-tools and lustre-modules packages.
[fs/lustre-release.git] / lustre / scripts / mass_install
1 #! /bin/sh
2 # mass_install - Install zero or more files in a directory
3 # Gordon Matzigkeit <gord@fig.org>, 2001-09-26
4 # Copyright (C) 2001  Cluster File Systems, Inc.
5 #
6 # This code is issued under the GNU General Public License.
7 # See the file COPYING in this distribution
8
9 # Usage: mass_install DIR [FILES...] [OPTS...]
10 FILES=
11 DIR=
12 OPTS=
13
14 for arg
15 do
16  if test -n "$OPTS"; then
17   # Everything from here is an option.
18   OPTS="$OPTS $arg"
19  else
20   case "$arg" in
21   # We found the first option.
22   -*) OPTS="$arg" ;;
23   *)
24    if test -z "$DIR"; then
25     # We don't have a directory yet.
26     DIR="$arg"
27    else
28     # We have no files.
29     FILES="$FILES $arg"
30    fi
31    ;;
32   esac
33  fi
34 done
35
36 if test -n "$DIR" && test -n "$FILES"; then
37  # Make sure the directory exists.
38  if test ! -d "$DIR"; then
39   cmd="mkdir -p $DIR"
40   $cmd || exit $?
41  fi
42
43  # Run the installer.
44  for f in $FILES; do
45   base=`echo "$f" | sed -e 'sX.*/XX'`
46   cmd="install $OPTS $f $DIR/$base"
47   echo "$cmd"
48   $cmd || exit $?
49  done
50 fi
51 exit 0