mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-11-04 13:21:54 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			317 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			317 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#! /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 ""
 | 
						|
	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."
 | 
						|
}
 | 
						|
 | 
						|
# Basic build system:
 | 
						|
PACKAGES_DEBIAN="build-essential pkg-config"
 | 
						|
# Asterisk: basic requirements:
 | 
						|
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libedit-dev libjansson-dev libsqlite3-dev uuid-dev libxml2-dev"
 | 
						|
# Asterisk: for addons:
 | 
						|
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libspeex-dev libspeexdsp-dev libogg-dev libvorbis-dev libasound2-dev portaudio19-dev libcurl4-openssl-dev xmlstarlet bison flex"
 | 
						|
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libpq-dev unixodbc-dev libltdl-dev libneon27-dev libgmime-2.6-dev liblua5.2-dev liburiparser-dev libxslt1-dev libssl-dev"
 | 
						|
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libvpb-dev libmysqlclient-dev libbluetooth-dev libradcli-dev freetds-dev libosptk-dev libjack-jackd2-dev bash"
 | 
						|
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libsnmp-dev libiksemel-dev libcorosync-common-dev libcpg-dev libcfg-dev libnewt-dev libpopt-dev libical-dev libspandsp-dev"
 | 
						|
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libresample1-dev libc-client2007e-dev binutils-dev libsrtp0-dev libsrtp2-dev libgsm1-dev doxygen graphviz zlib1g-dev libldap2-dev"
 | 
						|
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libcodec2-dev libfftw3-dev libsndfile1-dev libunbound-dev"
 | 
						|
# Asterisk: for the unpackaged below:
 | 
						|
PACKAGES_DEBIAN="$PACKAGES_DEBIAN wget subversion"
 | 
						|
# Asterisk: for ./configure --with-pjproject-bundled:
 | 
						|
PACKAGES_DEBIAN="$PACKAGES_DEBIAN bzip2 patch python-dev"
 | 
						|
 | 
						|
# Basic build system:
 | 
						|
PACKAGES_RH="make gcc gcc-c++ pkgconfig"
 | 
						|
# Asterisk: basic requirements:
 | 
						|
PACKAGES_RH="$PACKAGES_RH libedit-devel jansson-devel libuuid-devel sqlite-devel libxml2-devel"
 | 
						|
# Asterisk: for addons:
 | 
						|
PACKAGES_RH="$PACKAGES_RH speex-devel speexdsp-devel libogg-devel libvorbis-devel alsa-lib-devel portaudio-devel libcurl-devel xmlstarlet bison flex"
 | 
						|
PACKAGES_RH="$PACKAGES_RH postgresql-devel unixODBC-devel libtool-ltdl-devel neon-devel gmime-devel lua-devel uriparser-devel libxslt-devel openssl-devel"
 | 
						|
PACKAGES_RH="$PACKAGES_RH mysql-devel bluez-libs-devel radcli-devel freetds-devel jack-audio-connection-kit-devel bash"
 | 
						|
PACKAGES_RH="$PACKAGES_RH net-snmp-devel iksemel-devel corosynclib-devel newt-devel popt-devel libical-devel spandsp-devel"
 | 
						|
PACKAGES_RH="$PACKAGES_RH libresample-devel uw-imap-devel binutils-devel libsrtp-devel gsm-devel doxygen graphviz zlib-devel openldap-devel hoard"
 | 
						|
PACKAGES_RH="$PACKAGES_RH codec2-devel fftw-devel libsndfile-devel unbound-devel"
 | 
						|
# Asterisk: for the unpackaged below:
 | 
						|
PACKAGES_RH="$PACKAGES_RH wget subversion"
 | 
						|
# Asterisk: for ./configure --with-pjproject-bundled:
 | 
						|
PACKAGES_RH="$PACKAGES_RH bzip2 patch python-devel"
 | 
						|
 | 
						|
# Basic build system:
 | 
						|
PACKAGES_NBSD="gmake pkg-config"
 | 
						|
# Asterisk: basic requirements:
 | 
						|
PACKAGES_NBSD="$PACKAGES_NBSD editline jansson sqlite3 libuuid libxml2"
 | 
						|
# Asterisk: for addons:
 | 
						|
