This solution is much more streamlined then my previous solution for testing that required another VM to build and pull files from and never spent time getting it to persist through a reboot but i found some issues in the original script on my system (7.0.0 original script may work on previous versions). I initially changed a bunch of things but to stay closer to Ecosphere7903 original posted solution, which i think is better than mine, i reinstalled with minimal changes to the original instructions to get it to work.
I noticed initially that, like kizeren, the /var/ossec directory was never created so add:
# Ensure /var/ossec directory exists
if [ ! -d "/var/ossec" ]; then
mkdir -p /var/ossec
fi
# Ensure proper permissions
chown -R wazuh:wazuh /var/ossec
This check to see if the directory exist and if not create it
you can also add:
useradd -r -g wazuh -m -d /var/ossec -s /sbin/nologin wazuh
useradd doesn't by default create the directory if it doesn't exist but just add -m flag and it will
After that i noticed that the install is putting the files in /bin instead /var/ossec/bin. You can check if this is happening using a find command and see where the files are. If the same issue occurs there is a few solutions, but the easiest is you can either update the script to move the files after the install to the correct directory or change the installpkg to include an installation directory:
installpkg --root /var/ossec /boot/config/plugins/wazuh-agent-4.9.1-unraid.txz
After these updates the script runs fine and appears in the wazuh UI under agents.
I also run the install script using the plugin user scripts so i have more control over it and set to run after the array starts but adding it to the /boot/config/go gets the same result.