Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change macOS register agent installation script #5481

Merged
merged 2 commits into from
May 23, 2023
Merged
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ All notable changes to the Wazuh app project will be documented in this file.

### Fixed

- Fixed macos apple install command [#5466](https:/wazuh/wazuh-kibana-app/pull/5466)
- Fixed macos apple install command [#5466](https:/wazuh/wazuh-kibana-app/pull/5466) [#5481](https:/wazuh/wazuh-kibana-app/pull/5481)

## Wazuh v4.4.2 - OpenSearch Dashboards 2.6.0 - Revision 01

Expand Down
24 changes: 8 additions & 16 deletions public/controllers/agent/components/register-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,23 +403,11 @@ export const RegisterAgent = withErrorBoundary(
.join(',')}' `;
}

// macos doesnt need = param
if (this.state.selectedOS === 'macos') {
return deployment.replace(/=/g, ' ');
}

return deployment;
}

agentNameVariable() {
let agentName = `WAZUH_AGENT_NAME='${this.state.agentName}' `;
if (
this.state.selectedOS === 'macos' &&
this.state.selectedArchitecture &&
this.state.agentName !== ''
) {
return agentName.replace(/=/g, ' ');
}
if (this.state.selectedArchitecture && this.state.agentName !== '') {
return agentName;
} else {
Expand Down Expand Up @@ -975,6 +963,12 @@ export const RegisterAgent = withErrorBoundary(
zIndex: '100',
};

// Select macOS installation script based on architecture
const macOSInstallationOptions = (this.optionalDeploymentVariables() + this.agentNameVariable()).replaceAll('\' ', '\'\\n');
const macOSInstallationSetEnvVariablesScript = macOSInstallationOptions ? `echo -e "${macOSInstallationOptions}" > /tmp/wazuh_envs && ` : ``;
const macOSInstallationScript = `curl -so wazuh-agent.pkg https://packages.wazuh.com/4.x/macos/wazuh-agent-${this.state.wazuhVersion
}-1.pkg && ${macOSInstallationSetEnvVariablesScript}sudo installer -pkg ./wazuh-agent.pkg -target /`;

const customTexts = {
rpmText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
alpineText: `wget -O /etc/apk/keys/[email protected] ${this.optionalPackages()} >> /etc/apk/repositories && \
Expand All @@ -983,9 +977,7 @@ apk add wazuh-agent=${this.state.wazuhVersion}-r1`,
centText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
debText: `curl -so wazuh-agent.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}dpkg -i ./wazuh-agent.deb`,
ubuText: `curl -so wazuh-agent.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}dpkg -i ./wazuh-agent.deb`,
macosText: `curl -so wazuh-agent.pkg https://packages.wazuh.com/4.x/macos/wazuh-agent-${
this.state.wazuhVersion
}-1.pkg && sudo launchctl setenv ${this.optionalDeploymentVariables()}${this.agentNameVariable()}&& sudo installer -pkg ./wazuh-agent.pkg -target /`,
macosText: macOSInstallationScript,
winText:
this.state.selectedVersion == 'windowsxp' ||
this.state.selectedVersion == 'windowsserver2008'
Expand Down Expand Up @@ -1539,7 +1531,7 @@ apk add wazuh-agent=${this.state.wazuhVersion}-r1`,
serverAddress: nodeSelected,
udpProtocol: this.state.haveUdpProtocol,
connectionSecure: this.state.haveConnectionSecure
});
});
};

const steps = [
Expand Down