SAAS-83: Add ability to install Airtime components separately

-fixed
This commit is contained in:
Martin Konecny 2011-11-30 17:59:00 -05:00
parent 05dea59e55
commit c48154ef2f
7 changed files with 195 additions and 154 deletions

View File

@ -7,8 +7,6 @@ if [ `whoami` != 'root' ]; then
exit 1
fi
export WEB_ONLY=0
set +e
DEB=$(dpkg -s airtime 2> /dev/null | grep Status)
set -e
@ -17,6 +15,58 @@ if [[ "$DEB" = "Status: install ok installed" ]]; then
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"
}
overwrite="f"
preserve="f"
nodb="t"
reinstall="f"
mediamonitor="f"
pypo="f"
showrecorder="f"
web="f"
set -- $(getopt -l help,overwrite,preserve,no-db,reinstall,media-monitor,pypo,show-recorder,web "hopnrmysw" "$@")
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";;
(--) 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"
nodb="f"
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
@ -24,41 +74,55 @@ SCRIPTPATH=`dirname $SCRIPT`
AIRTIMEROOT=$SCRIPTPATH/../
# Check if airtime exists already
echo "* Checking for existing Airtime installation..."
set +e
DO_UPGRADE="0"
php --php-ini ${SCRIPTPATH}/airtime-php.ini ${SCRIPTPATH}/include/airtime-installed-check.php $@
php --php-ini ${SCRIPTPATH}/airtime-php.ini ${SCRIPTPATH}/include/airtime-installed-check.php
result=$?
set -e
if [ "$result" -eq "1" ]; then
DO_UPGRADE="0"
if [ "$result" -eq "0" ]; then
echo " * None found."
elif [ "$result" -eq "1" ]; 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 "2" -o "$result" -eq "3" ]; then
elif [ "$result" -eq "3" ]; then
echo " * You require at least Airtime 1.8.0 installed for upgrade"
exit 1
elif [ "$result" -eq "4" ]; then
exit 0
elif [ "$result" -eq "5" ]; then
WEB_ONLY=1
fi
#make DO_UPGRADE available in sub bash scripts
#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
if [ "$result" = "2" -o "$result" = "3" ]; then
#error message has already been printed inside the php script
exit 1
fi
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"
$AIRTIMEROOT/python_apps/python-virtualenv/virtualenv-install.sh
if [ "$python_service" -eq "0" ]; then
rm -rf "/usr/lib/airtime"
$AIRTIMEROOT/python_apps/python-virtualenv/virtualenv-install.sh
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
. ${virtualenv_bin}activate
python $AIRTIMEROOT/python_apps/create-pypo-user.py
fi
python $AIRTIMEROOT/python_apps/create-pypo-user.py
if [ "$DO_UPGRADE" -eq "1" ]; then
#do upgrade
php --php-ini ${SCRIPTPATH}/airtime-php.ini ${SCRIPTPATH}/include/airtime-upgrade.php $@
@ -67,14 +131,20 @@ fi
$SCRIPTPATH/include/airtime-copy-files.sh
$SCRIPTPATH/include/airtime-initialize.sh $@
#deactivate virtualenv
deactivate
if [ "$mediamonitor" = "t" -o "$pypo" = "t" -o "$showrecorder" = "t" ]; then
#deactivate virtualenv
deactivate
fi
/usr/lib/airtime/utils/rabbitmq-update-pid.sh
echo -e "\n*** Verifying your system environment, running airtime-check-system ***"
sleep 10
airtime-check-system --no-color
/usr/lib/airtime/utils/rabbitmq-update-pid.sh > /dev/null
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 *******************************"

View File

