CC-2518: Auto install script for manual install
- install dir is renamed to install_minimal - virtualenv command is moved to install script. - need more work on install_full part
This commit is contained in:
parent
65ea711792
commit
931fb4db62
31 changed files with 723 additions and 5 deletions
260
install_minimal/include/AirtimeIni.php
Normal file
260
install_minimal/include/AirtimeIni.php
Normal file
|
@ -0,0 +1,260 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Airtime
|
||||
* @copyright 2011 Sourcefabric o.p.s.
|
||||
* @license http://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
|
||||
// Do not allow remote execution
|
||||
$arr = array_diff_assoc($_SERVER, $_ENV);
|
||||
if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
|
||||
header("HTTP/1.1 400");
|
||||
header("Content-type: text/plain; charset=UTF-8");
|
||||
echo "400 Not executable\r\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
//make sure user has Postgresql PHP extension installed.
|
||||
if (!function_exists('pg_connect')) {
|
||||
trigger_error("PostgreSQL PHP extension required and not found.", E_USER_ERROR);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
|
||||
/* This class deals with the config files stored in /etc/airtime */
|
||||
class AirtimeIni
|
||||
{
|
||||
const CONF_FILE_AIRTIME = "/etc/airtime/airtime.conf";
|
||||
const CONF_FILE_PYPO = "/etc/airtime/pypo.cfg";
|
||||
const CONF_FILE_RECORDER = "/etc/airtime/recorder.cfg";
|
||||
const CONF_FILE_API_CLIENT = "/etc/airtime/api_client.cfg";
|
||||
const CONF_FILE_LIQUIDSOAP = "/etc/airtime/liquidsoap.cfg";
|
||||
const CONF_FILE_MEDIAMONITOR = "/etc/airtime/media-monitor.cfg";
|
||||
const CONF_FILE_MONIT = "/etc/monit/conf.d/airtime-monit.cfg";
|
||||
|
||||
public static function IniFilesExist()
|
||||
{
|
||||
$configFiles = array(AirtimeIni::CONF_FILE_AIRTIME,
|
||||
AirtimeIni::CONF_FILE_PYPO,
|
||||
AirtimeIni::CONF_FILE_RECORDER,
|
||||
AirtimeIni::CONF_FILE_LIQUIDSOAP,
|
||||
AirtimeIni::CONF_FILE_MEDIAMONITOR);
|
||||
$exist = false;
|
||||
foreach ($configFiles as $conf) {
|
||||
if (file_exists($conf)) {
|
||||
echo "Existing config file detected at $conf".PHP_EOL;
|
||||
$exist = true;
|
||||
}
|
||||
}
|
||||
return $exist;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function creates the /etc/airtime configuration folder
|
||||
* and copies the default config files to it.
|
||||
*/
|
||||
public static function CreateIniFiles()
|
||||
{
|
||||
if (!file_exists("/etc/airtime/")){
|
||||
if (!mkdir("/etc/airtime/", 0755, true)){
|
||||
echo "Could not create /etc/airtime/ directory. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!copy(AirtimeInstall::GetAirtimeSrcDir()."/build/airtime.conf", AirtimeIni::CONF_FILE_AIRTIME)){
|
||||
echo "Could not copy airtime.conf to /etc/airtime/. Exiting.";
|
||||
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);
|
||||
}
|
||||
if (!copy(__DIR__."/../../python_apps/pypo/pypo.cfg", AirtimeIni::CONF_FILE_PYPO)){
|
||||
echo "Could not copy pypo.cfg to /etc/airtime/. 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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public static function CreateMonitFile(){
|
||||
if (!copy(__DIR__."/../../python_apps/monit/airtime-monit.cfg", AirtimeIni::CONF_FILE_MONIT)){
|
||||
echo "Could not copy airtime-monit.cfg to /etc/monit/conf.d/. Exiting.";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function RemoveMonitFile(){
|
||||
@unlink("/etc/monit/conf.d/airtime-monit.cfg");
|
||||
}
|
||||
|
||||
/**
|
||||
* This function removes /etc/airtime and the configuration
|
||||
* files present within it.
|
||||
*/
|
||||
public static function RemoveIniFiles()
|
||||
{
|
||||
if (file_exists(AirtimeIni::CONF_FILE_AIRTIME)){
|
||||
unlink(AirtimeIni::CONF_FILE_AIRTIME);
|
||||
}
|
||||
|
||||
if (file_exists(AirtimeIni::CONF_FILE_PYPO)){
|
||||
unlink(AirtimeIni::CONF_FILE_PYPO);
|
||||
}
|
||||
|
||||
if (file_exists(AirtimeIni::CONF_FILE_RECORDER)){
|
||||
unlink(AirtimeIni::CONF_FILE_RECORDER);
|
||||
}
|
||||
|
||||
if (file_exists(AirtimeIni::CONF_FILE_LIQUIDSOAP)){
|
||||
unlink(AirtimeIni::CONF_FILE_LIQUIDSOAP);
|
||||
}
|
||||
|
||||
//wait until Airtime 1.9.0
|
||||
if (file_exists(AirtimeIni::CONF_FILE_MEDIAMONITOR)){
|
||||
unlink(AirtimeIni::CONF_FILE_MEDIAMONITOR);
|
||||
}
|
||||
|
||||
if (file_exists("etc/airtime")){
|
||||
rmdir("/etc/airtime/");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function generates a random string.
|
||||
*
|
||||
* The random string uses two parameters: $p_len and $p_chars. These
|
||||
* parameters do not need to be provided, in which case defaults are
|
||||
* used.
|
||||
*
|
||||
* @param string $p_len
|
||||
* How long should the generated string be.
|
||||
* @param string $p_chars
|
||||
* String containing chars that should be used for generating.
|
||||
* @return string
|
||||
* The generated random string.
|
||||
*/
|
||||
public static function GenerateRandomString($p_len=20, $p_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
|
||||
{
|
||||
$string = '';
|
||||
for ($i = 0; $i < $p_len; $i++)
|
||||
{
|
||||
$pos = mt_rand(0, strlen($p_chars)-1);
|
||||
$string .= $p_chars{$pos};
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function updates an INI style config file.
|
||||
*
|
||||
* A property and the value the property should be changed to are
|
||||
* supplied. If the property is not found, then no changes are made.
|
||||
*
|
||||
* @param string $p_filename
|
||||
* The path the to the file.
|
||||
* @param string $p_property
|
||||
* The property to look for in order to change its value.
|
||||
* @param string $p_value
|
||||
* The value the property should be changed to.
|
||||
*
|
||||
*/
|
||||
public static function UpdateIniValue($p_filename, $p_property, $p_value)
|
||||
{
|
||||
$lines = file($p_filename);
|
||||
$n=count($lines);
|
||||
foreach ($lines as &$line) {
|
||||
if ($line[0] != "#"){
|
||||
$key_value = explode("=", $line);
|
||||
$key = trim($key_value[0]);
|
||||
|
||||
if ($key == $p_property){
|
||||
$line = "$p_property = $p_value".PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fp=fopen($p_filename, 'w');
|
||||
for($i=0; $i<$n; $i++){
|
||||
fwrite($fp, $lines[$i]);
|
||||
}
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
/**
|
||||
* After the configuration files have been copied to /etc/airtime,
|
||||
* this function will update them to values unique to this
|
||||
* particular installation.
|
||||
*/
|
||||
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);
|
||||
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_PYPO, 'api_key', "'$api_key'");
|
||||
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_RECORDER, 'api_key', "'$api_key'");
|
||||
AirtimeIni::UpdateIniValue(AirtimeIni::CONF_FILE_MEDIAMONITOR, 'api_key', "'$api_key'");
|
||||
}
|
||||
|
||||
public static function ReadPythonConfig($p_filename)
|
||||
{
|
||||
$values = array();
|
||||
|
||||
$lines = file($p_filename);
|
||||
$n=count($lines);
|
||||
for ($i=0; $i<$n; $i++) {
|
||||
if (strlen($lines[$i]) && !in_array(substr($lines[$i], 0, 1), array('#', PHP_EOL))){
|
||||
$info = explode("=", $lines[$i]);
|
||||
$values[trim($info[0])] = trim($info[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
public static function MergeConfigFiles($configFiles, $suffix) {
|
||||
foreach ($configFiles as $conf) {
|
||||
if (file_exists("$conf$suffix.bak")) {
|
||||
|
||||
if($conf === CONF_FILE_AIRTIME) {
|
||||
// Parse with sections
|
||||
$newSettings = parse_ini_file($conf, true);
|
||||
$oldSettings = parse_ini_file("$conf$suffix.bak", true);
|
||||
}
|
||||
else {
|
||||
$newSettings = AirtimeIni::ReadPythonConfig($conf);
|
||||
$oldSettings = AirtimeIni::ReadPythonConfig("$conf$suffix.bak");
|
||||
}
|
||||
|
||||
$settings = array_keys($newSettings);
|
||||
|
||||
foreach($settings as $section) {
|
||||
if(isset($oldSettings[$section])) {
|
||||
if(is_array($oldSettings[$section])) {
|
||||
$sectionKeys = array_keys($newSettings[$section]);
|
||||
foreach($sectionKeys as $sectionKey) {
|
||||
if(isset($oldSettings[$section][$sectionKey])) {
|
||||
AirtimeIni::UpdateIniValue($conf, $sectionKey, $oldSettings[$section][$sectionKey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
AirtimeIni::UpdateIniValue($conf, $section, $oldSettings[$section]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
417
install_minimal/include/AirtimeInstall.php
Normal file
417
install_minimal/include/AirtimeInstall.php
Normal file
|
@ -0,0 +1,417 @@
|
|||
<?php
|
||||
//Pear classes.
|
||||
set_include_path(__DIR__.'/../../airtime_mvc/library/pear' . PATH_SEPARATOR . get_include_path());
|
||||
require_once('DB.php');
|
||||
|
||||
class AirtimeInstall
|
||||
{
|
||||
const CONF_DIR_BINARIES = "/usr/lib/airtime";
|
||||
const CONF_DIR_WWW = "/var/www/airtime";
|
||||
const CONF_DIR_LOG = "/var/log/airtime";
|
||||
|
||||
public static $databaseTablesCreated = false;
|
||||
|
||||
public static function GetAirtimeSrcDir()
|
||||
{
|
||||
return __DIR__."/../../airtime_mvc";
|
||||
}
|
||||
|
||||
public static function GetUtilsSrcDir()
|
||||
{
|
||||
return __DIR__."/../../utils";
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the user is running this PHP script with root
|
||||
* permissions. If not running with root permissions, causes the
|
||||
* script to exit.
|
||||
*/
|
||||
public static function ExitIfNotRoot()
|
||||
{
|
||||
// Need to check that we are superuser before running this.
|
||||
if(exec("whoami") != "root"){
|
||||
echo "Must be root user.\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public static function GetVersionInstalled()
|
||||
{
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
|
||||
if(file_exists('/etc/airtime/airtime.conf')) {
|
||||
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
|
||||
}
|
||||
else {
|
||||
echo "New Airtime Install.".PHP_EOL;
|
||||
return null;
|
||||
}
|
||||
|
||||
// Database config
|
||||
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
|
||||
$CC_CONFIG['dsn']['password'] = $values['database']['dbpass'];
|
||||
$CC_CONFIG['dsn']['hostspec'] = $values['database']['host'];
|
||||
$CC_CONFIG['dsn']['phptype'] = 'pgsql';
|
||||
$CC_CONFIG['dsn']['database'] = $values['database']['dbname'];
|
||||
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo "New Airtime Install.".PHP_EOL;
|
||||
return null;
|
||||
}
|
||||
else {
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version'";
|
||||
$version = $CC_DBC->GetOne($sql);
|
||||
|
||||
if (PEAR::isError($version)) {
|
||||
return null;
|
||||
}
|
||||
return $version;
|
||||
}
|
||||
}
|
||||
|
||||
public static function DbTableExists($p_name)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function InstallQuery($sql, $verbose = true)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
echo "Error! ".$result->getMessage()."\n";
|
||||
echo " SQL statement was:\n";
|
||||
echo " ".$sql."\n\n";
|
||||
} else {
|
||||
if ($verbose) {
|
||||
echo "done.\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function DbConnect($p_exitOnError = true)
|
||||
{
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo $CC_DBC->getMessage().PHP_EOL;
|
||||
echo $CC_DBC->getUserInfo().PHP_EOL;
|
||||
echo "Database connection problem.".PHP_EOL;
|
||||
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
|
||||
" with corresponding permissions.".PHP_EOL;
|
||||
if ($p_exitOnError) {
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* TODO: This function should be moved to the media-monitor
|
||||
* install script. */
|
||||
public static function InstallStorageDirectory()
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
echo "* Storage directory setup".PHP_EOL;
|
||||
|
||||
$ini = parse_ini_file(__DIR__."/airtime-install.ini");
|
||||
$stor_dir = $ini["storage_dir"];
|
||||
|
||||
$dirs = array($stor_dir, $stor_dir."/organize");
|
||||
|
||||
foreach ($dirs as $dir){
|
||||
if (!file_exists($dir)) {
|
||||
@mkdir($dir, 02777, true);
|
||||
if (file_exists($dir)) {
|
||||
$rp = realpath($dir);
|
||||
echo "* Directory $rp created".PHP_EOL;
|
||||
} else {
|
||||
echo "* Failed creating {$dir}".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
else if (is_writable($dir)) {
|
||||
$rp = realpath($dir);
|
||||
echo "* Skipping directory already exists: $rp".PHP_EOL;
|
||||
}
|
||||
else {
|
||||
$rp = realpath($dir);
|
||||
echo "* Error: Directory already exists, but is not writable: $rp".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo "* Giving Apache permission to access $rp".PHP_EOL;
|
||||
$success = chgrp($rp, $CC_CONFIG["webServerUser"]);
|
||||
$success = chown($rp, "pypo");
|
||||
$success = chmod($rp, 02777);
|
||||
}
|
||||
}
|
||||
|
||||
public static function CreateDatabaseUser()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
echo "* Creating Airtime database user".PHP_EOL;
|
||||
|
||||
$username = $CC_CONFIG['dsn']['username'];
|
||||
$password = $CC_CONFIG['dsn']['password'];
|
||||
$command = "echo \"CREATE USER $username ENCRYPTED PASSWORD '$password' LOGIN CREATEDB NOCREATEUSER;\" | su postgres -c psql 2>/dev/null";
|
||||
|
||||
@exec($command, $output, $results);
|
||||
if ($results == 0) {
|
||||
echo "* Database user '{$CC_CONFIG['dsn']['username']}' created.".PHP_EOL;
|
||||
} else {
|
||||
if (count($output) > 0) {
|
||||
echo "* Could not create user '{$CC_CONFIG['dsn']['username']}': ".PHP_EOL;
|
||||
echo implode(PHP_EOL, $output);
|
||||
}
|
||||
else {
|
||||
echo "* Database user '{$CC_CONFIG['dsn']['username']}' already exists.".PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function CreateDatabase()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
|
||||
echo "* Creating Airtime database".PHP_EOL;
|
||||
|
||||
$database = $CC_CONFIG['dsn']['database'];
|
||||
$username = $CC_CONFIG['dsn']['username'];
|
||||
#$command = "echo \"CREATE DATABASE $database OWNER $username\" | su postgres -c psql 2>/dev/null";
|
||||
$command = "su postgres -c \"createdb $database --owner $username\"";
|
||||
|
||||
@exec($command, $output, $results);
|
||||
if ($results == 0) {
|
||||
echo "* Database '{$CC_CONFIG['dsn']['database']}' created.".PHP_EOL;
|
||||
} else {
|
||||
if (count($output) > 0) {
|
||||
echo "* Could not create database '{$CC_CONFIG['dsn']['database']}': ".PHP_EOL;
|
||||
echo implode(PHP_EOL, $output);
|
||||
}
|
||||
else {
|
||||
echo "* Database '{$CC_CONFIG['dsn']['database']}' already exists.".PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
$databaseExisted = ($results != 0);
|
||||
|
||||
return $databaseExisted;
|
||||
}
|
||||
|
||||
public static function InstallPostgresScriptingLanguage()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
// Install postgres scripting language
|
||||
$langIsInstalled = $CC_DBC->GetOne('SELECT COUNT(*) FROM pg_language WHERE lanname = \'plpgsql\'');
|
||||
if ($langIsInstalled == '0') {
|
||||
echo "* Installing Postgres scripting language".PHP_EOL;
|
||||
$sql = "CREATE LANGUAGE 'plpgsql'";
|
||||
AirtimeInstall::InstallQuery($sql, false);
|
||||
} else {
|
||||
echo "* Postgres scripting language already installed".PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
public static function CreateDatabaseTables()
|
||||
{
|
||||
echo "* Creating database tables".PHP_EOL;
|
||||
|
||||
// Put Propel sql files in Database
|
||||
//$command = AirtimeInstall::CONF_DIR_WWW."/library/propel/generator/bin/propel-gen ".AirtimeInstall::CONF_DIR_WWW."/build/ insert-sql";
|
||||
$command = AirtimeInstall::CONF_DIR_WWW."/library/propel/generator/bin/propel-gen ".AirtimeInstall::CONF_DIR_WWW."/build/ insert-sql 2>/dev/null";
|
||||
@exec($command, $output, $results);
|
||||
AirtimeInstall::$databaseTablesCreated = true;
|
||||
}
|
||||
|
||||
public static function BypassMigrations($dir, $version)
|
||||
{
|
||||
$appDir = AirtimeInstall::GetAirtimeSrcDir();
|
||||
$command = "php $appDir/library/doctrine/migrations/doctrine-migrations.phar ".
|
||||
"--configuration=$dir/../../DoctrineMigrations/migrations.xml ".
|
||||
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
|
||||
"--no-interaction --add migrations:version $version";
|
||||
system($command);
|
||||
}
|
||||
|
||||
public static function MigrateTablesToVersion($dir, $version)
|
||||
{
|
||||
$appDir = AirtimeInstall::GetAirtimeSrcDir();
|
||||
$command = "php $appDir/library/doctrine/migrations/doctrine-migrations.phar ".
|
||||
"--configuration=$dir/../../DoctrineMigrations/migrations.xml ".
|
||||
"--db-configuration=$appDir/library/doctrine/migrations/migrations-db.php ".
|
||||
"--no-interaction migrations:migrate $version";
|
||||
system($command);
|
||||
}
|
||||
|
||||
public static function SetAirtimeVersion($p_version)
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "DELETE FROM cc_pref WHERE keystr = 'system_version'";
|
||||
$CC_DBC->query($sql);
|
||||
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '$p_version')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function SetUniqueId()
|
||||
{
|
||||
global $CC_DBC;
|
||||
|
||||
$uniqueId = md5(uniqid("", true));
|
||||
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('uniqueId', '$uniqueId')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function GetAirtimeVersion()
|
||||
{
|
||||
global $CC_DBC;
|
||||
$sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version'";
|
||||
$version = $CC_DBC->GetOne($sql);
|
||||
|
||||
if (PEAR::isError($version)) {
|
||||
return false;
|
||||
}
|
||||
return $version;
|
||||
}
|
||||
|
||||
public static function DeleteFilesRecursive($p_path)
|
||||
{
|
||||
$command = "rm -rf \"$p_path\"";
|
||||
exec($command);
|
||||
}
|
||||
|
||||
public static function CreateSymlinksToUtils()
|
||||
{
|
||||
echo "* Creating /usr/bin symlinks".PHP_EOL;
|
||||
AirtimeInstall::RemoveSymlinks();
|
||||
|
||||
echo "* Installing airtime-import".PHP_EOL;
|
||||
$dir = AirtimeInstall::CONF_DIR_BINARIES."/utils/airtime-import/airtime-import";
|
||||
exec("ln -s $dir /usr/bin/airtime-import");
|
||||
|
||||
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()
|
||||
{
|
||||
exec("rm -f /usr/bin/airtime-import");
|
||||
exec("rm -f /usr/bin/airtime-update-db-settings");
|
||||
exec("rm -f /usr/bin/airtime-check-system");
|
||||
}
|
||||
|
||||
public static function InstallPhpCode()
|
||||
{
|
||||
global $CC_CONFIG;
|
||||
echo "* Installing PHP code to ".AirtimeInstall::CONF_DIR_WWW.PHP_EOL;
|
||||
exec("mkdir -p ".AirtimeInstall::CONF_DIR_WWW);
|
||||
exec("cp -R ".AirtimeInstall::GetAirtimeSrcDir()."/* ".AirtimeInstall::CONF_DIR_WWW);
|
||||
|
||||
}
|
||||
|
||||
public static function UninstallPhpCode()
|
||||
{
|
||||
echo "* Removing PHP code from ".AirtimeInstall::CONF_DIR_WWW.PHP_EOL;
|
||||
exec('rm -rf "'.AirtimeInstall::CONF_DIR_WWW.'"');
|
||||
}
|
||||
|
||||
public static function InstallBinaries()
|
||||
{
|
||||
echo "* Installing binaries to ".AirtimeInstall::CONF_DIR_BINARIES.PHP_EOL;
|
||||
exec("mkdir -p ".AirtimeInstall::CONF_DIR_BINARIES);
|
||||
exec("cp -R ".AirtimeInstall::GetUtilsSrcDir()." ".AirtimeInstall::CONF_DIR_BINARIES);
|
||||
}
|
||||
|
||||
public static function UninstallBinaries()
|
||||
{
|
||||
echo "* Removing Airtime binaries from ".AirtimeInstall::CONF_DIR_BINARIES.PHP_EOL;
|
||||
exec('rm -rf "'.AirtimeInstall::CONF_DIR_BINARIES.'"');
|
||||
}
|
||||
|
||||
public static function DirCheck()
|
||||
{
|
||||
echo "Legend: \"+\" means the dir/file exists, \"-\" means that it does not.".PHP_EOL;
|
||||
$dirs = array(AirtimeInstall::CONF_DIR_BINARIES,
|
||||
AirtimeInstall::CONF_DIR_WWW,
|
||||
AirtimeIni::CONF_FILE_AIRTIME,
|
||||
AirtimeIni::CONF_FILE_LIQUIDSOAP,
|
||||
AirtimeIni::CONF_FILE_PYPO,
|
||||
AirtimeIni::CONF_FILE_RECORDER,
|
||||
"/usr/lib/airtime/pypo",
|
||||
"/usr/lib/airtime/show-recorder",
|
||||
"/var/log/airtime",
|
||||
"/var/log/airtime/pypo",
|
||||
"/var/log/airtime/show-recorder",
|
||||
"/var/tmp/airtime/pypo",
|
||||
"/var/tmp/airtime/show-recorder");
|
||||
foreach ($dirs as $f) {
|
||||
if (file_exists($f)) {
|
||||
echo "+ $f".PHP_EOL;
|
||||
} else {
|
||||
echo "- $f".PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function CreateZendPhpLogFile(){
|
||||
global $CC_CONFIG;
|
||||
|
||||
echo "* Creating logs directory ".AirtimeInstall::CONF_DIR_LOG.PHP_EOL;
|
||||
|
||||
$path = AirtimeInstall::CONF_DIR_LOG;
|
||||
$file = $path.'/zendphp.log';
|
||||
if (!file_exists($path)){
|
||||
mkdir($path, 0755, true);
|
||||
}
|
||||
|
||||
touch($file);
|
||||
chmod($file, 0755);
|
||||
chown($file, $CC_CONFIG['webServerUser']);
|
||||
chgrp($file, $CC_CONFIG['webServerUser']);
|
||||
}
|
||||
|
||||
public static function RemoveLogDirectories(){
|
||||
$path = AirtimeInstall::CONF_DIR_LOG;
|
||||
echo "* Removing logs directory ".$path.PHP_EOL;
|
||||
|
||||
exec("rm -rf \"$path\"");
|
||||
}
|
||||
|
||||
public static function CreateCronFile(){
|
||||
// Create CRON task to run every day. Time of day is initialized to a random time.
|
||||
$hour = rand(0,23);
|
||||
$minute = rand(0,59);
|
||||
|
||||
$fp = fopen('/etc/cron.d/airtime-crons','w');
|
||||
fwrite($fp, "$minute $hour * * * root /usr/lib/airtime/utils/phone_home_stat\n");
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
66
install_minimal/include/airtime-db-install.php
Normal file
66
install_minimal/include/airtime-db-install.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
/**
|
||||
* This file is separated out so that it can be run separately for DEB package installation.
|
||||
* When installing a DEB package, Postgresql may not be installed yet and thus the database
|
||||
* cannot be created. So this script is run after all DEB packages have been installed.
|
||||
*/
|
||||
|
||||
set_include_path(__DIR__.'/../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
require_once(dirname(__FILE__).'/AirtimeIni.php');
|
||||
require_once(dirname(__FILE__).'/AirtimeInstall.php');
|
||||
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants.php');
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
|
||||
|
||||
echo PHP_EOL."*** Database Installation ***".PHP_EOL;
|
||||
|
||||
AirtimeInstall::CreateDatabaseUser();
|
||||
|
||||
$databaseExisted = AirtimeInstall::CreateDatabase();
|
||||
|
||||
AirtimeInstall::DbConnect(true);
|
||||
|
||||
AirtimeInstall::InstallPostgresScriptingLanguage();
|
||||
|
||||
if (isset($argv[1]) && $argv[1] == 'y') {
|
||||
AirtimeInstall::CreateDatabaseTables();
|
||||
} else if ($databaseExisted) {
|
||||
//Database already exists. Ask the user how they want to
|
||||
//proceed. Warn them that creating the database tables again
|
||||
//will cause them to lose their old ones.
|
||||
|
||||
$userAnswer = "x";
|
||||
while (!in_array($userAnswer, array("y", "Y", "n", "N", ""))) {
|
||||
echo PHP_EOL."Database already exists. Do you want to delete all tables and recreate? (y/N)";
|
||||
$userAnswer = trim(fgets(STDIN));
|
||||
}
|
||||
if (in_array($userAnswer, array("y", "Y"))) {
|
||||
AirtimeInstall::CreateDatabaseTables();
|
||||
}
|
||||
} else {
|
||||
//Database was just created, meaning the tables do not
|
||||
//exist. Let's create them.
|
||||
AirtimeInstall::CreateDatabaseTables();
|
||||
}
|
||||
|
||||
echo "* Setting Airtime version".PHP_EOL;
|
||||
AirtimeInstall::SetAirtimeVersion(AIRTIME_VERSION);
|
||||
|
||||
AirtimeInstall::SetUniqueId();
|
||||
|
||||
if (AirtimeInstall::$databaseTablesCreated) {
|
||||
|
||||
$ini = parse_ini_file(__DIR__."/airtime-install.ini");
|
||||
|
||||
$stor_dir = realpath($ini["storage_dir"])."/";
|
||||
echo "* Inserting stor directory location $stor_dir into music_dirs table".PHP_EOL;
|
||||
|
||||
$sql = "INSERT INTO cc_music_dirs (directory, type) VALUES ('$stor_dir', 'stor')";
|
||||
$result = $CC_DBC->query($sql);
|
||||
if (PEAR::isError($result)) {
|
||||
echo "* Failed inserting {$stor_dir} in cc_music_dirs".PHP_EOL;
|
||||
echo "* Message {$result->getMessage()}".PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
}
|
1
install_minimal/include/airtime-install.ini
Normal file
1
install_minimal/include/airtime-install.ini
Normal file
|
@ -0,0 +1 @@
|
|||
storage_dir = /srv/airtime/stor/
|
148
install_minimal/include/airtime-install.php
Normal file
148
install_minimal/include/airtime-install.php
Normal file
|
@ -0,0 +1,148 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Airtime
|
||||
* @copyright 2011 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*
|
||||
* Checks if a previous version of Airtime is currently installed and upgrades Airtime if so.
|
||||
* Performs a new install (new configs, database install) if a version of Airtime is not found.
|
||||
* If the current version is found to be installed the user is presented with the help menu and can
|
||||
* choose -r to reinstall.
|
||||
*/
|
||||
set_include_path(__DIR__.'/../../airtime_mvc/library' . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
require_once(dirname(__FILE__).'/AirtimeIni.php');
|
||||
require_once(dirname(__FILE__).'/AirtimeInstall.php');
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants.php');
|
||||
|
||||
AirtimeInstall::ExitIfNotRoot();
|
||||
|
||||
$newInstall = false;
|
||||
$version = AirtimeInstall::GetVersionInstalled();
|
||||
|
||||
require_once('Zend/Loader/Autoloader.php');
|
||||
$autoloader = Zend_Loader_Autoloader::getInstance();
|
||||
|
||||
function printUsage($opts)
|
||||
{
|
||||
$msg = $opts->getUsageMessage();
|
||||
echo PHP_EOL."Usage: airtime-install [options]";
|
||||
echo substr($msg, strpos($msg, "\n")).PHP_EOL;
|
||||
}
|
||||
|
||||
try {
|
||||
$opts = new Zend_Console_Getopt(
|
||||
array(
|
||||
'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'
|
||||
)
|
||||
);
|
||||
$opts->parse();
|
||||
}
|
||||
catch (Zend_Console_Getopt_Exception $e) {
|
||||
print $e->getMessage() .PHP_EOL;
|
||||
printUsage($opts);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (isset($opts->h)) {
|
||||
printUsage($opts);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// The current version is already installed.
|
||||
if (isset($version) && ($version != false) && ($version == AIRTIME_VERSION) && !isset($opts->r)) {
|
||||
echo "Airtime $version is already installed.".PHP_EOL;
|
||||
printUsage($opts);
|
||||
exit(1);
|
||||
}
|
||||
// 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");
|
||||
|
||||
//Make sure to exit with non-zero error code so that airtime-install
|
||||
//shell script does not continue with installing pypo, show-recorder,
|
||||
//media-monitor etc.
|
||||
exit(2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// The only way we get here is if we are doing a new install or a reinstall.
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
if(is_null($version)) {
|
||||
$newInstall = true;
|
||||
}
|
||||
|
||||
$db_install = true;
|
||||
if (is_null($opts->r) && isset($opts->n)) {
|
||||
$db_install = false;
|
||||
}
|
||||
|
||||
$overwrite = false;
|
||||
if (isset($opts->o) || $newInstall == true) {
|
||||
$overwrite = true;
|
||||
}
|
||||
else if (!isset($opts->p) && !isset($opts->o) && isset($opts->r)) {
|
||||
if (AirtimeIni::IniFilesExist()) {
|
||||
$userAnswer = "x";
|
||||
while (!in_array($userAnswer, array("o", "O", "p", "P", ""))) {
|
||||
echo PHP_EOL."You have existing config files. Do you want to (O)verwrite them, or (P)reserve them? (o/P) ";
|
||||
$userAnswer = trim(fgets(STDIN));
|
||||
}
|
||||
if (in_array($userAnswer, array("o", "O"))) {
|
||||
$overwrite = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$overwrite = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($overwrite) {
|
||||
echo "* Creating INI files".PHP_EOL;
|
||||
AirtimeIni::CreateIniFiles();
|
||||
}
|
||||
AirtimeIni::CreateMonitFile();
|
||||
|
||||
|
||||
AirtimeInstall::InstallPhpCode();
|
||||
AirtimeInstall::InstallBinaries();
|
||||
|
||||
if ($overwrite) {
|
||||
echo "* Initializing INI files".PHP_EOL;
|
||||
AirtimeIni::UpdateIniFiles();
|
||||
}
|
||||
|
||||
// Update the build.properties file to point to the correct directory.
|
||||
AirtimeIni::UpdateIniValue(AirtimeInstall::CONF_DIR_WWW.'/build/build.properties', 'project.home', AirtimeInstall::CONF_DIR_WWW);
|
||||
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
|
||||
|
||||
echo "* Airtime Version: ".AIRTIME_VERSION.PHP_EOL;
|
||||
|
||||
AirtimeInstall::InstallStorageDirectory();
|
||||
|
||||
if ($db_install) {
|
||||
if($newInstall) {
|
||||
// This is called with "system" so that we can pass in a parameter. See the file itself
|
||||
// for why we need to do this.
|
||||
system('php '.__DIR__.'/airtime-db-install.php y');
|
||||
AirtimeInstall::DbConnect(true);
|
||||
} else {
|
||||
require_once('airtime-db-install.php');
|
||||
}
|
||||
}
|
||||
|
||||
AirtimeInstall::CreateSymlinksToUtils();
|
||||
|
||||
AirtimeInstall::CreateZendPhpLogFile();
|
||||
|
||||
AirtimeInstall::CreateCronFile();
|
||||
|
||||
/* FINISHED AIRTIME PHP INSTALLER */
|
87
install_minimal/include/airtime-uninstall.php
Normal file
87
install_minimal/include/airtime-uninstall.php
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Airtime
|
||||
* @copyright 2010 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__).'/AirtimeIni.php');
|
||||
require_once(dirname(__FILE__).'/AirtimeInstall.php');
|
||||
// Need to check that we are superuser before running this.
|
||||
AirtimeInstall::ExitIfNotRoot();
|
||||
|
||||
if (!file_exists(AirtimeIni::CONF_FILE_AIRTIME)) {
|
||||
echo PHP_EOL."Airtime config file '".AirtimeIni::CONF_FILE_AIRTIME."' does not exist.".PHP_EOL;
|
||||
echo "Most likely this means that Airtime is not installed, so there is nothing to do.".PHP_EOL.PHP_EOL;
|
||||
exit();
|
||||
}
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/constants.php');
|
||||
require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php');
|
||||
|
||||
echo PHP_EOL;
|
||||
echo "* Uninstalling Airtime ".AIRTIME_VERSION.PHP_EOL;
|
||||
AirtimeInstall::UninstallPhpCode();
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Delete the database
|
||||
// Note: Do not put a call to AirtimeInstall::DbConnect()
|
||||
// before this function, even if you called $CC_DBC->disconnect(), there will
|
||||
// still be a connection to the database and you wont be able to delete it.
|
||||
//------------------------------------------------------------------------
|
||||
echo " * Dropping the database '".$CC_CONFIG['dsn']['database']."'...".PHP_EOL;
|
||||
|
||||
// check if DB exists
|
||||
$command = "echo \"DROP DATABASE IF EXISTS ".$CC_CONFIG['dsn']['database']."\" | su postgres -c psql";
|
||||
|
||||
@exec($command, $output, $dbDeleteFailed);
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Delete DB tables
|
||||
// We do this if dropping the database fails above.
|
||||
//------------------------------------------------------------------------
|
||||
if ($dbDeleteFailed) {
|
||||
echo " * Couldn't delete the database, so deleting all the DB tables...".PHP_EOL;
|
||||
AirtimeInstall::DbConnect(false);
|
||||
|
||||
if (!PEAR::isError($CC_DBC)) {
|
||||
$sql = "select * from pg_tables where tableowner = 'airtime'";
|
||||
$rows = $CC_DBC->GetAll($sql);
|
||||
if (PEAR::isError($rows)) {
|
||||
$rows = array();
|
||||
}
|
||||
|
||||
foreach ($rows as $row) {
|
||||
$tablename = $row["tablename"];
|
||||
echo " * Removing database table $tablename...";
|
||||
|
||||
if (AirtimeInstall::DbTableExists($tablename)){
|
||||
$sql = "DROP TABLE $tablename CASCADE";
|
||||
AirtimeInstall::InstallQuery($sql, false);
|
||||
|
||||
$CC_DBC->dropSequence($tablename."_id");
|
||||
}
|
||||
echo "done.".PHP_EOL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Delete the user
|
||||
//------------------------------------------------------------------------
|
||||
echo " * Deleting database user '{$CC_CONFIG['dsn']['username']}'...".PHP_EOL;
|
||||
$command = "echo \"DROP USER IF EXISTS {$CC_CONFIG['dsn']['username']}\" | su postgres -c psql >/dev/null 2>&1";
|
||||
@exec($command, $output, $results);
|
||||
if ($results == 0) {
|
||||
echo " * User '{$CC_CONFIG['dsn']['username']}' deleted.".PHP_EOL;
|
||||
} else {
|
||||
echo " * Nothing to delete.".PHP_EOL;
|
||||
}
|
||||
|
||||
AirtimeInstall::RemoveSymlinks();
|
||||
AirtimeInstall::UninstallBinaries();
|
||||
AirtimeInstall::RemoveLogDirectories();
|
||||
AirtimeIni::RemoveMonitFile();
|
||||
|
||||
@unlink('/etc/cron.d/airtime-crons');
|
||||
|
||||
/* FINISHED AIRTIME PHP UNINSTALLER */
|
114
install_minimal/include/airtime-upgrade.php
Normal file
114
install_minimal/include/airtime-upgrade.php
Normal file
|
@ -0,0 +1,114 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Airtime
|
||||
* @subpackage StorageServer
|
||||
* @copyright 2010 Sourcefabric O.P.S.
|
||||
* @license http://www.gnu.org/licenses/gpl.txt
|
||||
*/
|
||||
|
||||
//Pear classes.
|
||||
set_include_path(__DIR__.'/../../airtime_mvc/library/pear' . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
require_once('DB.php');
|
||||
require_once(__DIR__.'/../../airtime_mvc/application/configs/constants.php');
|
||||
require_once(dirname(__FILE__).'/AirtimeIni.php');
|
||||
|
||||
if(exec("whoami") != "root"){
|
||||
echo "Must be root user.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
global $CC_DBC, $CC_CONFIG;
|
||||
|
||||
$values = parse_ini_file('/etc/airtime/airtime.conf', true);
|
||||
|
||||
// Database config
|
||||
$CC_CONFIG['dsn']['username'] = $values['database']['dbuser'];
|
||||
$CC_CONFIG['dsn']['password'] = $values['database']['dbpass'];
|
||||
$CC_CONFIG['dsn']['hostspec'] = $values['database']['host'];
|
||||
$CC_CONFIG['dsn']['phptype'] = 'pgsql';
|
||||
$CC_CONFIG['dsn']['database'] = $values['database']['dbname'];
|
||||
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], FALSE);
|
||||
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
echo $CC_DBC->getMessage().PHP_EOL;
|
||||
echo $CC_DBC->getUserInfo().PHP_EOL;
|
||||
echo "Database connection problem.".PHP_EOL;
|
||||
echo "Check if database '{$CC_CONFIG['dsn']['database']}' exists".
|
||||
" with corresponding permissions.".PHP_EOL;
|
||||
exit(1);
|
||||
} else {
|
||||
echo "* Connected to database".PHP_EOL;
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
}
|
||||
|
||||
$sql = "SELECT valstr FROM cc_pref WHERE keystr = 'system_version'";
|
||||
$version = $CC_DBC->GetOne($sql);
|
||||
|
||||
if (PEAR::isError($version)) {
|
||||
$version = false;
|
||||
}
|
||||
|
||||
if (!$version){
|
||||
|
||||
$sql = "SELECT * FROM ".$p_name;
|
||||
$result = $CC_DBC->GetOne($sql);
|
||||
if (!PEAR::isError($result)) {
|
||||
$version = "1.7.0";
|
||||
echo "Airtime Version: ".$version." ".PHP_EOL;
|
||||
}
|
||||
else {
|
||||
$version = "1.6";
|
||||
echo "Airtime Version: ".$version." ".PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
echo "******************************** Update Begin *********************************".PHP_EOL;
|
||||
|
||||
//convert strings like 1.9.0-devel to 1.9.0
|
||||
$version = substr($version, 0, 5);
|
||||
|
||||
if (strcmp($version, "1.7.0") < 0){
|
||||
system("php ".__DIR__."/../upgrades/airtime-1.7.0/airtime-upgrade.php");
|
||||
}
|
||||
if (strcmp($version, "1.8.0") < 0){
|
||||
system("php ".__DIR__."/../upgrades/airtime-1.8.0/airtime-upgrade.php");
|
||||
}
|
||||
if (strcmp($version, "1.8.1") < 0){
|
||||
system("php ".__DIR__."/../upgrades/airtime-1.8.1/airtime-upgrade.php");
|
||||
}
|
||||
if (strcmp($version, "1.8.2") < 0){
|
||||
system("php ".__DIR__."/../upgrades/airtime-1.8.2/airtime-upgrade.php");
|
||||
}
|
||||
if (strcmp($version, "1.9.0") < 0){
|
||||
system("php ".__DIR__."/../upgrades/airtime-1.9.0/airtime-upgrade.php");
|
||||
}
|
||||
|
||||
|
||||
//set the new version in the database.
|
||||
$sql = "DELETE FROM cc_pref WHERE keystr = 'system_version'";
|
||||
$CC_DBC->query($sql);
|
||||
|
||||
$newVersion = AIRTIME_VERSION;
|
||||
$sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '$newVersion')";
|
||||
$CC_DBC->query($sql);
|
||||
|
||||
echo PHP_EOL."*** Updating Api Client ***".PHP_EOL;
|
||||
passthru("python ".__DIR__."/../../python_apps/api_clients/install/api_client_install.py");
|
||||
|
||||
echo PHP_EOL."*** Updating Pypo ***".PHP_EOL;
|
||||
passthru("python ".__DIR__."/../../python_apps/pypo/install/pypo-install.py");
|
||||
|
||||
echo PHP_EOL."*** Updating Recorder ***".PHP_EOL;
|
||||
passthru("python ".__DIR__."/../../python_apps/show-recorder/install/recorder-install.py");
|
||||
|
||||
echo PHP_EOL."*** Updating Media Monitor ***".PHP_EOL;
|
||||
passthru("python ".__DIR__."/../../python_apps/media-monitor/install/media-monitor-install.py");
|
||||
|
||||
AirtimeIni::CreateMonitFile();
|
||||
|
||||
sleep(4);
|
||||
passthru("airtime-check-system");
|
||||
|
||||
echo "******************************* Update Complete *******************************".PHP_EOL;
|
Loading…
Add table
Add a link
Reference in a new issue