2011-09-08 21:10:33 +02:00
|
|
|
#!/bin/bash -e
|
|
|
|
#-e Causes bash script to exit if any of the installers
|
|
|
|
#return with a non-zero return value.
|
2011-05-31 18:45:27 +02:00
|
|
|
|
2012-04-03 01:25:27 +02:00
|
|
|
if [[ $EUID -ne 0 ]]; then
|
2011-09-20 17:25:56 +02:00
|
|
|
echo "Please run as root user."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-08-03 15:42:41 +02:00
|
|
|
|
2011-11-30 23:59:00 +01:00
|
|
|
showhelp () {
|
|
|
|
echo "Usage: airtime-install [options]
|
2011-12-23 21:32:48 +01:00
|
|
|
--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
|
|
|
|
--web|-w Install only files for web-server
|
2012-04-05 20:56:11 +02:00
|
|
|
--liquidsoap-keep-alive|-l Keep Liquidsoap alive when upgrading"
|
2011-11-30 23:59:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
overwrite="f"
|
|
|
|
preserve="f"
|
2011-12-02 19:51:57 +01:00
|
|
|
nodb="f"
|
2011-11-30 23:59:00 +01:00
|
|
|
reinstall="f"
|
|
|
|
mediamonitor="f"
|
|
|
|
pypo="f"
|
|
|
|
showrecorder="f"
|
|
|
|
web="f"
|
2011-12-15 17:16:14 +01:00
|
|
|
liquidsoap_keep_alive="f"
|
2012-08-03 17:13:17 +02:00
|
|
|
disable_deb_check="f"
|
2011-11-30 23:59:00 +01:00
|
|
|
|
2012-08-03 17:13:17 +02:00
|
|
|
set -- $(getopt -l help,overwrite,preserve,no-db,reinstall,media-monitor,pypo,web,liquidsoap-keep-alive,disable-deb-check "hopnrmywld" "$@")
|
2011-11-30 23:59:00 +01:00
|
|
|
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";;
|
|
|
|
(-w|--web) web="t";;
|
2011-12-15 17:16:14 +01:00
|
|
|
(-l|--liquidsoap-keep-alive) liquidsoap_keep_alive="t";;
|
2012-08-03 17:13:17 +02:00
|
|
|
(-d|--disable-deb-check) disable_deb_check="t";;
|
2011-11-30 23:59:00 +01:00
|
|
|
|
|
|
|
(--) shift; break;;
|
|
|
|
(-*) echo "$0: error - unrecognized option $1" 1>&2; exit 1;;
|
|
|
|
(*) break;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2012-05-16 22:39:13 +02:00
|
|
|
if [ "$mediamonitor" = "f" -a "$pypo" = "f" -a "$web" = "f" ]; then
|
2011-11-30 23:59:00 +01:00
|
|
|
#none of these install parameters were specified, so by default we install all of them
|
|
|
|
mediamonitor="t"
|
|
|
|
pypo="t"
|
|
|
|
showrecorder="t"
|
|
|
|
web="t"
|
|
|
|
fi
|
|
|
|
|
2012-08-03 17:13:17 +02:00
|
|
|
if [ "$disable_deb_check" == "f" ]; then
|
|
|
|
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
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#Update apt sources.list to point to the new deb-multimedia domain.
|
|
|
|
sed -i s/www.debian-multimedia.org/www.deb-multimedia.org/g /etc/apt/sources.list
|
|
|
|
|
2011-10-27 21:22:35 +02:00
|
|
|
# Absolute path to this script, e.g. /home/user/bin/foo.sh
|
2011-07-21 20:39:02 +02:00
|
|
|
SCRIPT=`readlink -f $0`
|
2011-10-27 21:22:35 +02:00
|
|
|
# Absolute path this script is in, thus /home/user/bin
|
2011-07-21 20:39:02 +02:00
|
|
|
SCRIPTPATH=`dirname $SCRIPT`
|
2011-11-01 19:07:56 +01:00
|
|
|
AIRTIMEROOT=$SCRIPTPATH/../
|
|
|
|
|
2012-04-25 16:11:24 +02:00
|
|
|
#Check if required zend mvc library is present. This is a temporary workaround for 2.0.1,
|
|
|
|
#and we should probably create a separate file that checks whether ALL dependencies are satisfied before
|
2012-02-09 22:22:59 +01:00
|
|
|
#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...
|
2012-04-25 16:26:45 +02:00
|
|
|
|
|
|
|
set +e
|
2012-02-09 22:22:59 +01:00
|
|
|
dpkg -l | grep zendframework > /dev/null 2>&1
|
|
|
|
ZENDFRAMEWORK=$?
|
|
|
|
|
|
|
|
dpkg -l | grep libzend-framework-php > /dev/null 2>&1
|
|
|
|
LIBZEND=$?
|
2012-05-10 20:46:22 +02:00
|
|
|
|
|
|
|
dpkg -l | grep lsof > /dev/null 2>&1
|
|
|
|
LSOF_EXIST=$?
|
|
|
|
|
|
|
|
dpkg -l | grep sudo > /dev/null 2>&1
|
|
|
|
SUDO_EXIST=$?
|
|
|
|
|
2012-02-09 22:22:59 +01:00
|
|
|
set -e
|
|
|
|
|
|
|
|
if [ "$ZENDFRAMEWORK" != "0" -a "$LIBZEND" != "0" ]; then
|
|
|
|
echo "zendframework/libzend-framework-php package missing. Please run airtime-full-install"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-05-10 20:46:22 +02:00
|
|
|
if [ "$LSOF_EXIST" != "0" -o "$SUDO_EXIST" != "0" ]; then
|
|
|
|
echo "Packages missing. Please run airtime-full-install"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-05-15 00:52:06 +02:00
|
|
|
echo "* Making sure /etc/default/locale is set properly"
|
|
|
|
set +e
|
|
|
|
update-locale
|
|
|
|
cat /etc/default/locale | grep -i "LANG=.*UTF-\?8"
|
|
|
|
if [ "$?" != "0" ]; then
|
2012-07-10 00:58:22 +02:00
|
|
|
echo -e " * Fail\n"
|
|
|
|
echo "A non UTF-8 default locale found in /etc/default/locale. Airtime requires
|
|
|
|
a UTF-8 locale to run. To fix this please do the following:
|
|
|
|
|
|
|
|
Ubuntu:
|
|
|
|
Put line 'en_US.UTF-8 UTF-8' (or similar) without quotes to '/var/lib/locales/supported.d/local',
|
|
|
|
replacing any existing lines.
|
|
|
|
A list of supported locales is available in '/usr/share/i18n/SUPPORTED'
|
|
|
|
Then run 'sudo dpkg-reconfigure locales'
|
|
|
|
|
|
|
|
Debian:
|
|
|
|
Run 'sudo dpkg-reconfigure locales' and use the interface to select 'en_US.UTF-8 UTF-8' (or similar).
|
|
|
|
On the second page select this new locale as the default.
|
|
|
|
|
|
|
|
After these changes have been made simply run install again.
|
|
|
|
|
|
|
|
Now exiting install...
|
|
|
|
"
|
2012-05-15 00:52:06 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
2012-07-10 00:58:22 +02:00
|
|
|
set -e
|
2012-05-15 00:52:06 +02:00
|
|
|
|
2011-11-18 20:06:42 +01:00
|
|
|
# Check if airtime exists already
|
2011-11-23 19:59:10 +01:00
|
|
|
set +e
|
2011-11-30 23:59:00 +01:00
|
|
|
php --php-ini ${SCRIPTPATH}/airtime-php.ini ${SCRIPTPATH}/include/airtime-installed-check.php
|
2011-11-23 19:59:10 +01:00
|
|
|
result=$?
|
|
|
|
set -e
|
2011-11-30 23:59:00 +01:00
|
|
|
|
|
|
|
DO_UPGRADE="0"
|
|
|
|
if [ "$result" -eq "0" ]; then
|
|
|
|
echo " * None found."
|
2012-05-16 18:57:11 +02:00
|
|
|
|
|
|
|
#Make sure any straggler config files are removed. Reason for this is that they may be from
|
|
|
|
#an older version of Airtime, but since there no database installed, we have no idea how to
|
|
|
|
#handle these (what version are they from?).
|
|
|
|
rm -f "/etc/airtime/airtime.conf"
|
|
|
|
rm -f "/etc/airtime/api_client.cfg"
|
|
|
|
rm -f "/etc/airtime/liquidsoap.cfg"
|
|
|
|
rm -f "/etc/airtime/media-monitor.cfg"
|
|
|
|
rm -f "/etc/airtime/pypo.cfg"
|
2011-12-02 19:51:57 +01:00
|
|
|
elif [ "$result" -eq "1" -a "$reinstall" = "f" ]; then
|
2012-07-16 21:34:09 +02:00
|
|
|
echo " * Same version of Airtime already installed! Reusing database."
|
|
|
|
nodb='t'
|
2012-07-16 21:43:17 +02:00
|
|
|
overwrite='f'
|
2011-11-30 23:59:00 +01:00
|
|
|
elif [ "$result" -eq "2" ]; then
|
2012-07-16 21:34:09 +02:00
|
|
|
echo " * Previous version of Airtime already installed..will perform upgrade."
|
2011-11-23 22:49:03 +01:00
|
|
|
DO_UPGRADE="1"
|
2011-11-30 23:59:00 +01:00
|
|
|
elif [ "$result" -eq "3" ]; then
|
2012-07-16 21:34:09 +02:00
|
|
|
echo " * You require at least Airtime 1.8.0 installed for upgrade."
|
2011-11-24 23:04:24 +01:00
|
|
|
exit 1
|
2011-11-23 22:49:03 +01:00
|
|
|
fi
|
|
|
|
|
2012-02-12 17:44:23 +01:00
|
|
|
#We don't want any of our python services running if we are doing an upgrade/reinstall.
|
|
|
|
#They will be automatically restarted later on.
|
2012-04-05 21:32:03 +02:00
|
|
|
echo "* Temporarily stopping any previous running services"
|
2012-02-12 17:44:23 +01:00
|
|
|
if [ -e /etc/init.d/airtime-media-monitor ]; then
|
2012-04-05 21:09:20 +02:00
|
|
|
invoke-rc.d airtime-media-monitor stop > /dev/null 2>&1
|
2012-02-12 17:44:23 +01:00
|
|
|
fi
|
|
|
|
if [ -e /etc/init.d/airtime-playout ]; then
|
2012-04-05 21:09:20 +02:00
|
|
|
invoke-rc.d airtime-playout stop > /dev/null 2>&1
|
2012-02-12 17:44:23 +01:00
|
|
|
fi
|
2011-11-30 23:59:00 +01:00
|
|
|
|
|
|
|
#export these variables to make them available in sub bash scripts
|
2011-11-23 22:49:03 +01:00
|
|
|
export DO_UPGRADE
|
2011-11-30 23:59:00 +01:00
|
|
|
export mediamonitor
|
|
|
|
export pypo
|
|
|
|
export showrecorder
|
|
|
|
export web
|
|
|
|
export reinstall
|
|
|
|
export nodb
|
|
|
|
export overwrite
|
|
|
|
export preserve
|
2011-12-15 17:16:14 +01:00
|
|
|
export liquidsoap_keep_alive
|
2011-11-23 19:59:10 +01:00
|
|
|
|
2011-11-30 23:59:00 +01:00
|
|
|
set +e
|
2012-05-16 22:39:13 +02:00
|
|
|
test "$mediamonitor" = "t" -o "$pypo" = "t"
|
2011-11-30 23:59:00 +01:00
|
|
|
export python_service=$?
|
|
|
|
set -e
|
2011-11-18 20:06:42 +01:00
|
|
|
|
|
|
|
echo -e "\n******************************** Install Begin *********************************"
|
2012-02-25 03:00:59 +01:00
|
|
|
rm -rf "/usr/lib/airtime"
|
2011-11-30 23:59:00 +01:00
|
|
|
if [ "$python_service" -eq "0" ]; then
|
|
|
|
$AIRTIMEROOT/python_apps/python-virtualenv/virtualenv-install.sh
|
2011-11-23 22:01:08 +01:00
|
|
|
|
2011-11-30 23:59:00 +01:00
|
|
|
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
|
|
|
|
. ${virtualenv_bin}activate
|
|
|
|
python $AIRTIMEROOT/python_apps/create-pypo-user.py
|
|
|
|
fi
|
2011-11-23 22:01:08 +01:00
|
|
|
|
2011-11-01 19:07:56 +01:00
|
|
|
|
2011-11-28 10:57:28 +01:00
|
|
|
if [ "$DO_UPGRADE" -eq "1" ]; then
|
2011-11-23 19:59:10 +01:00
|
|
|
#do upgrade
|
|
|
|
php --php-ini ${SCRIPTPATH}/airtime-php.ini ${SCRIPTPATH}/include/airtime-upgrade.php $@
|
|
|
|
fi
|
|
|
|
|
2012-05-06 03:34:09 +02:00
|
|
|
set +e
|
|
|
|
if [ "$DO_UPGRADE" -eq "0" ]; then
|
|
|
|
php --php-ini ${SCRIPTPATH}/airtime-php.ini ${SCRIPTPATH}/include/airtime-install.php $@
|
|
|
|
result=$?
|
|
|
|
|
|
|
|
if [ "$result" -ne "0" ]; then
|
|
|
|
#There was an error, exit with error code.
|
|
|
|
echo "There was an error during install. Exit code $result"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
set -e
|
|
|
|
|
2012-05-28 23:42:48 +02:00
|
|
|
export airtime_service_start='t'
|
2011-10-27 21:22:35 +02:00
|
|
|
$SCRIPTPATH/include/airtime-copy-files.sh
|
2011-10-27 21:53:54 +02:00
|
|
|
$SCRIPTPATH/include/airtime-initialize.sh $@
|
2011-05-31 22:05:48 +02:00
|
|
|
|
2012-05-16 22:39:13 +02:00
|
|
|
if [ "$mediamonitor" = "t" -o "$pypo" = "t" ]; then
|
2011-11-30 23:59:00 +01:00
|
|
|
#deactivate virtualenv
|
|
|
|
deactivate
|
|
|
|
fi
|
|
|
|
|
2011-11-24 23:14:31 +01:00
|
|
|
|
2011-11-30 23:59:00 +01:00
|
|
|
/usr/lib/airtime/utils/rabbitmq-update-pid.sh > /dev/null
|
2011-10-28 23:24:38 +02:00
|
|
|
|
2012-02-12 07:21:28 +01:00
|
|
|
touch /usr/share/airtime/public/index.php
|
2012-02-12 07:16:32 +01:00
|
|
|
|
2011-11-30 23:59:00 +01:00
|
|
|
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
|
2011-10-28 23:24:38 +02:00
|
|
|
|
2011-11-30 23:59:00 +01:00
|
|
|
airtime-check-system --no-color
|
|
|
|
fi
|
2011-11-23 22:01:08 +01:00
|
|
|
|
2011-06-01 18:32:42 +02:00
|
|
|
echo -e "\n******************************* Install Complete *******************************"
|