@ -73,44 +73,47 @@ class AirtimeIni
exit(1);
}
if (!copy(__DIR__."/../../python_apps/api_clients/api_client.cfg", AirtimeIni::CONF_FILE_API_CLIENT)){
echo "Could not copy api_client.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_API_CLIENT, self::CONF_PYPO_GRP)){
echo "Could not set ownership of api_client.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/pypo/pypo.cfg", AirtimeIni::CONF_FILE_PYPO)){
echo "Could not copy pypo.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_PYPO, self::CONF_PYPO_GRP)){
echo "Could not set ownership of pypo.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/show-recorder/recorder.cfg", AirtimeIni::CONF_FILE_RECORDER)){
echo "Could not copy recorder.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_RECORDER, self::CONF_PYPO_GRP)){
echo "Could not set ownership of recorder.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/pypo/liquidsoap_scripts/liquidsoap.cfg", AirtimeIni::CONF_FILE_LIQUIDSOAP)){
echo "Could not copy liquidsoap.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_LIQUIDSOAP, self::CONF_PYPO_GRP)){
echo "Could not set ownership of liquidsoap.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/media-monitor/media-monitor.cfg", AirtimeIni::CONF_FILE_MEDIAMONITOR)){
echo "Could not copy media-monitor.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_MEDIAMONITOR, self::CONF_PYPO_GRP)){
echo "Could not set ownership of media-monitor.cfg to 'pypo'. Exiting.";
exit(1);
if (getenv("python_service") == "0"){
if (!copy(__DIR__."/../../python_apps/api_clients/api_client.cfg", AirtimeIni::CONF_FILE_API_CLIENT)){
echo "Could not copy api_client.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_API_CLIENT, self::CONF_PYPO_GRP)){
echo "Could not set ownership of api_client.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/pypo/pypo.cfg", AirtimeIni::CONF_FILE_PYPO)){
echo "Could not copy pypo.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_PYPO, self::CONF_PYPO_GRP)){
echo "Could not set ownership of pypo.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/show-recorder/recorder.cfg", AirtimeIni::CONF_FILE_RECORDER)){
echo "Could not copy recorder.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_RECORDER, self::CONF_PYPO_GRP)){
echo "Could not set ownership of recorder.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/pypo/liquidsoap_scripts/liquidsoap.cfg", AirtimeIni::CONF_FILE_LIQUIDSOAP)){
echo "Could not copy liquidsoap.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_LIQUIDSOAP, self::CONF_PYPO_GRP)){
echo "Could not set ownership of liquidsoap.cfg to 'pypo'. Exiting.";
exit(1);
}
if (!copy(__DIR__."/../../python_apps/media-monitor/media-monitor.cfg", AirtimeIni::CONF_FILE_MEDIAMONITOR)){
echo "Could not copy media-monitor.cfg to /etc/airtime/. Exiting.";
exit(1);
} else if (!self::ChangeFileOwnerGroupMod(AirtimeIni::CONF_FILE_MEDIAMONITOR, self::CONF_PYPO_GRP)){
echo "Could not set ownership of media-monitor.cfg to 'pypo'. Exiting.";
exit(1);
}
}
}
@ -225,8 +228,10 @@ class AirtimeIni
public static function UpdateIniFiles()
{
$api_key = AirtimeIni::GenerateRandomString();
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_AIRTIME, 'api_key', $api_key);
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_AIRTIME, 'airtime_dir', AirtimeInstall::CONF_DIR_WWW);
if (getenv("web") == "t"){
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_AIRTIME, 'api_key', $api_key);
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_AIRTIME, 'airtime_dir', AirtimeInstall::CONF_DIR_WWW);
}
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_API_CLIENT, 'api_key', "'$api_key'");
}

View File

