Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions cfe_internal/enterprise/CFE_hub_specific.cf
Original file line number Diff line number Diff line change
Expand Up @@ -115,34 +115,50 @@ bundle agent update_cli_rest_server_url_config
# Both share and live versions must be changed at once since httpd will be restarted later in the same agent run.
"mp_config_file" string => "$(cfe_internal_hub_vars.docroot)/application/config/config.php";
"mp_share_config_file" string => "$(sys.workdir)/share/GUI/application/config/config.php";
"regex_test_pattern" string => ".*localhost:$(cfe_internal_hub_vars.https_port).*";
"api_config_file" string => "$(cfe_internal_hub_vars.docroot)/api/modules/inventory/config/config.php";
"mp_test_pattern" string => ".*localhost:$(cfe_internal_hub_vars.https_port).*";
"api_test_pattern" string => ".*127.0.0.1:$(cfe_internal_hub_vars.https_port).*";

files:
mpf_enable_mission_portal_docroot_sync_from_share_gui::
"$(mp_share_config_file)"
handle => "cfe_internal_edit_share_gui_mp_config",
edit_line => change_cli_rest_server_url_port,
edit_line => change_mp_server_url_port,
if => and(
fileexists("$(mp_share_config_file)"),
islessthan(countlinesmatching("$(regex_test_pattern)", "$(mp_share_config_file)"), 1)
islessthan(countlinesmatching("$(mp_test_pattern)", "$(mp_share_config_file)"), 1)
);

any::
"$(mp_config_file)"
handle => "cfe_internal_edit_mp_config",
edit_line => change_cli_rest_server_url_port,
edit_line => change_mp_server_url_port,
if => and(
fileexists("$(mp_config_file)"),
islessthan(countlinesmatching("$(regex_test_pattern)", "$(mp_config_file)"), 1)
islessthan(countlinesmatching("$(mp_test_pattern)", "$(mp_config_file)"), 1)
);

"$(api_config_file)"
edit_line => change_api_server_url_port,
if => and(
fileexists("$(api_config_file)"),
islessthan(countlinesmatching("$(api_test_pattern)", "$(api_config_file)"), 1)
);
}

bundle edit_line change_cli_rest_server_url_port
bundle edit_line change_mp_server_url_port
{
replace_patterns:
"^\s*\$config\['cli_rest_server_url'\]\s*=\s*\"https://localhost(?::(?!$(cfe_internal_hub_vars.https_port))\d{1,5})?/api/\";\s*$"
replace_with => value(" $config['cli_rest_server_url'] = \"https://localhost:$(cfe_internal_hub_vars.https_port)/api/\";"),
comment => "Change port CLI REST server URL port";
comment => "Change port MP REST server URL port";
}
bundle edit_line change_api_server_url_port
{
replace_patterns:
"^\s*define\(\"API_URL\",\s*\"https://127.0.0.1(?::(?!$(cfe_internal_hub_vars.https_port))\d{1,5})?/api\"\);\s*$"
replace_with => value("define(\"API_URL\", \"https://127.0.0.1:$(cfe_internal_hub_vars.https_port)/api/\");"),
comment => "Change port API REST server URL port";
}

##################################################################
Expand Down
11 changes: 5 additions & 6 deletions cfe_internal/enterprise/CFE_knowledge.cf
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ bundle agent cfe_internal_setup_knowledge
copy_from => no_backup_cp_compare("$(sys.workdir)/share/GUI", "binary"),
depth_search => recurse("inf");

"$(cfe_internal_hub_vars.docroot)/.htaccess"
comment => "Correct up htaccess file in doc root",
handle => "cfe_internal_setup_knowledge_files_doc_root_htaccess",
copy_from => no_backup_cp("$(sys.workdir)/share/GUI/Apache-htaccess");

any::

"$(install_logs)" -> { "ENT-4506" }
Expand Down Expand Up @@ -129,12 +134,6 @@ bundle agent cfe_internal_setup_knowledge
handle => "cfe_internal_setup_knowledge_dir_httpd",
perms => mog("755", "root", "root");

