BuildGPIB.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/sh
  2. # configure and build the gpib drivers
  3. main()
  4. {
  5. local dir
  6. dir=linux-gpib-svn
  7. if ! cd "${dir}"
  8. then
  9. echo cannot change to ${dir}
  10. exit 1
  11. fi
  12. [ -e Makefile ] && make clean
  13. autoreconf --verbose --install --symlink
  14. ./configure --disable-tcl-binding --disable-php-binding --disable-perl-binding --disable-guile-binding
  15. make clean
  16. make
  17. make -C language/python
  18. modprobe -v -r tnt4882
  19. make install
  20. make -C language/python install
  21. # update library cache
  22. ldconfig -v
  23. echo loading the updated driver
  24. modprobe -v tnt4882
  25. echo cleaning up
  26. make clean
  27. cd ..
  28. echo initialising the driver
  29. gpib_config
  30. echo installing scripts in init.d and rcX.d
  31. install -o root -g root -m 750 init-scripts/gpib /etc/init.d/
  32. for d in 1
  33. do
  34. rm -f "/etc/rc${d}.d/K01gpib"
  35. ln -s ../init.d/gpib "/etc/rc${d}.d/K01gpib"
  36. done
  37. for d in 2 3 4 5
  38. do
  39. rm -f "/etc/rc${d}.d/S99gpib"
  40. ln -s ../init.d/gpib "/etc/rc${d}.d/S99gpib"
  41. done
  42. echo setting up udev rules
  43. udev='/etc/udev/rules.d'
  44. for rule in init-scripts/*.rules
  45. do
  46. echo installing: ${rule} to: ${udev}
  47. install -o root -g root -m 644 "${rule}" "${udev}"/
  48. done
  49. echo running the startup script
  50. /etc/init.d/gpib stop
  51. sleep 1
  52. /etc/init.d/gpib start
  53. echo Add the following to your /etc/sudoers
  54. echo '----------8<----------8<----------8<---------'
  55. cat init-scripts/sudoers.add
  56. echo '----------8<----------8<----------8<---------'
  57. echo 'Now run: sudo visudo'
  58. echo ' or: sudo EDITOR=jove visudo'
  59. echo and paste the above text into file
  60. # check that the gpib module is usable
  61. if ! python -m Gpib
  62. then
  63. echo '** ERROR:'
  64. echo '** The python GPIB.py module is not accessible'
  65. echo '** Maybe there are multiple versions of python'
  66. echo '** and the wrong one was selected by this install script'
  67. echo '** OR:'
  68. echo '** python development tools were not installed, try:'
  69. echo '** sudo apt-get python-dev'
  70. echo '** and re-run this script'
  71. fi
  72. }
  73. if [ -z "${SUDO_UID}" -o -z "${SUDO_GID}" ]
  74. then
  75. echo re-run with sudo
  76. sudo -K
  77. exec sudo "$0" "$@"
  78. exit 1
  79. fi
  80. if [ -n "${SUDO_UID}" -a -n "${SUDO_GID}" ]
  81. then
  82. main "$@"
  83. else
  84. echo sudo failed
  85. fi