-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update script to install Wazuh agent
- Loading branch information
Showing
1 changed file
with
55 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,30 +2,64 @@ | |
|
||
WAZUH_MANAGER="10.0.0.2" | ||
|
||
if [ "$(uname -o)" = "GNU/Linux" ] && command -v groupadd >/dev/null 2>&1; then | ||
apt-get update && apt-get install -y curl gnupg2 | ||
(curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import) | ||
chmod 644 /usr/share/keyrings/wazuh.gpg | ||
|
||
# Check if the repository is already added | ||
if ! grep -q "https://packages.wazuh.com/4.x/apt/" /etc/apt/sources.list.d/wazuh.list 2>/dev/null; then | ||
echo "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main" | tee -a /etc/apt/sources.list.d/wazuh.list | ||
install_dependencies() { | ||
if command -v apt-get >/dev/null 2>&1; then | ||
apt-get update && apt-get install -y curl gnupg2 | ||
elif command -v yum >/dev/null 2>&1; then | ||
yum install -y curl gnupg2 | ||
elif command -v zypper >/dev/null 2>&1; then | ||
zypper refresh && zypper install -y curl gnupg2 | ||
elif command -v apk >/dev/null 2>&1; then | ||
apk update && apk add curl gnupg | ||
else | ||
echo "Unsupported package manager" | ||
exit 1 | ||
fi | ||
} | ||
|
||
apt-get update | ||
apt-get install wazuh-agent -y | ||
sed -i "s|MANAGER_IP|$WAZUH_MANAGER|g" /var/ossec/etc/ossec.conf | ||
elif [ "$(which apk)" = "/sbin/apk" ]; then | ||
wget -O /etc/apk/keys/[email protected] https://packages.wazuh.com/key/alpine-devel%40wazuh.com-633d7457.rsa.pub | ||
echo "https://packages.wazuh.com/4.x/alpine/v3.12/main" >> /etc/apk/repositories | ||
apk update | ||
apk add wazuh-agent | ||
setup_wazuh_repository() { | ||
if command -v apt-get >/dev/null 2>&1; then | ||
(curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import) | ||
chmod 644 /usr/share/keyrings/wazuh.gpg | ||
if ! grep -q "https://packages.wazuh.com/4.x/apt/" /etc/apt/sources.list.d/wazuh.list 2>/dev/null; then | ||
echo "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main" | tee -a /etc/apt/sources.list.d/wazuh.list | ||
fi | ||
apt-get update | ||
apt-get install wazuh-agent -y | ||
elif command -v yum >/dev/null 2>&1; then | ||
rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH | ||
cat > /etc/yum.repos.d/wazuh.repo <<- EOM | ||
[wazuh] | ||
name=Wazuh repository | ||
baseurl=https://packages.wazuh.com/4.x/yum/ | ||
gpgcheck=1 | ||
gpgkey=https://packages.wazuh.com/key/GPG-KEY-WAZUH | ||
enabled=1 | ||
EOM | ||
yum install wazuh-agent -y | ||
elif command -v zypper >/dev/null 2>&1; then | ||
rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH | ||
zypper addrepo https://packages.wazuh.com/4.x/suse/ wazuh | ||
zypper refresh | ||
zypper install wazuh-agent -y | ||
elif command -v apk >/dev/null 2>&1; then | ||
wget -O /etc/apk/keys/[email protected] https://packages.wazuh.com/key/alpine-devel%40wazuh.com-633d7457.rsa.pub | ||
echo "https://packages.wazuh.com/4.x/alpine/v3.12/main" >> /etc/apk/repositories | ||
apk update | ||
apk add wazuh-agent | ||
else | ||
echo "Unsupported package manager" | ||
exit 1 | ||
fi | ||
} | ||
|
||
configure_wazuh_agent() { | ||
sed -i "s|MANAGER_IP|$WAZUH_MANAGER|g" /var/ossec/etc/ossec.conf | ||
else | ||
log ERROR "Unsupported OS for creating user." | ||
exit 1 | ||
fi | ||
} | ||
|
||
install_dependencies | ||
setup_wazuh_repository | ||
configure_wazuh_agent | ||
|
||
sh /app/scripts/tests/setup.sh | ||
|
||
|
@@ -56,4 +90,4 @@ chmod +x /app/scripts/install.sh | |
@test "yara.sh script downloaded" { | ||
/app/scripts/install.sh | ||
[ -f "/var/ossec/active-response/bin/yara.sh" ] | ||
} | ||
} |