#!/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 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 #Check whether version of virtualenv is <= 1.4.8. If so exit install. BAD_VERSION="1.4.8" VERSION=$(virtualenv --version) NEWEST_VERSION=$(echo -e "$BAD_VERSION\n$VERSION\n'" | sort -t '.' -g | tail -n 1) echo -n "Ensuring python-virtualenv version > $BAD_VERSION..." if [[ "$NEWEST_VERSION" = "$BAD_VERSION" ]]; then URL="http://apt.sourcefabric.org/pool/main/p/python-virtualenv/python-virtualenv_1.4.9-3_all.deb" echo "Failed!" echo "You have version $BAD_VERSION or older installed. Please install package at $URL first and then try installing Airtime again." exit 1 else echo "Success!" fi echo -e "\n******************************** Install Begin *********************************" # 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/../ rm -rf "/usr/lib/airtime" $AIRTIMEROOT/python_apps/python-virtualenv/virtualenv-install.sh python $AIRTIMEROOT/python_apps/create-pypo-user.py $SCRIPTPATH/include/airtime-copy-files.sh $SCRIPTPATH/include/airtime-initialize.sh $@ #Hack to parse rabbitmq pid and place it into the correct directory. This is also #done in our rabbitmq init.d script, but placing it here so that monit recognizes # it faster (in time for the upcoming airtime-check-system) codename=`lsb_release -cs` if [ "$codename" == "oneiric" ]; then rabbitmqstatus=`/etc/init.d/rabbitmq-server status | grep "\[{pid"` rabbitmqpid=`echo $rabbitmqstatus | sed "s/.*,\(.*\)\}.*/\1/"` else rabbitmqpid=`sed "s/.*,\(.*\)\}.*/\1/" /var/lib/rabbitmq/pids` fi echo "RabbitMQ PID: $rabbitmqpid" echo "$rabbitmqpid" > /var/run/rabbitmq.pid echo -e "\n*** Verifying your system environment, running airtime-check-system ***" sleep 10 airtime-check-system echo -e "\n******************************* Install Complete *******************************"