install_prereq 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. #! /bin/sh
  2. #
  3. # $Id$
  4. #
  5. # install_prereq: a script to install distribution-specific
  6. # prerequirements
  7. set -e
  8. usage() {
  9. echo "$0: a script to install distribution-specific prerequirement"
  10. echo 'Revision: $Id$'
  11. echo ""
  12. echo "Usage: $0: Shows this message."
  13. echo "Usage: $0 test Prints commands it is about to run."
  14. echo "Usage: $0 install Really install."
  15. echo "Usage: $0 install-unpackaged Really install unpackaged requirements."
  16. }
  17. # Basic build system:
  18. PACKAGES_DEBIAN="build-essential"
  19. # Asterisk: basic requirements:
  20. PACKAGES_DEBIAN="$PACKAGES_DEBIAN libncurses-dev libz-dev libssl-dev libxml2-dev libsqlite3-dev"
  21. # Asterisk: for addons:
  22. PACKAGES_DEBIAN="$PACKAGES_DEBIAN libcurl-dev libspeex-dev libspeexdsp-dev libogg-dev libvorbis-dev libasound2-dev portaudio19-dev libcurl4-openssl-dev"
  23. PACKAGES_DEBIAN="$PACKAGES_DEBIAN libpq-dev unixodbc-dev libsqlite0-dev libmysqlclient15-dev libneon27-dev libgmime-dev libusb-dev liblua5.1-0-dev lua5.1"
  24. PACKAGES_DEBIAN="$PACKAGES_DEBIAN libopenh323-dev libvpb-dev libgtk2.0-dev libmysqlclient-dev libbluetooth-dev libradiusclient-ng-dev freetds-dev"
  25. PACKAGES_DEBIAN="$PACKAGES_DEBIAN libsnmp-dev libiksemel-dev libopenais-dev libnewt-dev libpopt-dev libical-dev libspandsp-dev libjack-dev"
  26. PACKAGES_DEBIAN="$PACKAGES_DEBIAN libresample-dev libc-client-dev binutils-dev libsrtp-dev libgsm1-dev"
  27. PACKAGES_RH="automake gcc gcc-c++ ncurses-devel openssl-devel libxml2-devel unixODBC-devel libcurl-devel libogg-devel libvorbis-devel speex-devel"
  28. PACKAGES_RH="$PACKAGES_RH spandsp-devel freetds-devel net-snmp-devel iksemel-devel openais-devel newt-devel popt-devel libtool-ltdl-devel lua-devel"
  29. PACKAGES_RH="$PACKAGES_RH libsqlite3x-devel radiusclient-ng-devel portaudio-devel postgresql-devel libresample-devel neon-devel libical-devel"
  30. PACKAGES_RH="$PACKAGES_RH openldap-devel gmime22-devel sqlite2-devel mysql-devel bluez-libs-devel jack-audio-connection-kit-devel gsm-devel"
  31. PACKAGES_OBSD="popt gmake wget libxml libogg libvorbis curl iksemel spandsp speex iodbc freetds-0.63p1-msdblib mysql-client gmime sqlite sqlite3 jack"
  32. KVERS=`uname -r`
  33. case "$1" in
  34. test) testcmd=echo ;;
  35. install) testcmd='' ;;
  36. install-unpackaged) unpackaged="yes" ;;
  37. '') usage; exit 0 ;;
  38. *) usage; exit 1 ;;
  39. esac
  40. in_test_mode() {
  41. test "$testcmd" != ''
  42. }
  43. check_installed_debs() {
  44. aptitude -F '%c %p' search "$@" 2>/dev/null \
  45. | awk '/^p/{print $2}'
  46. }
  47. # parsing the output of yum is close to impossible.
  48. # We'll use rpm and hope for the best:
  49. check_installed_rpms() {
  50. for pack in "$@"
  51. do
  52. if ! rpm -q $pack >/dev/null 2>/dev/null
  53. then echo $pack
  54. fi
  55. done
  56. }
  57. check_installed_pkgs() {
  58. for pack in "$@"
  59. do
  60. if [ `pkg_info -a | grep $pack | wc -l` = 0 ]; then
  61. echo $pack
  62. fi
  63. done
  64. }
  65. handle_debian() {
  66. # echo "# Distribution is Debian or compatible"
  67. extra_packs=`check_installed_debs $PACKAGES_DEBIAN`
  68. $testcmd aptitude install -y $extra_packs
  69. }
  70. handle_rh() {
  71. # echo "# Distribution is RedHat-based or compatible"
  72. extra_packs=`check_installed_rpms $PACKAGES_RH`
  73. # FIXME: is there yum with RHEL 4?
  74. $testcmd yum install -y $extra_packs
  75. }
  76. handle_obsd() {
  77. # echo "# Distribution is OpenBSD or compatible"
  78. extra_packs=`check_installed_pkgs $PACKAGES_OBSD`
  79. $testcmd pkg_add $extra_packs
  80. }
  81. install_unpackaged() {
  82. echo "*** Installing NBS (Network Broadcast Sound) ***"
  83. svn co http://svn.digium.com/svn/nbs/trunk nbs-trunk
  84. cd nbs-trunk
  85. make && make install
  86. cd ..
  87. echo "*** Installing libresample ***"
  88. svn co http://svn.digium.com/svn/thirdparty/libresample/trunk libresample-trunk
  89. cd libresample-trunk
  90. ./configure && make && make install
  91. cd ..
  92. }
  93. if in_test_mode; then
  94. echo "#############################################"
  95. echo "## $1: test mode."
  96. echo "## Use the commands here to install your system."
  97. echo "#############################################"
  98. elif test "${unpackaged}" = "yes" ; then
  99. install_unpackaged
  100. exit 0
  101. fi
  102. OS=`uname -s`
  103. unsupported_distro=''
  104. # A number of distributions we don't (yet?) support.
  105. if [ "$OS" != 'Linux' -a "$OS" != 'OpenBSD' ]; then
  106. echo >&2 "$0: Your OS ($OS) is currently not supported. Aborting."
  107. exit 1
  108. fi
  109. if [ -f /etc/gentoo-release ]; then
  110. unsupported_distro='Gentoo'
  111. fi
  112. if [ -f /etc/mandrake-release ]; then
  113. unsupported_distro='Mandriva'
  114. fi
  115. if [ -f /etc/SuSE-release ]; then
  116. unsupported_distro='SUSE'
  117. fi
  118. if [ -f /etc/slackware-version ]; then
  119. unsupported_distro='Slackware'
  120. fi
  121. if [ "$unsupported_distro" != '' ]; then
  122. echo >&2 "$0: Your distribution ($unsupported_distro) is currently not supported. Aborting."
  123. exit 1
  124. fi
  125. # The distributions we do support:
  126. if [ -r /etc/debian_version ]; then
  127. handle_debian
  128. elif [ -r /etc/redhat-release ]; then
  129. handle_rh
  130. elif [ "$OS" = 'OpenBSD' ]; then
  131. handle_obsd
  132. fi
  133. if ! in_test_mode; then
  134. echo "#############################################"
  135. echo "## $1 completed successfully"
  136. echo "#############################################"
  137. fi