#!/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 showhelp () { echo "Usage: airtime-install [options] --help|-h Displays usage information. --overwrite|-o Overwrite any existing config files. --preserve|-p Keep any existing config files. --no-db|-n Turn off database install. --reinstall|-r Force a fresh install of this Airtime Version --media-monitor|-m Install only media-monitor --pypo|-p Install only pypo and liquidsoap --show-recorder|-s Install only show-recorder --web|-w Install only files for web-server --liquidsoap-keep-alive|-l Keep Liquidsoap alive when upgrading --disable-auto-start-services|-d Disable auto-starting Airtime services" } overwrite="f" preserve="f" nodb="f" reinstall="f" mediamonitor="f" pypo="f" showrecorder="f" web="f" liquidsoap_keep_alive="f" disable_auto_start_services="f" set -- $(getopt -l help,overwrite,preserve,no-db,reinstall,media-monitor,pypo,show-recorder,web,liquidsoap-keep-alive,disable-auto-start-services "hopnrmyswld" "$@") while [ $# -gt 0 ] do case "$1" in (-h|--help) showhelp; exit 0;; (-o|--overwrite) overwrite="t";; (-p|--preserve) preserve="t";; (-n|--no-db) nodb="t";; (-r|--reinstall) reinstall="t";; (-m|--media-monitor) mediamonitor="t";; (-y|--pypo) pypo="t";; (-s|--show-recorder) showrecorder="t";; (-w|--web) web="t";; (-l|--liquidsoap-keep-alive) liquidsoap_keep_alive="t";; (-d|--disable-auto-start-services) disable_auto_start_services="t";; (--) shift; break;; (-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;; (*) break;; esac shift done if [ "$mediamonitor" = "f" -a "$pypo" = "f" -a "$showrecorder" = "f" -a "$web" = "f" ]; then #none of these install parameters were specified, so by default we install all of them mediamonitor="t" pypo="t" showrecorder="t" web="t" 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 required zend mvc and php-db libraries are present. This is a temporary workaround for 2.0.1, #and we should probably create a seperate file that checks whether ALL dependencies are satisfied before #allowing the install to continue. However in that case, we wouldn't check for Debian packages so that we #can become less Debian platform dependent in the future... set +e dpkg -l | grep php-db > /dev/null 2>&1 PHP_DB=$? dpkg -l | grep zendframework > /dev/null 2>&1 ZENDFRAMEWORK=$? dpkg -l | grep libzend-framework-php > /dev/null 2>&1 LIBZEND=$? set -e if [ "$PHP_DB" != "0" ]; then echo "php-db package missing. Please run airtime-full-install" exit 1 fi if [ "$ZENDFRAMEWORK" != "0" -a "$LIBZEND" != "0" ]; then echo "zendframework/libzend-framework-php package missing. Please run airtime-full-install" exit 1 fi # Check if airtime exists already set +e php --php-ini ${SCRIPTPATH}/airtime-php.ini ${SCRIPTPATH}/include/airtime-installed-check.php result=$? set -e DO_UPGRADE="0" if [ "$result" -eq "0" ]; then echo " * None found." elif [ "$result" -eq "1" -a "$reinstall" = "f" ]; then echo " * Same version of Airtime already installed!" exit 1; elif [ "$result" -eq "2" ]; then echo " * Previous version of Airtime already installed..will perform upgrade" DO_UPGRADE="1" elif [ "$result" -eq "3" ]; then echo " * You require at least Airtime 1.8.0 installed for upgrade" exit 1 fi #We don't want any of our python services running if we are doing an upgrade/reinstall. #They will be automatically restarted later on. if [ -e /etc/init.d/airtime-media-monitor ]; then /etc/init.d/airtime-media-monitor stop > /dev/null 2>&1 fi if [ -e /etc/init.d/airtime-playout ]; then /etc/init.d/airtime-playout stop > /dev/null 2>&1 fi if [ -e /etc/init.d/airtime-show-recorder ]; then /etc/init.d/airtime-show-recorder stop > /dev/null 2>&1 fi #export these variables to make them available in sub bash scripts export DO_UPGRADE export mediamonitor export pypo export showrecorder export web export reinstall export nodb export overwrite export preserve export liquidsoap_keep_alive export disable_auto_start_services set +e test "$mediamonitor" = "t" -o "$pypo" = "t" -o "$showrecorder" = "t" export python_service=$? set -e echo -e "\n******************************** Install Begin *********************************" rm -rf "/usr/lib/airtime" if [ "$python_service" -eq "0" ]; then $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 fi if [ "$DO_UPGRADE" -eq "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 $@ if [ "$mediamonitor" = "t" -o "$pypo" = "t" -o "$showrecorder" = "t" ]; then #deactivate virtualenv deactivate fi /usr/lib/airtime/utils/rabbitmq-update-pid.sh > /dev/null touch /usr/share/airtime/public/index.php if [ "$python_service" -eq "0" ]; then #only run airtime-check-system if all components were installed echo -e "\n*** Verifying your system environment, running airtime-check-system ***" sleep 15 airtime-check-system --no-color fi echo -e "\n******************************* Install Complete *******************************"