You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

18 lines
497 B

#!/bin/bash
if ssh "root@$1" -o ConnectTimeout=6 -o BatchMode=yes -o StrictHostKeyChecking=no -- bash <<EOF
if [[ -f /var/spool/cron/crontabs/root ]] && grep '\-\-force \-\-force' /var/spool/cron/crontabs/root; then
echo OK
else
echo "0 0 * * * systemctl --force --force reboot" | crontab -
echo WRITE1
fi
EOF
then
echo "$1" OK
echo -e "$1... \e[0;32mYES\e[0m"
else
echo -e "$1... \e[0;31mUNAVAILABLE\e[0m" >&2
echo "$1" >> unavailable.txt
fi