#!/bin/bash ## This is a shell script to verify certain things on the Linux distribution ## we are attempting to build FreePBX on. We check the following items: ## + Existence of asterisk user and group ## + Whether pear is installed and up to date. ## + Whether peardb is installed. ## ## The following codes are returned to the installer that uses this script ## so that it can output appropriate messages to the user. ## ## Code Meaning ## ==== ======= ## 0 Success - Everything is as we need it to be. ## 1 pear is not installed. ## 2 pear is not up to date ## 4 pear DB package is installed. ## ## The above codes can also be used in combination. All errors found will be ## output as a list. ## # The list of error values success=0 pear=1 pearupgrade=2 peardb=4 # The error messages that correspond to above are as follows errorheader=" The following installation problem or problems were detected: " pearmsg=" - You need php-pear to be installed on your build system in order to build FreePBX. You do not appear to have it installed. Please do so using your appropriate package management tool." pearupgrademsg=" - The php-pear installed on your system does not appear to be up to date. It is recommended that you update this before building FreePBX as it can cause problems in compilation if it is not up to date. You can upgrade you pear install by running the shell commands \"pear update-channels\" and \"pear upgrade-all\" It is highly recommended that you do this. If your build fails during build of php-pear-db package, failure to update will be the reason." peardbmsg=" - You need pear-db to be uninstalled on your build system in order to build FreePBX. You appear to have it installed. Please remove it by running the shell command \"pear uninstall DB\"" # Set our return to success to start status=$success # Check if pear is installed and up to date if [[ ! `which pear | grep /pear` ]]; then status=`expr $status + $pear` else if [[ ! `pear list-upgrades | grep No` ]]; then status=`expr $status + $pearupgrade` fi fi # Check if peardb is installed if [[ `pear list | grep DB` ]]; then status=`expr $status + $peardb` fi # Output an appropriate error message. Ugly but works. if [ $status = "0" ]; then echo "SUCCESS" elif [ $status = "1" ]; then echo "$errorheader $pearmsg" elif [ $status = "2" ]; then echo "$errorheader $pearupgrademsg" elif [ $status = "3" ]; then echo "$errorheader $pearmsg $pearupgrademsg" elif [ $status = "4" ]; then echo "$errorheader $peardbmsg" elif [ $status = "5" ]; then echo "$errorheader $pearmsg $peardbmsg" elif [ $status = "6" ]; then echo "$errorheader $pearupgrademsg $peardbmsg" elif [ $status = "7" ]; then echo "$errorheader $pearmsg $pearupgrademsg $peardbmsg" fi exit $status