install_prereq 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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 uuid-dev uuid"
  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 libcorosync-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 libedit-dev libldap-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 corosynclib-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 libedit-devel libuuid-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. for pack in "$@"
  45. do
  46. tocheck="${tocheck} ^${pack}$"
  47. done
  48. aptitude -F '%c %p' search ${tocheck} 2>/dev/null \
  49. | awk '/^p/{print $2}' \
  50. | grep -v ':i386$'
  51. }
  52. # parsing the output of yum is close to impossible.
  53. # We'll use rpm and hope for the best:
  54. check_installed_rpms() {
  55. for pack in "$@"
  56. do
  57. if ! rpm -q $pack >/dev/null 2>/dev/null
  58. then echo $pack
  59. fi
  60. done
  61. }
  62. check_installed_pkgs() {
  63. for pack in "$@"
  64. do
  65. if [ `pkg_info -a | grep $pack | wc -l` = 0 ]; then
  66. echo $pack
  67. fi
  68. done
  69. }
  70. handle_debian() {
  71. # echo "# Distribution is Debian or compatible"
  72. extra_packs=`check_installed_debs $PACKAGES_DEBIAN`
  73. $testcmd aptitude install -y $extra_packs
  74. }
  75. handle_rh() {
  76. # echo "# Distribution is RedHat-based or compatible"
  77. extra_packs=`check_installed_rpms $PACKAGES_RH`
  78. # FIXME: is there yum with RHEL 4?
  79. $testcmd yum install -y $extra_packs
  80. }
  81. handle_obsd() {
  82. # echo "# Distribution is OpenBSD or compatible"
  83. extra_packs=`check_installed_pkgs $PACKAGES_OBSD`
  84. $testcmd pkg_add $extra_packs
  85. }
  86. install_unpackaged() {
  87. echo "*** Installing NBS (Network Broadcast Sound) ***"
  88. svn co http://svn.digium.com/svn/nbs/trunk nbs-trunk
  89. cd nbs-trunk
  90. make && make install
  91. cd ..
  92. echo "*** Installing libresample ***"
  93. svn co http://svn.digium.com/svn/thirdparty/libresample/trunk libresample-trunk
  94. cd libresample-trunk
  95. ./configure && make && make install
  96. cd ..
  97. }
  98. if in_test_mode; then
  99. echo "#############################################"
  100. echo "## $1: test mode."
  101. echo "## Use the commands here to install your system."
  102. echo "#############################################"
  103. elif test "${unpackaged}" = "yes" ; then
  104. install_unpackaged
  105. exit 0
  106. fi
  107. OS=`uname -s`
  108. unsupported_distro=''
  109. # A number of distributions we don't (yet?) support.
  110. if [ "$OS" != 'Linux' -a "$OS" != 'OpenBSD' ]; then
  111. echo >&2 "$0: Your OS ($OS) is currently not supported. Aborting."
  112. exit 1
  113. fi
  114. if [ -f /etc/gentoo-release ]; then
  115. unsupported_distro='Gentoo'
  116. fi
  117. if [ -f /etc/mandrake-release ]; then
  118. unsupported_distro='Mandriva'
  119. fi
  120. if [ -f /etc/SuSE-release ]; then
  121. unsupported_distro='SUSE'
  122. fi
  123. if [ -f /etc/slackware-version ]; then
  124. unsupported_distro='Slackware'
  125. fi
  126. if [ "$unsupported_distro" != '' ]; then
  127. echo >&2 "$0: Your distribution ($unsupported_distro) is currently not supported. Aborting."
  128. exit 1
  129. fi
  130. # The distributions we do support:
  131. if [ -r /etc/debian_version ]; then
  132. handle_debian
  133. elif [ -r /etc/redhat-release ]; then
  134. handle_rh
  135. elif [ "$OS" = 'OpenBSD' ]; then
  136. handle_obsd
  137. fi
  138. if ! in_test_mode; then
  139. echo "#############################################"
  140. echo "## $1 completed successfully"
  141. echo "#############################################"
  142. fi