timeout 30 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://localhost/centreon/api/latest/platform/versions)" != "200" ]]; do sleep 5; done'

su - www-data -s /bin/bash -c "/usr/share/centreon/bin/console cache:clear"

curl -s http://localhost/centreon/login

centreon -d -u admin -p Centreon\!2021 -a APPLYCFG -v 1
su - centreon-gorgone -s /bin/bash -c "sudo service centengine reload"

API_TOKEN=$(curl -s -d '{"security": {"credentials": {"login": "admin","password": "Centreon!2021"}}}' -H "Content-Type: application/json" -X POST http://127.0.0.1/centreon/api/latest/login | jq -r .security.token)
curl -s -d '{"check":{"is_forced":true},"resources":[{"id":26,"parent":{"id":14},"type":"service"},{"id":14,"parent":null,"type":"host"}]}' -H "X-AUTH-TOKEN:$API_TOKEN" -H "Content-Type: application/json" -X POST 'http://127.0.0.1/centreon/api/latest/monitoring/resources/check'

apt-get update
apt search centreon
apt-get clean

systemctl stop gorgoned
systemctl stop centengine
systemctl stop cbd
systemctl stop php8.1-fpm
systemctl stop apache2

rm -f /tmp/gorgone/*.ipc /var/log/centreon*/*.log /var/lib/centreon-gorgone/history.sdb
