#!/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 sqlite3 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 Could not find asterisk user. ## 2 Could not find asterisk group. ## 4 pear is not installed. ## 8 pear is not up to date ## 16 sqlite3 is not 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 asteriskuser=1 asteriskgroup=2 pear=4 pearupgrade=8 sqlite3=16 # The error messages that correspond to above are as follows errorheader=" The following installation problem or problems were detected: " asteriskusermsg=" - The build of FreePBX in PADS requires there be an asterisk user on the host build system. You do not appear to have one. You should create one before running the FreePBX build." asteriskgroupmsg=" - The build of FreePBX in PADS requires there be an asterisk group on the host build system. You do not appear to have one. You should create one before running the FreePBX build." 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 command \"pear upgrade-all\"" sqlite3msg=" - You need sqlite3 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." # Set our return to success to start status=$success # Check if there is an asterisk user and update eror if [[ ! `cat /etc/passwd | grep asterisk` ]]; then status=`expr $status + $asteriskuser` fi # Check if there is an asterisk group and update eror if [[ ! `cat /etc/group | grep asterisk` ]]; then status=`expr $status + $asteriskgroup` fi # 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 sqlite3 is installed if [[ ! `which sqlite3 | grep /sqlite3` ]]; then status=`expr $status + $sqlite3` fi # Output an appropriate error message. Ugly but works. if [ $status = "0" ]; then echo "SUCCESS" elif [ $status = "1" ]; then echo "$errorheader $asteriskusermsg" elif [ $status = "2" ]; then echo "$errorheader $asteriskgroupmsg" elif [ $status = "3" ]; then echo "$errorheader $asteriskusermsg $asteriskgroupmsg" elif [ $status = "4" ]; then echo "$errorheader $pearmsg" elif [ $status = "5" ]; then echo "$errorheader $asteriskusermsg $pearmsg" elif [ $status = "6" ]; then echo "$errorheader $asteriskgroupmsg $pearmsg" elif [ $status = "7" ]; then echo "$errorheader $asteriskusermsg $asteriskgroupmsg $pearmsg" elif [ $status = "8" ]; then echo "$errorheader $pearupgrademsg" elif [ $status = "9" ]; then echo "$errorheader $asteriskusermsg $pearupgrademsg" elif [ $status = "10" ]; then echo "$errorheader $asteriskgroupmsg $pearupgrademsg" elif [ $status = "11" ]; then echo "$errorheader $asteriskusermsg $asteriskgroupmsg $pearupgrademsg" elif [ $status = "12" ]; then echo "$errorheader $pearmsg $pearupgrademsg" elif [ $status = "13" ]; then echo "$errorheader $asteriskusermsg $pearmsg $pearupgrademsg" elif [ $status = "14" ]; then echo "$errorheader $asteriskgroupmsg $pearmsg $pearupgrademsg" elif [ $status = "15" ]; then echo "$errorheader $asteriskusermsg $asteriskgroupmsg $pearmsg $pearupgrademsg" elif [ $status = "16" ]; then echo "$errorheader $sqlite3msg" elif [ $status = "17" ]; then echo "$errorheader $asteriskusermsg $sqlite3msg" elif [ $status = "18" ]; then echo "$errorheader $asteriskgroupmsg $sqlite3msg" elif [ $status = "19" ]; then echo "$errorheader $asteriskusermsg $asteriskgroupmsg $sqlite3msg" elif [ $status = "20" ]; then echo "$errorheader $pearmsg $sqlite3msg" elif [ $status = "21" ]; then echo "$errorheader $asteriskusermsg $pearmsg $sqlite3msg" elif [ $status = "22" ]; then echo "$errorheader $asteriskgroupmsg $pearmsg $sqlite3msg" elif [ $status = "23" ]; then echo "$errorheader $asteriskusermsg $asteriskgroupmsg $pearmsg $sqlite3msg" elif [ $status = "24" ]; then echo "$errorheader $pearupgrademsg $sqlite3msg" elif [ $status = "25" ]; then echo "$errorheader $asteriskusermsg $pearupgrademsg $sqlite3msg" elif [ $status = "26" ]; then echo "$errorheader $asteriskgroupmsg $pearupgrademsg $sqlite3msg" elif [ $status = "27" ]; then echo "$errorheader $asteriskusermsg $asteriskgroupmsg $pearupgrademsg $sqlite3msg" elif [ $status = "28" ]; then echo "$errorheader $pearmsg $pearupgrademsg $sqlite3msg" elif [ $status = "29" ]; then echo "$errorheader $asteriskusermsg $pearmsg $pearupgrademsg $sqlite3msg" elif [ $status = "30" ]; then echo "$errorheader $asteriskgroupmsg $pearmsg $pearupgrademsg $sqlite3msg" elif [ $status = "31" ]; then echo "$errorheader $asteriskusermsg $asteriskgroupmsg $pearmsg $pearupgrademsg $sqlite3msg" fi exit $status