I am using the following to keep osquery updated in all my macOS agents:
#!/bin/bash
install_version="4.8.0"
down_url="https://pkg.osquery.io/darwin/osquery-${install_version}.pkg"
pkg="/tmp/osquery.pkg"
if [ ! -x /usr/local/bin/osqueryi ]; then
curl -s --fail -o $pkg $down_url
if [ $? -eq 0 ]; then
installer -pkg $pkg -target / > /dev/null 2>&1
sleep 30
/Library/Ossec/bin/ossec-control restart > /dev/null 2>&1
exit 0
fi
elif [ "$(/usr/local/bin/osqueryi --version | awk '{print $3}')" != "$install_version" ]; then
launchctl unload /Library/LaunchDaemons/com.facebook.osqueryd.plist
rm /Library/LaunchDaemons/com.facebook.osqueryd.plist
rm -rf /private/var/log/osquery
rm -rf /private/var/osquery
rm /usr/local/bin/osquery*
pkgutil --forget com.facebook.osquery
curl -s --fail -o $pkg $down_url
if [ $? -eq 0 ]; then
installer -pkg $pkg -target / > /dev/null 2>&1
sleep 30
/Library/Ossec/bin/ossec-control restart > /dev/null 2>&1
fi
fi
Yes, it is pretty simple :). Update process for osquery goes perfect but last command "ossec-control restart", it is never executed and a lot of errors appears:
2021/05/06 08:47:40 wazuh-modulesd:osquery: INFO: Following osquery results file '/var/log/osquery/osqueryd.snapshots.log'.
2021/05/06 08:47:40 wazuh-modulesd:command: INFO: Starting command 'install-osquery-macos'.
2021/05/06 08:47:40 sca: INFO: Module started.
2021/05/06 08:47:40 wazuh-modulesd:control: INFO: Starting control thread.
2021/05/06 08:47:40 sca: INFO: Policy '/Library/Ossec/ruleset/sca/sca_unix_audit.yml' disabled by configuration.
2021/05/06 08:47:40 sca: INFO: Loaded policy '/Library/Ossec/etc/shared/macos_cis_yml'
2021/05/06 08:47:40 sca: INFO: Starting Security Configuration Assessment scan.
2021/05/06 08:47:40 sca: INFO: Starting evaluation of policy: '/Library/Ossec/etc/shared/macos_cis_yml'
2021/05/06 08:47:40 wazuh-modulesd:osquery: WARNING: E0506 08:47:40.885989 249183744 shutdown.cpp:69] Cannot activate filesystem logger plugin: Could not create file: /var/log/osquery/osqueryd.results.log
2021/05/06 08:47:41 wazuh-modulesd:syscollector: INFO: Starting evaluation.
2021/05/06 08:47:41 wazuh-modulesd:osquery: INFO: Results file '/var/log/osquery/osqueryd.snapshots.log' was deleted.
2021/05/06 08:47:41 wazuh-modulesd:osquery: WARNING: Results file '/var/log/osquery/osqueryd.snapshots.log' not available: No such file or directory (2). Retrying in 1 sec.
2021/05/06 08:47:42 wazuh-modulesd:osquery: WARNING: Results file '/var/log/osquery/osqueryd.snapshots.log' not available: No such file or directory (2). Retrying in 2 sec.
2021/05/06 08:47:43 wazuh-modulesd:osquery: WARNING: E0506 08:47:43.707573 170332160 shutdown.cpp:69] Worker returned exit status
2021/05/06 08:47:43 wazuh-modulesd:osquery: ERROR: Osquery exited with code 78. Closing module.
2021/05/06 08:47:44 wazuh-modulesd:osquery: INFO: Closing module.
Why? Is it possible to reload wazuh agent after osquery is updated?
Many thanks.
--
You received this message because you are subscribed to the Google Groups "Wazuh mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wazuh+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wazuh/8efbe711-abd9-46f5-8ed8-bb1f2378adb4n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wazuh/10D6D795-FE28-4896-8410-A5787F52BE88%40outlook.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wazuh/fd612a13-fd61-48d6-9522-f2543e981393n%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wazuh/ea1a506e-9278-4586-b2cc-0fff5c9478ben%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/wazuh/0B97A19F-8B05-4D4F-AA46-B824E9893525%40outlook.com.
* This message and the information contained in or attached to it are private and confidential and intended exclusively for the addressee. Any dissemination, copying or distribution to third parties without the express consent of the sender is strictly prohibited. If you have received this message in error, please delete it immediately and notify the sender. Thank you for your collaboration.
To view this discussion on the web visit https://groups.google.com/d/msgid/wazuh/31c6bc4f-c323-4c7a-8108-7cca0a5d9064n%40googlegroups.com.
<upgrade_osquery.sh.txt>