ansible-ipa-management/files/root/cron/ipa
2024-01-22 22:29:18 -07:00

29 lines
796 B
Bash

#!/bin/bash
PATH=/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
# IPA should be running. If a service is broken or down, status
# will report at least 3
ipactl status > /dev/null 2>&1
ret_val=$?
if [ "$ret_val" -ne 0 ]; then
echo "IPA SERVER IS NOT UP"
exit 20
fi
# clean up first
if [ -d /var/lib/ipa/backup ]; then
touch /var/lib/ipa/backup
find /var/lib/ipa/backup -type d -name "ipa-full*" -mtime +14 -exec rm -rf {} +
fi
ipa-backup > /dev/null 2>&1
backup_val=$?
FROM="FreeIPA Server Node $(hostname -s) <identitymanagement@rockylinux.org>"
if [ "$backup_val" -ne 0 ]; then
echo "IPA Backup Failed on $(hostname)" | mutt -e "set from=\"$FROM\"" \
-e 'set envelope_from=yes' \
-s "IPA Backup Failed" \
infrastructure@rockylinux.org
fi