Skip to content

Commit

Permalink
Change macOS register agent installation script (#5481)
Browse files Browse the repository at this point in the history
* Change set environment variables for macOS

* Add changelog
  • Loading branch information
asteriscos authored May 23, 2023
1 parent b38ed89 commit 3200cc9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
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://github.com/wazuh/wazuh-kibana-app/pull/5466)
- Fixed macos apple install command [#5466](https://github.com/wazuh/wazuh-kibana-app/pull/5466) [#5481](https://github.com/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/alpine-devel@wazuh.com-633d7457.rsa.pub ${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

0 comments on commit 3200cc9

Please sign in to comment.