#!/bin/bash -e #-e Causes bash script to exit if any of the installers #return with a non-zero return value. if [ `whoami` != 'root' ]; then echo "Please run as root user." exit 1 fi export INSTALL_PYPO=1 export INSTALL_MEDIA_MONITOR=1 export INSTALL_SHOW_RECORDER=1 set +e DEB=$(dpkg -s airtime 2> /dev/null | grep Status) set -e if [[ "$DEB" = "Status: install ok installed" ]]; then echo -e "\nDebian package of Airtime detected. Please use the debian package to upgrade.\n" exit 1 fi # Absolute path to this script, e.g. /home/user/bin/foo.sh SCRIPT=`readlink -f $0` # Absolute path this script is in, thus /home/user/bin SCRIPTPATH=`dirname $SCRIPT` AIRTIMEROOT=$SCRIPTPATH/../ # Check if airtime exists already set +e DO_UPGRADE="0" php --php-ini ${SCRIPTPATH}/airtime-php.ini ${SCRIPTPATH}/include/airtime-installed-check.php $@ result=$? set -e if [ "$result" -eq "1" ]; then DO_UPGRADE="1" elif [ "$result" -eq "2" -o "$result" -eq "3" ]; then exit 1 elif [ "$result" -eq "4" ]; then exit 0 fi #make DO_UPGRADE available in sub bash scripts export DO_UPGRADE if [ "$result" = "2" -o "$result" = "3" ]; then #error message has already been printed inside the php script exit 1 fi echo -e "\n******************************** Install Begin *********************************" rm -rf "/usr/lib/airtime" $AIRTIMEROOT/python_apps/python-virtualenv/virtualenv-install.sh virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/" . ${virtualenv_bin}activate python $AIRTIMEROOT/python_apps/create-pypo-user.py if [ "$DO_UPGRADE" = "1" ]; then #do upgrade php --php-ini ${SCRIPTPATH}/airtime-php.ini ${SCRIPTPATH}/include/airtime-upgrade.php $@ fi $SCRIPTPATH/include/airtime-copy-files.sh $SCRIPTPATH/include/airtime-initialize.sh $@ #deactivate virtualenv deactivate /usr/lib/airtime/utils/rabbitmq-update-pid.sh echo -e "\n*** Verifying your system environment, running airtime-check-system ***" sleep 10 airtime-check-system echo -e "\n******************************* Install Complete *******************************"