PACKAGES_NBSD="$PACKAGES_NBSD speex speexdsp libogg libvorbis alsa-lib portaudio-devel curl bison flex"
 | 
						|
PACKAGES_NBSD="$PACKAGES_NBSD postgresql10-client unixodbc libltdl neon gmime lua52 uriparser libxslt openssl"
 | 
						|
PACKAGES_NBSD="$PACKAGES_NBSD mysql-client radiusclient-ng freetds bash"
 | 
						|
PACKAGES_NBSD="$PACKAGES_NBSD net-snmp iksemel popt libical spandsp"
 | 
						|
PACKAGES_NBSD="$PACKAGES_NBSD imap-uw srtp gsm doxygen graphviz libzip openldap-client"
 | 
						|
PACKAGES_NBSD="$PACKAGES_NBSD codec2 fftw libsndfile unbound"
 | 
						|
# Asterisk: for the unpackaged below:
 | 
						|
PACKAGES_NBSD="$PACKAGES_NBSD wget subversion-base"
 | 
						|
# Asterisk: for ./configure --with-pjproject-bundled:
 | 
						|
PACKAGES_NBSD="$PACKAGES_NBSD bzip2 patch python27"
 | 
						|
 | 
						|
# Basic build system:
 | 
						|
PACKAGES_OBSD="gmake"
 | 
						|
# Asterisk: basic requirements:
 | 
						|
PACKAGES_OBSD="$PACKAGES_OBSD libxml sqlite3 e2fsprogs jansson"
 | 
						|
# Asterisk: for addons:
 | 
						|
PACKAGES_OBSD="$PACKAGES_OBSD speex speexdsp libogg libvorbis portaudio-svn curl xmlstarlet bison"
 | 
						|
PACKAGES_OBSD="$PACKAGES_OBSD postgresql-client iodbc libltdl neon gmime lua%5.2 uriparser libxslt"
 | 
						|
PACKAGES_OBSD="$PACKAGES_OBSD mariadb-client radcli freetds"
 | 
						|
PACKAGES_OBSD="$PACKAGES_OBSD net-snmp iksemel popt libical spandsp"
 | 
						|
PACKAGES_OBSD="$PACKAGES_OBSD c-client libsrtp gsm doxygen graphviz"
 | 
						|
PACKAGES_OBSD="$PACKAGES_OBSD fftw3 libsndfile"
 | 
						|
# Asterisk: for the unpackaged below:
 | 
						|
PACKAGES_OBSD="$PACKAGES_OBSD wget subversion"
 | 
						|
# Asterisk: for ./configure --with-pjproject-bundled:
 | 
						|
PACKAGES_OBSD="$PACKAGES_OBSD bzip2 python%2"
 | 
						|
 | 
						|
# Basic build system:
 | 
						|
PACKAGES_FBSD="gmake pkgconf"
 | 
						|
# Asterisk: basic requirements:
 | 
						|
PACKAGES_FBSD="$PACKAGES_FBSD libedit jansson e2fsprogs-libuuid sqlite3 libxml2"
 | 
						|
# Asterisk: for addons:
 | 
						|
PACKAGES_FBSD="$PACKAGES_FBSD speex speexdsp libogg libvorbis alsa-lib portaudio curl xmlstarlet bison flex"
 | 
						|
PACKAGES_FBSD="$PACKAGES_FBSD postgresql10-client unixODBC libltdl neon gmime26 lua52 uriparser libxslt openssl"
 | 
						|
PACKAGES_FBSD="$PACKAGES_FBSD mysql57-client radcli freetds"
 | 
						|
PACKAGES_FBSD="$PACKAGES_FBSD net-snmp iksemel corosync newt popt libical spandsp"
 | 
						|
PACKAGES_FBSD="$PACKAGES_FBSD cclient libbfd libsrtp gsm libilbc doxygen graphviz libzip openldap-client libhoard"
 | 
						|
# Asterisk: for the unpackaged below:
 | 
						|
PACKAGES_FBSD="$PACKAGES_FBSD wget subversion"
 | 
						|
# Asterisk: for ./configure --with-pjproject-bundled:
 | 
						|
PACKAGES_FBSD="$PACKAGES_FBSD bzip2 patch python"
 | 
						|
 | 
						|
