0byt3m1n1
Path:
/
data
/
applications
/
aps
/
typo3
/
12.4.7
/
standard
/
scripts
/
[
Home
]
File: app-util.php
<?php ini_set('include_path', '.'); require_once('env-parser.php'); require_once('file-util.php'); require_once('db-util.php'); function typo3_setup($typo3_path, $schema_files, $db_ids) { // Get hostname //exec("hostname", $output, $result_code); //if(strstr($output[0], "atl4")) $ssh_host = "atl4vuxbuild01.registeredsite.com"; //else { //$ssh_host = "qa1vuxweb01.registeredsite.com"; //} $cmd = "cp -vp PermissionsCheck.php " . $typo3_path . "/typo3/sysext/install/Classes/Database/PermissionsCheck.php 2>&1"; // Copy PHP script to check DB permissions exec($cmd, $output, $result_code); $cmd = "cp -v /prov_control/.ssh/aps-key " . $typo3_path . "/.. 2>&1"; // Copy ssh private key exec($cmd, $output, $result_code); $cmd = "chmod -v 600 " . $typo3_path . "/../aps-key 2>&1"; // Set permissions ssh private key exec($cmd, $output, $result_code); // Get the last output line where the result code of the install should be. Make sure to clear it up and return an int value $typo3_install_result = intval(trim(end($output))); // Just run one cycle from $db_ids and $schema_files if($typo3_install_result != 0) return($typo3_install_result); foreach($db_ids as $db_id){ if(get_db_type($db_id) != "mysql") { print "FIXME: database type " . get_db_type($db_id) . " is not supported.\n"; exit(1); } foreach($schema_files as $schema_filename => $schema_db_id){ /** * * Connect to 'atl4vuxbuild01' using SSH protocol and execute the official Joomla cli installer * * NOTE: This entire script is invoked by IQJPS in the following way * '/bin/su -s /bin/bash {user_id} -c "source /etc/profile && {$cmd}' therefore certain considerations * must be taken into account as the {user_id} has restricted access. See comments * * */ $ssh_cmd = "/usr/bin/ssh -i " . $typo3_path . "/../aps-key " . // Use a ssh key in an NFS volume to be available to all hostprov server and 444 file permissions to allow customer user_id to read and use it. "root@" . $ssh_host . " -o StrictHostKeyChecking=no " . // StrictHostKeyChecking=no do not force to strictly check known_host keys "\"cd " . $typo3_path . " && " . "/usr/bin/php81 bin/typo3 setup --no-interaction --driver=mysqli --force --create-site='" . fetch_env_var('BASE_URL_SCHEME') . "://" . fetch_env_var('BASE_URL_HOST') . "/" . fetch_env_var('BASE_URL_PATH') . "' " . "--server-type=apache --project-name='Typo3 sample' -vvv " . "--username='" . get_db_login($db_id) . "' " . "--host='" . get_db_address($db_id) . "' " . "--port=" . get_db_port($db_id) . " " . "--password='" . addslashes(get_db_password($db_id)) . "' " . "--dbname='" . get_db_name($db_id) . "' " . "--admin-email='user@mydomain.com' " . // fetch_env_var('SETTINGS_admin_email') . " " . "--admin-username='" . fetch_env_var('SETTINGS_admin_name') . "' " . "--admin-user-password='" . addslashes(fetch_env_var('SETTINGS_admin_password')) . "' \" " . "2>&1 | tee /var/tmp/typo-setup-output.log " . "| grep -v \.ssh; " . "echo -n \${PIPESTATUS[0]} "; // Echoes the status code of the install command (the first part of the pipe) to catch it from the prov server running the event // BEGIN: REMOVE THIS TEMP FILE $outfile = fopen("/var/tmp/typo_cmd.txt", "w"); fwrite($outfile, $ssh_cmd); fclose($outfile); // END: REMOVE THIS TEMP FILE // Execute Typo3 setup & install script exec($ssh_cmd, $output, $result_code); // Get the last output line where the result code of the install should be. Make sure to clear it up and return an int value $typo3_install_result = intval(trim(end($output))); $cmd = "rm -vf " . $typo3_path . "/../aps-key 2>&1"; // Remove ssh private key exec($cmd, $output, $result_code); // Just run one cycle from $db_ids and $schema_files return($typo3_install_result); } } } function remove_app($schema_files, $db_ids, $psa_modify_hash, $db_modify_hash, $settings_modify_hash, $crypt_settings_modify_hash, $settings_enum_modify_hash, $additional_modify_hash) { import_sql_scripts_to_databases($schema_files, $db_ids, $psa_modify_hash, $db_modify_hash, $settings_modify_hash, $crypt_settings_modify_hash, $settings_enum_modify_hash, $additional_modify_hash); } function import_sql_scripts_to_databases($schema_files, $db_ids, $psa_modify_hash, $db_modify_hash, $settings_modify_hash, $crypt_settings_modify_hash, $settings_enum_modify_hash, $additional_modify_hash) { foreach($db_ids as $db_id){ if(get_db_type($db_id) != "mysql") { print "FIXME: database type " . get_db_type($db_id) . " is not supported.\n"; exit(1); } foreach($schema_files as $schema_filename => $schema_db_id){ if($schema_db_id == $db_id){ mysql_db_connect(get_db_address($db_id), get_db_login($db_id), get_db_password($db_id), get_db_name($db_id)); $sql = modify_content($schema_filename, array_merge($psa_modify_hash, $db_modify_hash, $settings_modify_hash, $settings_enum_modify_hash, $crypt_settings_modify_hash, $additional_modify_hash)); populate_mysql_db($sql); } } } } ?>