public function install($app, $db_params) { logMessage(L_USER, sprintf("Copying application files to %s", $app->get('BASE_DIR'))); if (!OsUtils::fullCopy('package/app/', $app->get('BASE_DIR'))) { return "Failed to copy application files to target directory"; } $os_name = OsUtils::getOsName(); $architecture = OsUtils::getSystemArchitecture(); logMessage(L_USER, "Copying binaries for {$os_name} {$architecture}"); if (!OsUtils::fullCopy("package/bin/{$os_name}/{$architecture}", $app->get('BIN_DIR'))) { return "Failed to copy binaris for {$os_name} {$architecture}"; } logMessage(L_USER, "Replacing configuration tokens in files"); foreach ($this->install_config['token_files'] as $file) { $replace_file = $app->replaceTokensInString($file); if (!$app->replaceTokensInFile($replace_file)) { return "Failed to replace tokens in {$replace_file}"; } } logMessage(L_USER, "Changing permissions of directories and files"); foreach ($this->install_config['chmod_items'] as $item) { $chmod_item = $app->replaceTokensInString($item); if (!OsUtils::chmod($chmod_item)) { return "Failed to change permissions for {$chmod_item}"; } } $sql_files = parse_ini_file($app->get('BASE_DIR') . APP_SQL_DIR . 'create_kaltura_db.ini', true); logMessage(L_USER, sprintf("Creating and initializing '%s' database", $app->get('DB1_NAME'))); if (!DatabaseUtils::createDb($db_params, $app->get('DB1_NAME'))) { return "Failed to create '" . $app->get('DB1_NAME') . "' database"; } foreach ($sql_files['kaltura']['sql'] as $sql) { $sql_file = $app->get('BASE_DIR') . APP_SQL_DIR . $sql; if (!DatabaseUtils::runScript($sql_file, $db_params, $app->get('DB1_NAME'))) { return "Failed running database script {$sql_file}"; } } logMessage(L_USER, sprintf("Creating and initializing '%s' database", $app->get('DB_STATS_NAME'))); if (!DatabaseUtils::createDb($db_params, $app->get('DB_STATS_NAME'))) { return "Failed to create '" . $app->get('DB_STATS_NAME') . "' database"; } foreach ($sql_files['stats']['sql'] as $sql) { $sql_file = $app->get('BASE_DIR') . APP_SQL_DIR . $sql; if (!DatabaseUtils::runScript($sql_file, $db_params, $app->get('DB_STATS_NAME'))) { return "Failed running database script {$sql_file}"; } } logMessage(L_USER, "Creating data warehouse"); if (!OsUtils::execute(sprintf("%s/ddl/dwh_ddl_install.sh -h %s -P %s -u %s -p %s -d %s ", $app->get('DWH_DIR'), $app->get('DB1_HOST'), $app->get('DB1_PORT'), $app->get('DWH_USER'), $app->get('DWH_PASS'), $app->get('DWH_DIR')))) { return "Failed running data warehouse initialization script"; } logMessage(L_USER, "Creating Dynamic Enums"); if (OsUtils::execute(sprintf("%s %s/deployment/base/scripts/installPlugins.php", $app->get('PHP_BIN'), $app->get('APP_DIR')))) { logMessage(L_INFO, "Dynamic Enums created"); } else { return "Failed to create dynamic enums"; } logMessage(L_USER, "Configure sphinx"); if (OsUtils::execute(sprintf("%s %s/deployment/base/scripts/configureSphinx.php", $app->get('PHP_BIN'), $app->get('APP_DIR')))) { logMessage(L_INFO, "sphinx configuration file (kaltura.conf) created"); } else { return "Failed to create sphinx configuration file (kaltura.conf)"; } logMessage(L_USER, "Running the sphinx search deamon"); !OsUtils::executeInBackground($app->get('APP_DIR') . '/plugins/sphinx_search/scripts/watch.daemon.sh -u root'); logMessage(L_USER, "Creating system symbolic links"); foreach ($this->install_config['symlinks'] as $slink) { $link_items = explode(SYMLINK_SEPARATOR, $app->replaceTokensInString($slink)); if (symlink($link_items[0], $link_items[1])) { logMessage(L_INFO, "Created symbolic link {$link_items['0']} -> {$link_items['1']}"); } else { return sprintf("Failed to create symblic link from %s to %s", $link_items[0], $link_items[1]); } } if (strcasecmp($app->get('KALTURA_VERSION_TYPE'), K_CE_TYPE) == 0) { $app->simMafteach(); } logMessage(L_USER, "Deploying uiconfs in order to configure the application"); foreach ($this->install_config['uiconfs'] as $uiconfapp) { $to_deploy = $app->replaceTokensInString($uiconfapp); if (OsUtils::execute(sprintf("%s %s/deployment/uiconf/deploy.php --disableUrlHashing=true --ini=%s", $app->get('PHP_BIN'), $app->get('APP_DIR'), $to_deploy))) { logMessage(L_INFO, "Deployed uiconf {$to_deploy}"); } else { return "Failed to deploy uiconf {$to_deploy}"; } } logMessage(L_USER, "Deploying uiconfs in order to configure the application"); foreach ($this->install_config['uiconfs_2'] as $uiconfapp) { $to_deploy = $app->replaceTokensInString($uiconfapp); if (OsUtils::execute(sprintf("%s %s/deployment/uiconf/deploy_v2.php --ini=%s", $app->get('PHP_BIN'), $app->get('APP_DIR'), $to_deploy))) { logMessage(L_INFO, "Deployed uiconf {$to_deploy}"); } else { return "Failed to deploy uiconf {$to_deploy}"; } } logMessage(L_USER, "Creating the uninstaller"); if (!OsUtils::fullCopy('installer/uninstall.php', $app->get('BASE_DIR') . "/uninstaller/")) { return "Failed to create the uninstaller"; } $app->saveUninstallerConfig($this->install_config['symlinks']); logMessage(L_USER, "Running the batch manager"); if (!OsUtils::execute($app->get('APP_DIR') . '/scripts/serviceBatchMgr.sh start')) { return "Failed running the btach manager"; } return null; }
public function installRed5($app) { OsUtils::execute("dos2unix " . $app->get('BIN_DIR') . "/red5/red5"); OsUtils::execute("ln -s " . $app->get('BIN_DIR') . "/red5/red5 /etc/init.d/red5"); OsUtils::execute("/etc/init.d/red5 start"); OsUtils::executeInBackground('chkconfig red5 on'); //Replace rtmp_url parameter in the local.ini configuration file $location = $app->get('APP_DIR') . "/configurations/local.ini"; $localValues = parse_ini_file($location, true); $localValues['rtmp_url'] = 'rtmp://' . $app->get('KALTURA_VIRTUAL_HOST_NAME') . '/oflaDemo'; OsUtils::writeToIniFile($location, $localValues); //url-managers.ini change $location = $app->get('APP_DIR') . "/configurations/url_managers.ini"; $urlManagersValues = parse_ini_file($location); $red5Addition = array('class' => 'kLocalPathUrlManager'); $urlManagersValues[$app->get('ENVIRONMENT_NAME')] = $red5Addition; OsUtils::writeToIniFile($location, $urlManagersValues); //Retrieve KCW uiconf ids $uiconfIds = $this->extractKCWUiconfIds($app); logMessage(L_USER, "If you are insterested in recording entries from webcam, please adjust the RTMP server URL in each of the following uiConfs:\r\n" . implode("\r\n", $uiconfIds)); logMessage(L_USER, "By replacing 'rtmp://yoursite.com/oflaDemo' with 'rtmp://" . $app->get('ENVIRONMENT_NAME') . "/oflaDemo"); OsUtils::execute("mv " . $app->get('BIN_DIR') . "/red5/webapps/oflaDemo/streams " . $app->get('BIN_DIR') . "/red5/webapps/oflaDemo/streams_x"); OsUtils::execute("ln -s " . $app->get('WEB_DIR') . "/content/webcam " . $app->get('BIN_DIR') . "/red5/webapps/oflaDemo/streams"); OsUtils::execute("ln -s " . $app->get('WEB_DIR') . "/content " . $app->get('BIN_DIR') . "/red5/webapps/oflaDemo/streams"); }
private function installRed5($app) { if (!$app->get('RED5_INSTALL')) { return; } OsUtils::execute("dos2unix " . $app->get('BIN_DIR') . "/red5/red5"); OsUtils::execute("ln -s " . $app->get('BIN_DIR') . "/red5/red5 /etc/init.d/red5"); OsUtils::execute("/etc/init.d/red5 start"); OsUtils::executeInBackground('chkconfig red5 on'); //Replace rtmp_url parameter in the local.ini configuration file $location = $app->get('APP_DIR') . "/configurations/local.ini"; $localValues = parse_ini_file($location, true); $localValues['rtmp_url'] = 'rtmp://' . $app->get('BASE_HOST_NO_PORT') . '/oflaDemo'; OsUtils::writeToIniFile($location, $localValues); //url-managers.ini change $location = $app->get('APP_DIR') . "/configurations/url_managers.ini"; $urlManagersValues = parse_ini_file($location); $red5Addition = array('class' => 'kLocalPathUrlManager'); $urlManagersValues[$app->get('BASE_HOST_NO_PORT')] = $red5Addition; OsUtils::writeToIniFile($location, $urlManagersValues); OsUtils::execute("mv " . $app->get('BIN_DIR') . "/red5/webapps/oflaDemo/streams " . $app->get('BIN_DIR') . "/red5/webapps/oflaDemo/streams_x"); OsUtils::execute("ln -s " . $app->get('WEB_DIR') . "/content/webcam " . $app->get('BIN_DIR') . "/red5/webapps/oflaDemo/streams"); OsUtils::execute("ln -s " . $app->get('WEB_DIR') . "/content " . $app->get('BIN_DIR') . "/red5/webapps/oflaDemo/streams"); }
//return "\nFailed running script batchuser\n"; //} logMessage(L_USER, 'add crons'); $cron_content = file_get_contents('/opt/kaltura/crontab/kaltura_crontab'); logMessage(L_USER, 'apending crons: ' . $cron_content); OsUtils::appendFile('/etc/crontab', $cron_content); $cron_content = file_get_contents('/opt/kaltura/dwh/crontab/dwh_crontab'); logMessage(L_USER, 'apending crons: ' . $cron_content); OsUtils::appendFile('/etc/crontab', $cron_content); logMessage(L_USER, 'restart cron'); if (!OsUtils::execute("/etc/init.d/crond restart")) { echo "Failed restart cron"; return "\nFailed cron\n"; } logMessage(L_USER, 'chmod'); if (!OsUtils::execute("chmod 700 /etc/cron.d")) { echo "Failed chmod"; return "\nFailed chmod\n"; } //logMessage(L_USER, 'chmod'); //if (!OsUtils::execute("chmod 700 /etc/rc.d/init.d")) { // echo "Failed chmod"; // return "\nFailed chmod\n"; //} $kalturaProcesses = implode(OsUtils::executeReturnOutput("ps -ef | grep kaltura")); logMessage(L_USER, 'ps -ef | grep kaltura: ' . $kalturaProcesses); $processFound = strstr($kalturaProcesses, 'searchd --config'); if (!$processFound) { echo 'ERROR: searchd is not running'; } $processFound = strstr($kalturaProcesses, 'KGenericBatchMgr.class.php');