-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller-wazuh.sh
executable file
·81 lines (70 loc) · 1.94 KB
/
installer-wazuh.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# Function to display help
function display_help() {
echo "Usage: $0 -m <WAZUH_MANAGER> -n <HOSTNAME_AGENT> [-i] [-e]"
echo
echo " -m <WAZUH_MANAGER> Server Wazuh (IP atau hostname)"
echo " -n <HOSTNAME_AGENT> Hostname Agent (biarkan kosong untuk menggunakan hostname sistem)"
echo " -i Install Wazuh Agent"
echo " -e Enable and start Wazuh Agent service"
echo " -h Display this help message"
exit 1
}
# Check if no arguments were provided
if [ $# -eq 0 ]; then
display_help
fi
# Variables
INSTALL=false
ENABLE=false
WAZUH_MANAGER=""
HOSTNAME_AGENT=""
# Parse command line options
while getopts "iem:n:h" opt; do
case $opt in
i)
INSTALL=true
;;
e)
ENABLE=true
;;
m)
WAZUH_MANAGER="$OPTARG"
;;
n)
HOSTNAME_AGENT="$OPTARG"
;;
h)
display_help
;;
*)
display_help
;;
esac
done
# Set hostname agent to system hostname if not provided
if [ -z "$HOSTNAME_AGENT" ]; then
HOSTNAME_AGENT=$(hostname)
fi
# Function to install Wazuh Agent
function install_wazuh_agent() {
# Download the Wazuh Agent package
wget https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_4.10.1-1_amd64.deb
# Install the Wazuh Agent
sudo WAZUH_MANAGER="$WAZUH_MANAGER" WAZUH_AGENT_GROUP='Owlexa-Healthcare' WAZUH_AGENT_NAME="$HOSTNAME_AGENT" dpkg -i ./wazuh-agent_4.10.1-1_amd64.deb
# Remove the downloaded .deb file
rm -f ./wazuh-agent*.deb
}
# Function to enable and start Wazuh Agent service
function enable_service() {
sudo systemctl enable wazuh-agent
sudo systemctl start wazuh-agent
}
# Execute installation if requested
if $INSTALL; then
install_wazuh_agent
fi
# Enable service if requested
if $ENABLE; then
enable_service
fi