Whamcloud - gitweb
Add scripts/mass_install to simplify installation rules.
[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
5 # Usage: mass_install DIR [FILES...] [OPTS...]
6 FILES=
7 DIR=
8 OPTS=
9
10 for arg
11 do
12  if test -n "$OPTS"; then
13   # Everything from here is an option.
14   OPTS="$OPTS $arg"
15  else
16   case "$arg" in
17   # We found the first option.
18   -*) OPTS="$arg" ;;
19   *)
20    if test -z "$DIR"; then
21     # We don't have a directory yet.
22     DIR="$arg"
23    else
24     # We have no files.
25     FILES="$FILES $arg"
26    fi
27    ;;
28   esac
29  fi
30 done
31
32 if test -n "$DIR" && test -n "$FILES"; then
33  # Make sure the directory exists.
34  if test ! -d "$DIR"; then
35   cmd="mkdir -p $DIR"
36   $cmd || exit $?
37  fi
38
39  # Run the installer.
40  for f in $FILES; do
41   base=`echo "$f" | sed -e 'sX.*/XX'`
42   cmd="install $OPTS $f $DIR/$base"
43   echo "$cmd"
44   $cmd || exit $?
45  done
46 fi
47 exit 0