### Copyright 1999-2025. WebPros International GmbH. All rights reserved.

# This cronjob is responsible for receiving the updates of WP-agent.
# It works as following logic:
# - WP-agent CLI is called to receive the available update version;
# - If update is found, then the URLs to the host with repositories are updated and cache is cleared for WP-agent repos;
# - If WP-agent CLI is failed (e.g. unable to communicate with update service or WP-agent is completely broken), then
# the cronjob executes wp-agent-installer script to set the default URLs to host with repositories;
# - Finally the package manager is called to install latest available version.

0 1 * * * root sleep $((1 + RANDOM \% 5))h $((1 + RANDOM \% 60))m; bash /usr/local/wp-agent/bin/wp-agent-installer.sh --self-update > /dev/null 2> /dev/null || /bin/yum -y update wp-agent > /dev/null 2> /dev/null