KVERS=`uname -r`
 | 
						|
 | 
						|
JANSSON_VER=2.11
 | 
						|
 | 
						|
case "$1" in
 | 
						|
test)
 | 
						|
	testcmd=echo
 | 
						|
	;;
 | 
						|
install)
 | 
						|
	testcmd=''
 | 
						|
	;;
 | 
						|
install-unpackaged)
 | 
						|
	unpackaged="yes"
 | 
						|
	;;
 | 
						|
'')
 | 
						|
	usage
 | 
						|
	exit 0
 | 
						|
	;;
 | 
						|
*)
 | 
						|
	usage
 | 
						|
	exit 1
 | 
						|
	;;
 | 
						|
esac
 | 
						|
 | 
						|
in_test_mode() {
 | 
						|
	test "$testcmd" != ''
 | 
						|
}
 | 
						|
 | 
						|
check_installed_debs() {
 | 
						|
	for pack in "$@" ; do
 | 
						|
		tocheck="${tocheck} ^${pack}$ ~P^${pack}$"
 | 
						|
	done
 | 
						|
	pkgs=$(aptitude -F '%c %p' search ${tocheck} 2>/dev/null | awk '/^p/{print $2}')
 | 
						|
	if [ ${#pkgs} -ne 0 ]; then
 | 
						|
		echo $pkgs | sed -r -e "s/ ?[^ :]+:i386//g"
 | 
						|
	fi
 | 
						|
}
 | 
						|
 | 
						|
# 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
 | 
						|
}
 | 
						|
 | 
						|
check_installed_pkgs() {
 | 
						|
	for pack in "$@"
 | 
						|
	do
 | 
						|
		if [ `pkg_info -a | grep $pack | wc -l` = 0 ]; then
 | 
						|
		echo $pack
 | 
						|
		fi
 | 
						|
	done
 | 
						|
}
 | 
						|
 | 
						|
check_installed_fpkgs() {
 | 
						|
	for pack in "$@"
 | 
						|
	do
 | 
						|
		if [ `pkg info -a | grep $pack | wc -l` = 0 ]; then
 | 
						|
		echo $pack
 | 
						|
		fi
 | 
						|
	done
 | 
						|
}
 | 
						|
 | 
						|
handle_debian() {
 | 
						|
	if ! [ -x "$(command -v aptitude)" ]; then
 | 
						|
		apt-get install aptitude
 | 
						|
	fi
 | 
						|
	extra_packs=`check_installed_debs $PACKAGES_DEBIAN`
 | 
						|
	$testcmd aptitude update
 | 
						|
	if [ x"$extra_packs" != "x" ] ; then
 | 
						|
		$testcmd aptitude install -y $extra_packs
 | 
						|
	fi
 | 
						|
}
 | 
						|
 | 
						|
handle_rh() {
 | 
						|
	extra_packs=`check_installed_rpms $PACKAGES_RH`
 | 
						|
	if [ x"$extra_packs" != "x" ] ; then
 | 
						|
		$testcmd yum install --skip-broken --assumeyes $extra_packs
 | 
						|
	fi
 | 
						|
}
 | 
						|
 | 
						|
handle_nbsd() {
 | 
						|
	extra_packs=`check_installed_pkgs $PACKAGES_NBSD`
 | 
						|
	if [ x"$extra_packs" != "x" ] ; then
 | 
						|
		if [ -z "$PKG_PATH" ] ; then
 | 
						|
			# see NetBSD Problem Report #48177
 | 
						|
			export PKG_PATH="http://cdn.NetBSD.org/pub/pkgsrc/packages/$(uname -s)/$(uname -p)/$(uname -r)/All"
 | 
						|
		fi
 | 
						|
		$testcmd pkg_add $extra_packs
 | 
						|
	fi
 | 
						|
}
 | 
						|
 | 
						|
handle_obsd() {
 | 
						|
	extra_packs=`check_installed_pkgs $PACKAGES_OBSD`
 | 
						|
	if [ x"$extra_packs" != "x" ] ; then
 | 
						|
		$testcmd pkg_add $extra_packs
 | 
						|
	fi
 | 
						|
}
 | 
						|
 | 
						|
handle_fbsd() {
 | 
						|
	extra_packs=`check_installed_fpkgs $PACKAGES_FBSD`
 | 
						|
	if [ x"$extra_packs" != "x" ] ; then
 | 
						|
		$testcmd pkg install -y $extra_packs
 | 
						|
	fi
 | 
						|
}
 | 
						|
 | 
						|
install_unpackaged() {
 | 
						|
	echo "*** Installing NBS (Network Broadcast Sound) ***"
 | 
						|
	svn co http://svn.digium.com/svn/nbs/trunk nbs-trunk
 | 
						|
	cd nbs-trunk
 | 
						|
	make all install
 | 
						|
	cd ..
 | 
						|
 | 
						|
	# Only install libresample if it wasn't installed via package
 | 
						|
	if ! test -f /usr/include/libresample.h; then
 | 
						|
		echo "*** Installing libresample ***"
 | 
						|
		svn co http://svn.digium.com/svn/thirdparty/libresample/trunk libresample-trunk
 | 
						|
		cd libresample-trunk
 | 
						|
		./configure
 | 
						|
		make all install
 | 
						|
		cd ..
 | 
						|
	fi
 | 
						|
 | 
						|
	# Only install Jansson if it wasn't installed via package
 | 
						|
	if ! test -f /usr/include/jansson.h; then
 | 
						|
		echo "*** Installing jansson ***"
 | 
						|
		wget -O - http://www.digip.org/jansson/releases/jansson-${JANSSON_VER}.tar.gz | zcat | tar -xf -
 | 
						|
		cd jansson-${JANSSON_VER}
 | 
						|
		./configure
 | 
						|
		make all install
 | 
						|
		cd ..
 | 
						|
		echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local.conf
 | 
						|
		/sbin/ldconfig
 | 
						|
	fi
 | 
						|
 | 
						|
	# Only install libsrtp2 if it wasn't installed via package
 | 
						|
	if ! test -f /usr/include/srtp/srtp.h; then
 | 
						|
		if ! test -f /usr/include/srtp2/srtp.h; then
 | 
						|
			echo "*** Installing libsrtp2 ***"
 | 
						|
			wget -O - http://github.com/cisco/libsrtp/archive/v2.tar.gz | zcat | tar -xf -
 | 
						|
			cd libsrtp-2
 | 
						|
			./configure --enable-openssl
 | 
						|
			make shared_library install
 | 
						|
			cd ..
 | 
						|
			echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local.conf
 | 
						|
			/sbin/ldconfig
 | 
						|
		fi
 | 
						|
	fi
 | 
						|
 | 
						|
	if ! test -f /usr/include/pjlib.h; then
 | 
						|
		echo "PJProject not installed, yet. Therefore, please, run"
 | 
						|
		echo "./configure --with-pjproject-bundled"
 | 
						|
	fi
 | 
						|
}
 | 
						|
 | 
						|
if in_test_mode; then
 | 
						|
	echo "#############################################"
 | 
						|
	echo "## $1: test mode."
 | 
						|
	echo "## Use the commands here to install your system."
 | 
						|
	echo "#############################################"
 | 
						|
elif test "${unpackaged}" = "yes" ; then
 | 
						|
	install_unpackaged
 | 
						|
	exit 0
 | 
						|
fi
 | 
						|
 | 
						|
OS=`uname -s`
 | 
						|
unsupported_distro=''
 | 
						|
 | 
						|
# A number of distributions we don't (yet?) support.
 | 
						|
if [ "$OS" != 'Linux' -a "$OS" != 'NetBSD' -a "$OS" != 'OpenBSD' -a "$OS" != 'FreeBSD' ]; then
 | 
						|
	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
 | 
						|
elif [ "$OS" = 'NetBSD' ]; then
 | 
						|
	handle_nbsd
 | 
						|
elif [ "$OS" = 'OpenBSD' ]; then
 | 
						|
	handle_obsd
 | 
						|
elif [ "$OS" = 'FreeBSD' ]; then
 | 
						|
	handle_fbsd
 | 
						|
fi
 | 
						|
 | 
						|
if ! in_test_mode; then
 | 
						|
	echo "#############################################"
 | 
						|
	echo "## $1 completed successfully"
 | 
						|
	echo "#############################################"
 | 
						|
fi
 |