From f19f2153dc7f7acad8920257a6987ceadde29b65 Mon Sep 17 00:00:00 2001 From: martin Date: Fri, 20 May 2011 17:37:06 -0400 Subject: [PATCH] CC-2284: Create script that verifies all required processes are running. -check if icecast is running -added system symlink to run script -run airtime-check-system at end of install -display summary message with link to FAQ if failed --- install/airtime-install.php | 4 ++ install/include/AirtimeInstall.php | 5 ++ utils/airtime-check-system | 34 +++++++++++++ utils/airtime-check-system.php | 76 +++++++++++++++++++++++++++--- 4 files changed, 113 insertions(+), 6 deletions(-) create mode 100755 utils/airtime-check-system diff --git a/install/airtime-install.php b/install/airtime-install.php index e3614391f..677ed1192 100644 --- a/install/airtime-install.php +++ b/install/airtime-install.php @@ -129,5 +129,9 @@ system("python ".__DIR__."/../python_apps/show-recorder/install/recorder-install //echo PHP_EOL."*** Media Monitor Installation ***".PHP_EOL; //system("python ".__DIR__."/../python_apps/pytag-fs/install/media-monitor-install.py"); +echo PHP_EOL."*** Verifying Correct System Environment ***".PHP_EOL; +$command = "airtime-check-system"; +system($command); + echo "******************************* Install Complete *******************************".PHP_EOL; diff --git a/install/include/AirtimeInstall.php b/install/include/AirtimeInstall.php index 9b6f68bf9..b56eb7aab 100644 --- a/install/include/AirtimeInstall.php +++ b/install/include/AirtimeInstall.php @@ -302,6 +302,10 @@ class AirtimeInstall echo "* Installing airtime-update-db-settings".PHP_EOL; $dir = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-update-db-settings"; exec("ln -s $dir /usr/bin/airtime-update-db-settings"); + + echo "* Installing airtime-check-system".PHP_EOL; + $dir = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-check-system"; + exec("ln -s $dir /usr/bin/airtime-check-system"); } public static function RemoveSymlinks() @@ -309,6 +313,7 @@ class AirtimeInstall exec("rm -f /usr/bin/airtime-import"); exec("rm -f /usr/bin/airtime-clean-storage"); exec("rm -f /usr/bin/airtime-update-db-settings"); + exec("rm -f /usr/bin/airtime-check-system"); } public static function InstallPhpCode() diff --git a/utils/airtime-check-system b/utils/airtime-check-system new file mode 100755 index 000000000..45477df43 --- /dev/null +++ b/utils/airtime-check-system @@ -0,0 +1,34 @@ +#!/bin/bash +#------------------------------------------------------------------------------- +# Copyright (c) 2010 Sourcefabric O.P.S. +# +# This file is part of the Airtime project. +# http://airtime.sourcefabric.org/ +# +# Airtime is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# Airtime is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Airtime; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +#------------------------------------------------------------------------------- +#------------------------------------------------------------------------------- +# This script cleans audio files in Airtime. +# +# Absolute path to this script +SCRIPT=`readlink -f $0` +# Absolute path this script is in +SCRIPTPATH=`dirname $SCRIPT` + +invokePwd=$PWD +cd $SCRIPTPATH + +php -q airtime-check-system.php "$@" || exit 1 diff --git a/utils/airtime-check-system.php b/utils/airtime-check-system.php index 107822dbc..13caf808d 100644 --- a/utils/airtime-check-system.php +++ b/utils/airtime-check-system.php @@ -1,5 +1,11 @@ 0){ + $delimited = split("[ ]+", $output[0]); + $status = $delimited[1]; + } else { + self::$check_system_ok = false; + } + echo "ICECAST_PID=$status".PHP_EOL; + } public static function CheckConfigFilesExist(){ //echo PHP_EOL."Verifying Config Files in /etc/airtime".PHP_EOL; @@ -99,6 +151,7 @@ class AirtimeCheck{ $fullPath = "/etc/airtime/$cf"; if (!file_exists($fullPath)){ $allFound = AirtimeCheck::CHECK_FAILED; + self::$check_system_ok = false; } } @@ -138,11 +191,12 @@ class AirtimeCheck{ if ($dbconn === false){ $status = AirtimeCheck::CHECK_FAILED; + self::$check_system_ok = false; } else { $status = AirtimeCheck::CHECK_OK; } - echo "TEST_PGSQL_DATABASE=$status".PHP_EOL; + echo "PGSQL_DATABASE=$status".PHP_EOL; } public static function PythonLibrariesInstalled(){ @@ -153,6 +207,8 @@ class AirtimeCheck{ if (count($output[0]) > 0){ $key_value = split("==", $output[0]); $status = trim($key_value[1]); + } else { + self::$check_system_ok = false; } echo "PYTHON_KOMBU_VERSION=$status".PHP_EOL; @@ -165,6 +221,8 @@ class AirtimeCheck{ if (count($output[0]) > 0){ $key_value = split("==", $output[0]); $status = trim($key_value[1]); + } else { + self::$check_system_ok = false; } echo "PYTHON_POSTER_VERSION=$status".PHP_EOL; @@ -210,9 +268,10 @@ class AirtimeCheck{ $airtimeIni["rabbitmq"]["password"]); } catch (Exception $e){ $status = AirtimeCheck::CHECK_FAILED; + self::$check_system_ok = false; } - echo "TEST_RABBITMQ_SERVER=$status".PHP_EOL; + echo "RABBITMQ_SERVER=$status".PHP_EOL; } public static function GetAirtimeServerVersion($pypoCfg){ @@ -249,6 +308,7 @@ class AirtimeCheck{ foreach ($fileNames as $fn){ if (!file_exists($fn)){ $status = AirtimeCheck::CHECK_FAILED; + self::$check_system_ok = false; } } @@ -298,6 +358,9 @@ class AirtimeCheck{ // error handler function function myErrorHandler($errno, $errstr, $errfile, $errline) { + return true; + + /* if ($errno == E_WARNING){ if (strpos($errstr, "401") !== false){ echo "\t\tServer is running but could not find Airtime".PHP_EOL; @@ -308,6 +371,7 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) } } - /* Don't execute PHP internal error handler */ + //Don't execute PHP internal error handler return true; + */ }