| 
									
										
										
										
											2008-05-12 20:34:38 +00:00
										 |  |  | #! /bin/sh | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # $Id$ | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # install_prereq: a script to install distribution-specific | 
					
						
							|  |  |  | # prerequirements | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | set -e | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | usage() { | 
					
						
							|  |  |  |   echo "$0: a script to install distribution-specific prerequirement" | 
					
						
							|  |  |  |   echo 'Revision: $Id$' | 
					
						
							|  |  |  |   echo "" | 
					
						
							| 
									
										
										
										
											2010-06-09 10:45:10 +00:00
										 |  |  |   echo "Usage: $0:                    Shows this message." | 
					
						
							|  |  |  |   echo "Usage: $0 test                Prints commands it is about to run." | 
					
						
							|  |  |  |   echo "Usage: $0 install             Really install." | 
					
						
							|  |  |  |   echo "Usage: $0 install-unpackaged  Really install unpackaged requirements." | 
					
						
							| 
									
										
										
										
											2008-05-12 20:34:38 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Basic build system: | 
					
						
							|  |  |  | PACKAGES_DEBIAN="build-essential" | 
					
						
							|  |  |  | # Asterisk: basic requirements: | 
					
						
							| 
									
										
										
										
											2009-07-25 12:28:38 +00:00
										 |  |  | PACKAGES_DEBIAN="$PACKAGES_DEBIAN libncurses-dev libz-dev libssl-dev libxml2-dev" | 
					
						
							| 
									
										
										
										
											2010-06-09 10:21:23 +00:00
										 |  |  | # Asterisk: for addons: | 
					
						
							| 
									
										
										
										
											2010-06-09 10:33:32 +00:00
										 |  |  | PACKAGES_DEBIAN="$PACKAGES_DEBIAN libcurl-dev libspeex-dev libspeexdsp-dev libogg-dev libvorbis-dev libasound2-dev portaudio19-dev libcurl4-openssl-dev" | 
					
						
							| 
									
										
										
										
											2012-01-14 15:22:33 +00:00
										 |  |  | PACKAGES_DEBIAN="$PACKAGES_DEBIAN libpq-dev unixodbc-dev libsqlite0-dev libsqlite3-dev libmysqlclient15-dev libneon27-dev libgmime-dev libusb-dev liblua5.1-0-dev lua5.1" | 
					
						
							| 
									
										
										
										
											2010-06-09 10:30:32 +00:00
										 |  |  | PACKAGES_DEBIAN="$PACKAGES_DEBIAN libopenh323-dev libvpb-dev libgtk2.0-dev libmysqlclient-dev libbluetooth-dev libradiusclient-ng-dev freetds-dev" | 
					
						
							| 
									
										
										
										
											2010-06-09 10:55:07 +00:00
										 |  |  | PACKAGES_DEBIAN="$PACKAGES_DEBIAN libsnmp-dev libiksemel-dev libopenais-dev libnewt-dev libpopt-dev libical-dev libspandsp-dev libjack-dev" | 
					
						
							| 
									
										
										
										
											2012-01-14 15:22:33 +00:00
										 |  |  | PACKAGES_DEBIAN="$PACKAGES_DEBIAN libresample-dev libc-client-dev binutils-dev libsrtp-dev" | 
					
						
							| 
									
										
										
										
											2008-05-12 20:34:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-11-18 05:12:05 +00:00
										 |  |  | PACKAGES_RH="automake gcc gcc-c++ ncurses-devel openssl-devel libxml2-devel unixODBC-devel libcurl-devel libogg-devel libvorbis-devel speex-devel" | 
					
						
							|  |  |  | PACKAGES_RH="$PACKAGES_RH spandsp-devel freetds-devel net-snmp-devel iksemel-devel openais-devel newt-devel popt-devel libtool-ltdl-devel lua-devel" | 
					
						
							|  |  |  | PACKAGES_RH="$PACKAGES_RH libsqlite3x-devel radiusclient-ng-devel portaudio-devel postgresql-devel libresample-devel neon-devel libical-devel" | 
					
						
							|  |  |  | PACKAGES_RH="$PACKAGES_RH openldap-devel gmime22-devel sqlite2-devel mysql-devel bluez-libs-devel jack-audio-connection-kit-devel" | 
					
						
							| 
									
										
										
										
											2008-05-12 20:34:38 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-26 14:00:52 +00:00
										 |  |  | PACKAGES_OBSD="popt gmake wget libxml libogg libvorbis curl iksemel spandsp speex iodbc freetds-0.63p1-msdblib mysql-client gmime sqlite sqlite3 jack" | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-12 20:34:38 +00:00
										 |  |  | KVERS=`uname -r` | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | case "$1" in | 
					
						
							|  |  |  | test)    testcmd=echo ;; | 
					
						
							|  |  |  | install) testcmd='' ;; | 
					
						
							| 
									
										
										
										
											2010-06-09 10:45:10 +00:00
										 |  |  | install-unpackaged) unpackaged="yes" ;; | 
					
						
							| 
									
										
										
										
											2008-05-12 20:34:38 +00:00
										 |  |  | '') usage; exit 0 ;; | 
					
						
							|  |  |  | *) usage; exit 1 ;; | 
					
						
							|  |  |  | esac | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | in_test_mode() { | 
					
						
							|  |  |  |   test "$testcmd" != '' | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | check_installed_debs() { | 
					
						
							| 
									
										
										
										
											2009-07-24 14:35:49 +00:00
										 |  |  | 	aptitude -F '%c %p' search "$@" 2>/dev/null \ | 
					
						
							|  |  |  | 	| awk '/^p/{print $2}' | 
					
						
							| 
									
										
										
										
											2008-05-12 20:34:38 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # parsing the output of yum is close to impossible. | 
					
						
							|  |  |  | # We'll use rpm and hope for the best: | 
					
						
							|  |  |  | check_installed_rpms() { | 
					
						
							|  |  |  | 	for pack in "$@" | 
					
						
							|  |  |  | 	do | 
					
						
							|  |  |  | 		if ! rpm -q $pack >/dev/null 2>/dev/null | 
					
						
							|  |  |  | 		then echo $pack | 
					
						
							|  |  |  | 		fi | 
					
						
							|  |  |  | 	done | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-26 14:00:52 +00:00
										 |  |  | check_installed_pkgs() { | 
					
						
							|  |  |  | 	for pack in "$@" | 
					
						
							|  |  |  | 	do | 
					
						
							|  |  |  | 		if [ `pkg_info -a | grep $pack | wc -l` = 0 ]; then | 
					
						
							|  |  |  | 		echo $pack | 
					
						
							|  |  |  | 		fi | 
					
						
							|  |  |  | 	done | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-12 20:34:38 +00:00
										 |  |  | handle_debian() { | 
					
						
							|  |  |  | 	# echo "# Distribution is Debian or compatible" | 
					
						
							|  |  |  | 	extra_packs=`check_installed_debs $PACKAGES_DEBIAN` | 
					
						
							| 
									
										
										
										
											2009-07-24 14:35:49 +00:00
										 |  |  | 	$testcmd aptitude install -y $extra_packs | 
					
						
							| 
									
										
										
										
											2008-05-12 20:34:38 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | handle_rh() { | 
					
						
							|  |  |  | 	# echo "# Distribution is RedHat-based or compatible" | 
					
						
							|  |  |  | 	extra_packs=`check_installed_rpms $PACKAGES_RH` | 
					
						
							|  |  |  |         # FIXME: is there yum with RHEL 4? | 
					
						
							|  |  |  | 	$testcmd yum install -y $extra_packs | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-07-26 14:00:52 +00:00
										 |  |  | handle_obsd() { | 
					
						
							|  |  |  | 	# echo "# Distribution is OpenBSD or compatible" | 
					
						
							|  |  |  | 	extra_packs=`check_installed_pkgs $PACKAGES_OBSD` | 
					
						
							|  |  |  | 	$testcmd pkg_add $extra_packs | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-06-09 10:45:10 +00:00
										 |  |  | install_unpackaged() { | 
					
						
							|  |  |  | 	echo "*** Installing NBS (Network Broadcast Sound) ***" | 
					
						
							|  |  |  | 	svn co http://svn.digium.com/svn/nbs/trunk nbs-trunk | 
					
						
							|  |  |  | 	cd nbs-trunk | 
					
						
							|  |  |  | 	make && make install | 
					
						
							|  |  |  | 	cd .. | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	echo "*** Installing libresample ***" | 
					
						
							|  |  |  | 	svn co http://svn.digium.com/svn/thirdparty/libresample/trunk libresample-trunk | 
					
						
							|  |  |  | 	cd libresample-trunk | 
					
						
							|  |  |  | 	./configure && make && make install | 
					
						
							|  |  |  | 	cd .. | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-05-12 20:34:38 +00:00
										 |  |  | if in_test_mode; then | 
					
						
							|  |  |  | 	echo "#############################################" | 
					
						
							|  |  |  | 	echo "## $1: test mode." | 
					
						
							|  |  |  | 	echo "## Use the commands here to install your system." | 
					
						
							|  |  |  | 	echo "#############################################" | 
					
						
							| 
									
										
										
										
											2010-06-09 10:45:10 +00:00
										 |  |  | elif test "${unpackaged}" = "yes" ; then | 
					
						
							|  |  |  | 	install_unpackaged | 
					
						
							|  |  |  | 	exit 0 | 
					
						
							| 
									
										
										
										
											2008-05-12 20:34:38 +00:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | OS=`uname -s` | 
					
						
							|  |  |  | unsupported_distro='' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # A number of distributions we don't (yet?) support. | 
					
						
							| 
									
										
										
										
											2009-07-26 14:00:52 +00:00
										 |  |  | if [ "$OS" != 'Linux' -a "$OS" != 'OpenBSD' ]; then | 
					
						
							| 
									
										
										
										
											2008-05-12 20:34:38 +00:00
										 |  |  |   echo >&2 "$0: Your OS ($OS) is currently not supported. Aborting." | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [ -f /etc/gentoo-release ]; then | 
					
						
							|  |  |  |   unsupported_distro='Gentoo' | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [ -f /etc/mandrake-release ]; then | 
					
						
							|  |  |  |   unsupported_distro='Mandriva' | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [ -f /etc/SuSE-release ]; then | 
					
						
							|  |  |  |   unsupported_distro='SUSE' | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [ -f /etc/slackware-version ]; then | 
					
						
							|  |  |  |   unsupported_distro='Slackware' | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if [ "$unsupported_distro" != '' ]; then | 
					
						
							|  |  |  |   echo >&2 "$0: Your distribution ($unsupported_distro) is currently not supported. Aborting." | 
					
						
							|  |  |  |   exit 1 | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # The distributions we do support: | 
					
						
							|  |  |  | if [ -r /etc/debian_version ]; then | 
					
						
							|  |  |  |   handle_debian | 
					
						
							|  |  |  | elif [ -r /etc/redhat-release ]; then | 
					
						
							|  |  |  |   handle_rh | 
					
						
							| 
									
										
										
										
											2009-07-26 14:00:52 +00:00
										 |  |  | elif [ "$OS" = 'OpenBSD' ]; then | 
					
						
							|  |  |  |   handle_obsd | 
					
						
							| 
									
										
										
										
											2008-05-12 20:34:38 +00:00
										 |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if ! in_test_mode; then | 
					
						
							|  |  |  |   echo "#############################################" | 
					
						
							|  |  |  |   echo "## $1 completed successfully" | 
					
						
							|  |  |  |   echo "#############################################" | 
					
						
							|  |  |  | fi |