2
0

install.sh 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/sh
  2. #
  3. # install - install a program, script, or datafile
  4. # This comes from X11R5; it is not part of GNU.
  5. #
  6. # $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
  7. #
  8. # This script is compatible with the BSD install script, but was written
  9. # from scratch.
  10. #
  11. # set DOITPROG to echo to test this script
  12. doit="${DOITPROG:-}"
  13. # put in absolute paths if you don't have them in your path; or use env. vars.
  14. mvprog="${MVPROG:-mv}"
  15. cpprog="${CPPROG:-cp}"
  16. chmodprog="${CHMODPROG:-chmod}"
  17. chownprog="${CHOWNPROG:-chown}"
  18. chgrpprog="${CHGRPPROG:-chgrp}"
  19. stripprog="${STRIPPROG:-strip}"
  20. rmprog="${RMPROG:-rm}"
  21. instcmd="$mvprog"
  22. chmodcmd=""
  23. chowncmd=""
  24. chgrpcmd=""
  25. stripcmd=""
  26. rmcmd="$rmprog -f"
  27. src=""
  28. dst=""
  29. while [ x"$1" != x ]; do
  30. case $1 in
  31. -c) instcmd="$cpprog"
  32. shift
  33. continue;;
  34. -m) chmodcmd="$chmodprog $2"
  35. shift
  36. shift
  37. continue;;
  38. -o) chowncmd="$chownprog $2"
  39. shift
  40. shift
  41. continue;;
  42. -g) chgrpcmd="$chgrpprog $2"
  43. shift
  44. shift
  45. continue;;
  46. -s) stripcmd="$stripprog"
  47. shift
  48. continue;;
  49. *) if [ x"$src" = x ]
  50. then
  51. src=$1
  52. else
  53. dst=$1
  54. fi
  55. shift
  56. continue;;
  57. esac
  58. done
  59. if [ x"$src" = x ]
  60. then
  61. echo "install: no input file specified"
  62. exit 1
  63. fi
  64. if [ x"$dst" = x ]
  65. then
  66. echo "install: no destination specified"
  67. exit 1
  68. fi
  69. # if destination is a directory, append the input filename; if your system
  70. # does not like double slashes in filenames, you may need to add some logic
  71. if [ -d $dst ]
  72. then
  73. dst="$dst"/`basename $src`
  74. fi
  75. # get rid of the old one and mode the new one in
  76. $doit $rmcmd $dst
  77. $doit $instcmd $src $dst
  78. # and set any options; do chmod last to preserve setuid bits
  79. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; fi
  80. if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; fi
  81. if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; fi
  82. if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; fi
  83. exit 0