home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 April / PCO0499.ISO / filesbbs / os2 / apach134.arj / APACH134.ZIP / src / helpers / install.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1998-09-16  |  2.3 KB  |  101 lines

  1. #!/bin/sh
  2. ##
  3. ##  install.sh -- install a program, script or datafile
  4. ##
  5. ##  Based on `install-sh' from the X Consortium's X11R5 distribution
  6. ##  as of 89/12/18 which is freely available.
  7. ##  Cleaned up for Apache's Autoconf-style Interface (APACI)
  8. ##  by Ralf S. Engelschall <rse@apache.org>
  9. ##
  10. #
  11. # This script falls under the Apache License.
  12. # See http://www.apache.org/docs/LICENSE
  13.  
  14.  
  15. #
  16. #   put in absolute paths if you don't have them in your path; 
  17. #   or use env. vars.
  18. #
  19. mvprog="${MVPROG-mv}"
  20. cpprog="${CPPROG-cp}"
  21. chmodprog="${CHMODPROG-chmod}"
  22. chownprog="${CHOWNPROG-chown}"
  23. chgrpprog="${CHGRPPROG-chgrp}"
  24. stripprog="${STRIPPROG-strip}"
  25. rmprog="${RMPROG-rm}"
  26.  
  27. #
  28. #   parse argument line
  29. #
  30. instcmd="$mvprog"
  31. chmodcmd=""
  32. chowncmd=""
  33. chgrpcmd=""
  34. stripcmd=""
  35. rmcmd="$rmprog -f"
  36. mvcmd="$mvprog"
  37. src=""
  38. dst=""
  39. while [ ".$1" != . ]; do
  40.     case $1 in
  41.         -c) instcmd="$cpprog"
  42.             shift; continue
  43.             ;;
  44.         -m) chmodcmd="$chmodprog $2"
  45.             shift; shift; continue
  46.             ;;
  47.         -o) chowncmd="$chownprog $2"
  48.             shift; shift; continue
  49.             ;;
  50.         -g) chgrpcmd="$chgrpprog $2"
  51.             shift; shift; continue
  52.             ;;
  53.         -s) stripcmd="$stripprog"
  54.             shift; continue;;
  55.         *)  if [ ".$src" = . ]; then
  56.                 src=$1
  57.             else
  58.                 dst=$1
  59.             fi
  60.             shift; continue
  61.             ;;
  62.     esac
  63. done
  64. if [ ".$src" = . ]; then
  65.      echo "install.sh: no input file specified"
  66.      exit 1
  67. fi
  68. if [ ".$dst" = . ]; then
  69.      echo "install.sh: no destination specified"
  70.      exit 1
  71. fi
  72.  
  73. #
  74. #  If destination is a directory, append the input filename; if
  75. #  your system does not like double slashes in filenames, you may
  76. #  need to add some logic
  77. #
  78. if [ -d $dst ]; then
  79.     dst="$dst/`basename $src`"
  80. fi
  81.  
  82. #  Make a temp file name in the proper directory.
  83. dstdir=`dirname $dst`
  84. dsttmp=$dstdir/#inst.$$#
  85.  
  86. #  Move or copy the file name to the temp name
  87. $instcmd $src $dsttmp
  88.  
  89. #  And set any options; do chmod last to preserve setuid bits
  90. if [ ".$chowncmd" != . ]; then $chowncmd $dsttmp; fi
  91. if [ ".$chgrpcmd" != . ]; then $chgrpcmd $dsttmp; fi
  92. if [ ".$stripcmd" != . ]; then $stripcmd $dsttmp; fi
  93. if [ ".$chmodcmd" != . ]; then $chmodcmd $dsttmp; fi
  94.  
  95. #  Now rename the file to the real destination.
  96. $rmcmd $dst
  97. $mvcmd $dsttmp $dst
  98.  
  99. exit 0
  100.  
  101.