#!/bin/bash

max_retries=3

for ((i=1; i<=$max_retries; i++)); do
    ping -c 1 dl.fogworks.io >/dev/null 2>&1
    ping_status=$?

    if [ $ping_status -eq 0 ]; then
        break
    fi

    if [ $i -eq $max_retries ]; then
        echo "$(date '+%Y-%m-%d %H:%M:%S') Error: Failed to resolve host dl.fogworks.io after $max_retries retries" >> /var/log/maxio_cron.log
        exit 1
    fi

    sleep 5
done

curl http://dl.fogworks.io/maxio/online/install_maxio.sh | bash -s - -u




