diff --git a/install_full/ubuntu/airtime-full-install b/install_full/ubuntu/airtime-full-install index dfdb40b51..e063cdd63 100755 --- a/install_full/ubuntu/airtime-full-install +++ b/install_full/ubuntu/airtime-full-install @@ -39,7 +39,7 @@ php-pear php5-gd postgresql odbc-postgresql python2.6 libsoundtouch-ocaml \ libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \ libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \ php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \ -libvorbis-ocaml libpulse0 vorbis-tools lsb-release php-db +libpulse0 vorbis-tools lsb-release php-db #install packages with --force-yes option (this is useful in the case #of Debian, where these packages are unauthorized) diff --git a/install_full/ubuntu/airtime-full-install-nginx b/install_full/ubuntu/airtime-full-install-nginx index f5ab2d9fc..d05e5e978 100755 --- a/install_full/ubuntu/airtime-full-install-nginx +++ b/install_full/ubuntu/airtime-full-install-nginx @@ -42,7 +42,7 @@ php-pear php5-gd postgresql odbc-postgresql python2.6 libsoundtouch-ocaml \ libtaglib-ocaml libao-ocaml libmad-ocaml ecasound \ libesd0 libportaudio2 libsamplerate0 rabbitmq-server patch \ php5-curl mpg123 monit python-virtualenv multitail libcamomile-ocaml-data \ -libvorbis-ocaml libpulse0 vorbis-tools lsb-release php-db +libpulse0 vorbis-tools lsb-release php-db #install packages with --force-yes option (this is useful in the case #of Debian, where these packages are unauthorized) diff --git a/utils/airtime-check-system-old.php b/utils/airtime-check-system-old.php deleted file mode 100644 index 1b1449e6e..000000000 --- a/utils/airtime-check-system-old.php +++ /dev/null @@ -1,495 +0,0 @@ - 0){ - $delimited = preg_split("/[\s]+/", $output[0]); - $status = $delimited[1]; - } else { - self::$check_system_ok = false; - } - - //output_status("ICECAST_PROCESS_ID", $status); - return array(array("ICECAST_PROCESS_ID", $status)); - } - - public static function GetCpuInfo() - { - $command = "cat /proc/cpuinfo |grep -m 1 'model name' "; - exec($command, $output, $result); - - $choppedStr = explode(":", $output[0]); - $status = trim($choppedStr[1]); - //output_status("CPU", $status); - return array(array("CPU", $status)); - } - - public static function GetRamInfo() - { - $command = "cat /proc/meminfo |grep 'MemTotal' "; - exec($command, $output, $result); - $choppedStr = explode(":", $output[0]); - $status = trim($choppedStr[1]); - //output_status("Total RAM", $status); - return array(array("Total RAM", $status)); - - $output = null; - $command = "cat /proc/meminfo |grep 'MemFree' "; - exec($command, $output, $result); - $choppedStr = explode(":", $output[0]); - $status = trim($choppedStr[1]); - //output_status("Free RAM", $status); - return array(array("Free RAM", $status)); - } - - public static function CheckConfigFilesExist() - { - //echo PHP_EOL."Verifying Config Files in /etc/airtime".PHP_EOL; - $confFiles = array("airtime.conf", - "liquidsoap.cfg", - "pypo.cfg", - "media-monitor.cfg", - "recorder.cfg"); - - $allFound = AirtimeCheck::CHECK_OK; - - foreach ($confFiles as $cf){ - $fullPath = "/etc/airtime/$cf"; - if (!file_exists($fullPath)){ - $allFound = AirtimeCheck::CHECK_FAILED; - self::$check_system_ok = false; - break; - } - } - - //output_status("AIRTIME_CONFIG_FILES", $allFound); - return array(array("AIRTIME_CONFIG_FILES", $allFound)); - - } - - public static function GetAirtimeConf() - { - $ini = parse_ini_file("/etc/airtime/airtime.conf", true); - - if ($ini === false){ - echo "Error reading /etc/airtime/airtime.conf.".PHP_EOL; - exit; - } - - return $ini; - } - - public static function GetApiClientCfg() - { - $ini = parse_ini_file("/etc/airtime/api_client.cfg", false); - - if ($ini === false){ - echo "Error reading /etc/airtime/api_client.cfg.".PHP_EOL; - exit; - } - - return $ini; - } - - public static function CheckDbConnection($airtimeIni) - { - $host = $airtimeIni["database"]["host"]; - $dbname = $airtimeIni["database"]["dbname"]; - $dbuser = $airtimeIni["database"]["dbuser"]; - $dbpass = $airtimeIni["database"]["dbpass"]; - - $dbconn = pg_connect("host=$host port=5432 dbname=$dbname user=$dbuser password=$dbpass"); - - if ($dbconn === false){ - $status = AirtimeCheck::CHECK_FAILED; - self::$check_system_ok = false; - } else { - $status = AirtimeCheck::CHECK_OK; - } - - //output_status("POSTGRESQL_DATABASE", $status); - return array(array("POSTGRESQL_DATABASE", $status)); - } - - private static function isMinVersionSatisfied($minVersion, $version){ - $minVersionArr = explode(".", $minVersion); - $versionArr = explode(".", $version); - - if (count($minVersionArr) != count($versionArr)){ - return false; - } - - //when comparing 1.20 and 1.19, first compare "1" and "1" - //and then the "20" to the "19" - for ($i=0, $n = count($minVersionArr); $i<$n; $i++){ - if ($minVersionArr[$i] < $versionArr[$i]){ - return true; - } else if ($minVersionArr[$i] > $versionArr[$i]){ - return false; - } - //else continue if equal - } - - return true; - } - - private static function CheckPythonLibrary($lib, $minVersion){ - $command = "/usr/lib/airtime/airtime_virtualenv/bin/pip freeze | grep $lib"; - exec($command, $output, $result); - - $status = AirtimeCheck::CHECK_FAILED; - if (count($output[0]) > 0){ - $key_value = explode("==", $output[0]); - $version = trim($key_value[1]); - if (self::isMinVersionSatisfied($minVersion, $version)){ - $status = $version; - } else { - output_msg("Minimum require version for \"$lib\" is $minVersion. Your version: $version"); - self::$check_system_ok = false; - } - } else { - self::$check_system_ok = false; - } - - return $status; - } - - public static function PythonLibrariesInstalled() - { - - //output_status("PYTHON_KOMBU_VERSION", self::CheckPythonLibrary("kombu", self::KOMBU_MIN_VERSION)); - //output_status("PYTHON_POSTER_VERSION", self::CheckPythonLibrary("poster", self::POSTER_MIN_VERSION)); - //output_status("PYTHON_MUTAGEN_VERSION", self::CheckPythonLibrary("mutagen", self::MUTAGEN_MIN_VERSION)); - //output_status("PYTHON_PYINOTIFY_VERSION", self::CheckPythonLibrary("pyinotify", self::PYINOTIFY_MIN_VERSION)); - $statuses[] = array("PYTHON_KOMBU_VERSION", self::CheckPythonLibrary("kombu", self::KOMBU_MIN_VERSION)); - $statuses[] = array("PYTHON_POSTER_VERSION", self::CheckPythonLibrary("poster", self::POSTER_MIN_VERSION)); - $statuses[] = array("PYTHON_MUTAGEN_VERSION", self::CheckPythonLibrary("mutagen", self::MUTAGEN_MIN_VERSION)); - $statuses[] = array("PYTHON_PYINOTIFY_VERSION", self::CheckPythonLibrary("pyinotify", self::PYINOTIFY_MIN_VERSION)); - - return $statuses; - } - - public static function CheckDbTables() - { - - } - - /* The function tests for whether the rabbitmq-server package is - * installed. RabbitMQ could be installed manually via tarball - * and this function will fail to detect it! Unfortunately there - * seems to be no other way to check RabbitMQ version. Will update - * this function if I find a more universal solution. */ - /* - public static function CheckRabbitMqVersion(){ - echo PHP_EOL."Checking RabbitMQ Version".PHP_EOL; - - $command = "dpkg -l | grep rabbitmq-server"; - exec($command, $output, $result); - - if (count($output) > 0){ - //version string always starts at character 45. Lets find - //the end of this version string by looking for the first space. - $start = 45; - $end = strpos($output[0], " ", $start); - - $version = substr($output[0], $start, $end-$start); - - echo "\t$version ... [OK]".PHP_EOL; - } else { - echo "\trabbitmq-server package not found. [Failed!]".PHP_EOL; - } - } - * */ - - public static function CheckRabbitMqConnection($airtimeIni) - { - try { - $status = AirtimeCheck::CHECK_OK; - $conn = new AMQPConnection($airtimeIni["rabbitmq"]["host"], - $airtimeIni["rabbitmq"]["port"], - $airtimeIni["rabbitmq"]["user"], - $airtimeIni["rabbitmq"]["password"]); - } catch (Exception $e){ - $status = AirtimeCheck::CHECK_FAILED; - self::$check_system_ok = false; - } - - //output_status("RABBITMQ_SERVER", $status); - return array(array("RABBITMQ_SERVER", $status)); - } - - public static function GetAirtimeServerVersion($apiClientCfg) - { - $baseUrl = $apiClientCfg["base_url"]; - $basePort = $apiClientCfg["base_port"]; - $apiKey = "%%api_key%%"; - - $url = "http://$baseUrl:$basePort/api/version/api_key/$apiKey"; - //output_status("AIRTIME_VERSION_URL", $url); - $statuses[] = array("AIRTIME_VERSION_URL", $url); - - $apiKey = $apiClientCfg["api_key"]; - $url = "http://$baseUrl:$basePort/api/version/api_key/$apiKey"; - - $rh = fopen($url, "r"); - - $version = "Could not contact server"; - if ($rh !== false) { - //output_status("APACHE_CONFIGURED", "YES"); - $statuses[] = array("APACHE_CONFIGURED", "YES"); - while (($buffer = fgets($rh)) !== false) { - $json = json_decode(trim($buffer), true); - if (!is_null($json)){ - $version = $json["version"]; - } - } - } else { - //output_status("APACHE_CONFIGURED", "NO"); - $statuses[] = array("APACHE_CONFIGURED", "NO"); - } - //output_status("AIRTIME_VERSION", $version); - $statuses[] = array("AIRTIME_VERSION", $version); - return $statuses; - } - - public static function CheckApacheVHostFiles(){ - $fileNames = array("/etc/apache2/sites-available/airtime", - "/etc/apache2/sites-enabled/airtime"); - - $status = AirtimeCheck::CHECK_OK; - - foreach ($fileNames as $fn){ - if (!file_exists($fn)){ - $status = AirtimeCheck::CHECK_FAILED; - self::$check_system_ok = false; - } - } - - //Since apache2 loads config files in alphabetical order - //from the sites-enabled directory, we need to check if - //airtime is lexically the first file in this directory. - //get sorted array of files - $arr = scandir("/etc/apache2/sites-enabled"); - - /* - foreach ($arr as $a){ - if ($a == "." || $a == ".."){ - continue; - } - if ($a == "airtime"){ - break; - } else { - echo "\t\t*Warning, the file \"$a\" is lexically ahead of the file \"airtime\" in".PHP_EOL; - echo"\t\t /etc/apache2/sites-enabled and preventing airtime from being loaded".PHP_EOL; - } - } - */ - } - - public static function CheckOsTypeVersion(){ - - if (file_exists("/etc/lsb-release")){ - //lsb-release existing implies a Ubuntu installation. - - $ini = parse_ini_file("/etc/lsb-release", false); - $os_string = $ini["DISTRIB_DESCRIPTION"]; - } else if (file_exists("/etc/debian_version")) { - //if lsb-release does not exist, lets check if we are - //running on Debian. Look for file /etc/debian_version - $handler = fopen("/etc/debian_version", "r"); - $os_string = trim(fgets($handler)); - - } else { - $os_string = "Unknown"; - } - - // Figure out if 32 or 64 bit - $command = "file -b /sbin/init"; - exec($command, $output, $result); - $splitStr = explode(",", $output[0]); - $os_string .= $splitStr[1]; - - //output_status("OS", $os_string); - return array(array("OS", $os_string)); - } - - public static function CheckFreeDiskSpace(){ - exec("df -h", $output); - $split_rows = array(); - foreach ($output as $row){ - $split_rows[] = preg_split("/[\s]+/", $row); - } - return $split_rows; - } -} - - -// error handler function -function myErrorHandler($errno, $errstr, $errfile, $errline) -{ - //Don't execute PHP internal error handler - return true; -} diff --git a/utils/airtime-check-system.php b/utils/airtime-check-system.php index 1428d8776..ae1b11641 100644 --- a/utils/airtime-check-system.php +++ b/utils/airtime-check-system.php @@ -12,9 +12,11 @@ if (substr($sapi_type, 0, 3) == 'cli') { $airtimeIni = AirtimeCheck::GetAirtimeConf(); $apiKey = $airtimeIni['general']['api_key']; + $baseUrl = $airtimeIni['general']['base_url']; - $status = AirtimeCheck::GetStatus($apiKey); - AirtimeCheck::PrintStatus($status); + + $status = AirtimeCheck::GetStatus($baseUrl, $apiKey); + AirtimeCheck::PrintStatus($baseUrl, $status); } class AirtimeCheck { @@ -88,8 +90,8 @@ class AirtimeCheck { return $os_string." ".$machine; } - public static function GetServerType(){ - $headerInfo = get_headers("http://localhost",1); + public static function GetServerType($p_baseUrl){ + $headerInfo = get_headers("http://$p_baseUrl",1); if (!isset($headerInfo['Server'][0])) return self::UNKNOWN; @@ -97,9 +99,9 @@ class AirtimeCheck { return $headerInfo['Server'][0]; } - public static function GetStatus($p_apiKey){ + public static function GetStatus($p_baseUrl, $p_apiKey){ - $url = "http://localhost/api/status/format/json/api_key/%%api_key%%"; + $url = "http://$p_baseUrl/api/status/format/json/api_key/%%api_key%%"; self::output_status("AIRTIME_STATUS_URL", $url); $url = str_replace("%%api_key%%", $p_apiKey, $url); @@ -116,7 +118,7 @@ class AirtimeCheck { return $data; } - public static function PrintStatus($p_status){ + public static function PrintStatus($p_baseUrl, $p_status){ if ($p_status === false){ self::output_status("AIRTIME_SERVER_RESPONDING", "FAILED"); @@ -146,7 +148,7 @@ class AirtimeCheck { } self::output_status("OS", self::CheckOsTypeVersion()); self::output_status("CPU", self::GetCpuInfo()); - self::output_status("WEB_SERVER", self::GetServerType()); + self::output_status("WEB_SERVER", self::GetServerType($p_baseUrl)); if (isset($data->services)) { $services = $data->services;