"$(cfe_internal_hub_vars.docroot)/.htaccess" -> { "ENT-13173" }
comment => "Correct up htaccess file in doc root",
handle => "cfe_internal_setup_knowledge_files_doc_root_htaccess",
copy_from => no_backup_cp("$(sys.workdir)/share/GUI/Apache-htaccess"),
if => "mpf_enable_mission_portal_docroot_sync_from_share_gui";

"$(cfe_internal_hub_vars.public_docroot)/scripts/." -> { "CFE-951" }
comment => "Ensure permissions for $(cfe_internal_hub_vars.public_docroot)/scripts",
handle => "cfe_internal_setup_knowledge_files_doc_root_scripts_dir",
Expand Down
21 changes: 16 additions & 5 deletions cfe_internal/enterprise/mission_portal.cf
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,19 @@ bundle agent mission_portal_apache_from_stage(config, staged_config)
expression => returnszero("$(paths.systemctl) -q is-active cf-apache > /dev/null 2>&1", "useshell"),
if => fileexists( $(paths.systemctl) );

"httpd_config_validated"
expression => strcmp("$(validate_result.exit_code)", "0");
"httpd_config_error"
expression => not(strcmp("$(validate_result.exit_code)", "0"));

vars:

"validate_config"
string => "$(sys.workdir)/httpd/bin/httpd -t -f $(staged_config)";

"validate_result"
data => execresult_as_data("$(validate_config)", "useshell", "both");

# The location of the apache pid file moved from httpd/logs/httpd.pid to
# httpd/httpd.pid in 3.15.5, 3.18.1 and, 3.19.0

Expand All @@ -296,7 +304,7 @@ bundle agent mission_portal_apache_from_stage(config, staged_config)
if => and( or( "apache_stop_after_new_staged_config_repaired",
not( fileexists( "$(httpd_pid_file)" ) ),
isnewerthan( $(config), $(staged_config) ) ),
returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell")),
"httpd_config_validated"),
classes => results("bundle", "mission_portal_apache_config"),
comment => "We make sure that the deployed config is a copy of the staged
config if the staged config passes a syntax check. We redirect
Expand All @@ -313,7 +321,7 @@ bundle agent mission_portal_apache_from_stage(config, staged_config)
!systemd_supervised::
"LD_LIBRARY_PATH=$(sys.workdir)/lib:$LD_LIBRARY_PATH $(sys.workdir)/httpd/bin/apachectl"
args => "stop",
if => and( returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell"),
if => and( "httpd_config_validated",
isnewerthan( $(staged_config), $(config) ),
fileexists( "$(httpd_pid_file)" ) ),
contain => in_shell,
Expand All @@ -340,7 +348,8 @@ bundle agent mission_portal_apache_from_stage(config, staged_config)
systemd_supervised::
"cf-apache"
service_policy => "stop",
if => and( returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell"),
if => and( "httpd_config_validated",

isnewerthan( $(staged_config), $(config) ) ),
classes => results( "bundle", "apache_stop_after_new_staged_config" ),
comment => concat( "We have to stop apache before trying to start with a",
Expand All @@ -360,12 +369,14 @@ bundle agent mission_portal_apache_from_stage(config, staged_config)
comment => "We restart apache after the new valid config is in place";

reports:
httpd_config_error::
"'$(staged_config)' failed to validate: $(validate_result.output)";
DEBUG|DEBUG_mission_portal_apache_from_stage::
"DEBUG $(this.bundle): '$(config)' should be a copy of '$(staged_config)' because it validates with '$(validate_config)'"
if => returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell");
if => "httpd_config_validated";

"DEBUG $(this.bundle): '$(config)' should *not* be a copy of '$(staged_config)' because it failed to validate with '$(validate_config)'"
if => not(returnszero("$(validate_config) > /dev/null 2>&1 ", "useshell"));
if => not( "httpd_config_validated" );
}

##################################################################
Expand Down