@ -51,18 +51,23 @@ HOUR=$(($RANDOM%24))
MIN=$(($RANDOM%60))
echo "$MIN $HOUR * * * root /usr/lib/airtime/utils/phone_home_stat" > /etc/cron.d/airtime-crons
#virtualenv_bin="/usr/lib/airtime/airtime_virtualenv/bin/"
#. ${virtualenv_bin}activate
echo "* Creating /usr/lib/airtime"
if [ "$WEB_ONLY" -eq "0" ]; then
if [ "$python_service" -eq "0" ]; then
python $AIRTIMEROOT/python_apps/api_clients/install/api_client_install.py
python $AIRTIMEROOT/python_apps/pypo/install/pypo-copy-files.py
python $AIRTIMEROOT/python_apps/media-monitor/install/media-monitor-copy-files.py
python $AIRTIMEROOT/python_apps/show-recorder/install/recorder-copy-files.py
if [ "$mediamonitor" = "t" ]; then
python $AIRTIMEROOT/python_apps/media-monitor/install/media-monitor-copy-files.py
fi
if [ "$pypo" = "t" ]; then
python $AIRTIMEROOT/python_apps/pypo/install/pypo-copy-files.py
fi
if [ "$showrecorder" = "t" ]; then
python $AIRTIMEROOT/python_apps/show-recorder/install/recorder-copy-files.py
fi
fi
mkdir -p /usr/lib/airtime
cp -R $AIRTIMEROOT/utils /usr/lib/airtime
echo "* Creating symbolic links in /usr/bin"
@ -72,10 +77,12 @@ ln -sf /usr/lib/airtime/utils/airtime-update-db-settings /usr/bin/airtime-update
ln -sf /usr/lib/airtime/utils/airtime-check-system /usr/bin/airtime-check-system
ln -sf /usr/lib/airtime/utils/airtime-log /usr/bin/airtime-log
echo "* Creating /usr/share/airtime"
rm -rf "/usr/share/airtime"
mkdir -p /usr/share/airtime
cp -R $AIRTIMEROOT/airtime_mvc/* /usr/share/airtime/
if [ "$web" = "t" ]; then
echo "* Creating /usr/share/airtime"
rm -rf "/usr/share/airtime"
mkdir -p /usr/share/airtime
cp -R $AIRTIMEROOT/airtime_mvc/* /usr/share/airtime/
fi
echo "* Creating /var/log/airtime"
mkdir -p /var/log/airtime

View File

@ -30,12 +30,17 @@ if [ "$DO_UPGRADE" -eq "0" ]; then
fi
set -e
if [ "$WEB_ONLY" -eq "0" ]; then
python $AIRTIMEROOT/python_apps/pypo/install/pypo-initialize.py
if [ "$mediamonitor" = "t" ]; then
python $AIRTIMEROOT/python_apps/media-monitor/install/media-monitor-initialize.py
fi
if [ "$pypo" = "t" ]; then
python $AIRTIMEROOT/python_apps/pypo/install/pypo-initialize.py
fi
if [ "$showrecorder" = "t" ]; then
python $AIRTIMEROOT/python_apps/show-recorder/install/recorder-initialize.py
fi
# Start monit if it is not running, or restart if it is.
# Need to ensure monit is running before Airtime daemons are run. This is
# so we can ensure they can register with monit to monitor them when they start.
@ -47,10 +52,15 @@ fi
sleep 1
set +e
if [ "$WEB_ONLY" -eq "0" ]; then
if [ "$mediamonitor" = "t" ]; then
monit monitor airtime-media-monitor
fi
if [ "$pypo" = "t" ]; then
monit monitor airtime-playout
monit monitor airtime-liquidsoap
monit monitor airtime-media-monitor
fi
if [ "$showrecorder" = "t" ]; then
monit monitor airtime-show-recorder
fi

View File

@ -11,23 +11,8 @@ require_once(dirname(__FILE__).'/AirtimeIni.php');
require_once(dirname(__FILE__).'/AirtimeInstall.php');
require_once(__DIR__.'/airtime-constants.php');
$opts = AirtimeInstall::getOpts();
if ($opts == NULL) {
exit(1);
}
$version = AirtimeInstall::GetVersionInstalled();
// A previous version exists - if so, upgrade.
/*
if (isset($version) && ($version != false) && ($version < AIRTIME_VERSION) && !isset($opts->r)) {
echo "Airtime version $version found.".PHP_EOL;
require_once("airtime-upgrade.php");
exit(0);
}
* */
// -------------------------------------------------------------------------
// The only way we get here is if we are doing a new install or a reinstall.
// -------------------------------------------------------------------------
@ -38,14 +23,14 @@ if(is_null($version)) {
}
$db_install = true;
if (is_null($opts->r) && isset($opts->n)) {
if (getenv("nodb")=="t") {
$db_install = false;
}
$overwrite = false;
if (isset($opts->o) || $newInstall == true) {
if (getenv("overwrite") == "t" || $newInstall == true) {
$overwrite = true;
} else if (!isset($opts->p) && !isset($opts->o) && isset($opts->r)) {
} else if (getenv("preserve") == "f" && getenv("overwrite") == "f" && getenv("reinstall") == "t") {
if (AirtimeIni::IniFilesExist()) {
$userAnswer = "x";
while (!in_array($userAnswer, array("o", "O", "p", "P", ""))) {
@ -80,7 +65,7 @@ if ($db_install) {
if($newInstall) {
//call external script. "y" argument means force creation of database tables.
passthru('php '.__DIR__.'/airtime-db-install.php y');
AirtimeInstall::DbConnect(true);
//AirtimeInstall::DbConnect(true);
} else {
require_once('airtime-db-install.php');
}

View File

@ -9,51 +9,32 @@
* choose -r to reinstall.
*
* Returns 0 if Airtime is not installed
* Returns 1 if a previous version of Airtime installed
* Returns 2 if the same version of Airtime is installed
* Returns 3 if a version of Airtime that we can't upgrade from is installed.
* Returns 4 if we need to print help message.
* Returns 5 if we need should only install apache files (web-only).
* Returns 1 if the same version of Airtime already installed
* Returns 2 if a previous version of Airtime is installed we can upgrade from
* Returns 3 if a version of Airtime is installed that we can't upgrade from.
*/
require_once(dirname(__FILE__).'/AirtimeInstall.php');
require_once(__DIR__.'/airtime-constants.php');
AirtimeInstall::ExitIfNotRoot();
$opts = AirtimeInstall::getOpts();
if (is_null($opts)) {
exit(0);
}
if (isset($opts->h)) {
AirtimeInstall::printUsage($opts);
exit(4);
}
//install media-monitor
if (isset($opts->w)){
exit(5);
}
$version = AirtimeInstall::GetVersionInstalled();
// The current version is already installed.
echo "* Checking for existing install of Airtime...".PHP_EOL;
if (isset($version) && ($version != false)){
if (($version == AIRTIME_VERSION) && !isset($opts->r)) {
echo "Airtime $version is already installed.".PHP_EOL;
AirtimeInstall::printUsage($opts);
exit(2);
} else if (strcmp($version, AIRTIME_VERSION) < 0){
echo " * Found previous version: $version".PHP_EOL;
exit(1);
if (isset($version)){
if ($version === false){
//version of Airtime older than 1.7.0 detected
exit(3);
} else {
if (($version == AIRTIME_VERSION)) {
//same version of Airtime is already installed
exit(1);
} else if (strcmp($version, AIRTIME_VERSION) < 0){
//previous version of Airtime is installed.
exit(2);
}
}
} else {
echo " * Not Found".PHP_EOL;
}
if($version === false){
echo "A version of Airtime older than 1.7.0 detected, please upgrade to 1.7.0 first.\n";
echo "You will then be able to upgrade to 1.9.0 using this installer.\n";
exit(3);
//no previous version of Airtime found
exit(0);
}

View File

@ -11,23 +11,6 @@ if os.geteuid() != 0:
print "Please run this as root."
sys.exit(1)
"""
def is_natty():
try:
f = open('/etc/lsb-release')
except IOError as e:
#File doesn't exist, so we're not even dealing with Ubuntu
return False
for line in f:
split = line.split("=")
split[0] = split[0].strip(" \r\n")
split[1] = split[1].strip(" \r\n")
if split[0] == "DISTRIB_CODENAME" and (split[1] == "natty" or split[1] == "oneiric"):
return True
return False
"""
"""
This function returns the codename of the host OS by querying lsb_release.
If lsb_release does not exist, or an exception occurs the codename returned