6 # install_prereq: a script to install distribution-specific
12 echo "$0: a script to install distribution-specific prerequirement"
15 echo "Usage: $0: Shows this message."
16 echo "Usage: $0 test Prints commands it is about to run."
17 echo "Usage: $0 install Really install."
21 PACKAGES_DEBIAN="build-essential"
22 # Asterisk: basic requirements:
23 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libncurses-dev libz-dev libssl-dev"
24 # Asterisk: very useful addons:
25 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libcurl-dev libspeex-dev libogg-dev libvorbis-dev libasound2-dev"
26 # Asterisk: nice-to-have addons:
27 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libpq-dev unixodbc-dev libsqlite-dev"
29 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libopenh323-dev"
31 PACKAGES_DEBIAN="$PACKAGES_DEBIAN libsnmp-dev libiksemel-dev "
33 PACKAGES_RH="gcc gcc-c++ ncurses-devel openssl-devel"
39 install) testcmd='' ;;
48 # Fixme: should be done by apt and not by dpkg?
49 check_installed_debs() {
50 dpkg-query -W --showformat '${Status} ${Package}\n' "$@" 2>/dev/null \
51 | awk '/ not-installed/{print $4}'
54 # parsing the output of yum is close to impossible.
55 # We'll use rpm and hope for the best:
56 check_installed_rpms() {
59 if ! rpm -q $pack >/dev/null 2>/dev/null
66 # echo "# Distribution is Debian or compatible"
67 extra_packs=`check_installed_debs $PACKAGES_DEBIAN`
68 $testcmd apt-get install -y $extra_packs
72 # echo "# Distribution is RedHat-based or compatible"
73 extra_packs=`check_installed_rpms $PACKAGES_RH`
74 # FIXME: is there yum with RHEL 4?
75 $testcmd yum install -y $extra_packs
79 echo "#############################################"
80 echo "## $1: test mode."
81 echo "## Use the commands here to install your system."
82 echo "#############################################"
88 # A number of distributions we don't (yet?) support.
89 if [ "$OS" != 'Linux' ]; then
90 echo >&2 "$0: Your OS ($OS) is currently not supported. Aborting."
94 if [ -f /etc/gentoo-release ]; then
95 unsupported_distro='Gentoo'
98 if [ -f /etc/mandrake-release ]; then
99 unsupported_distro='Mandriva'
102 if [ -f /etc/SuSE-release ]; then
103 unsupported_distro='SUSE'
106 if [ -f /etc/slackware-version ]; then
107 unsupported_distro='Slackware'
110 if [ "$unsupported_distro" != '' ]; then
111 echo >&2 "$0: Your distribution ($unsupported_distro) is currently not supported. Aborting."
115 # The distributions we do support:
116 if [ -r /etc/debian_version ]; then
118 elif [ -r /etc/redhat-release ]; then
122 if ! in_test_mode; then
123 echo "#############################################"
124 echo "## $1 completed successfully"
125 echo "#############################################"