feature/DO-638--imap_monitoring (!4)

[DO-638]

Reviewed-on: https://git.avroid.tech/DevOps/avroid_scripts/pulls/4
This commit is contained in:
Boris Shestov
2024-06-17 12:15:21 +03:00
parent f07b54ea36
commit f2225a2900
5 changed files with 93 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
#!/bin/bash
# Переменная для tmp lock-файла
LOCK_FILE="/tmp/restart_imap.lock"
# Функция для проверки блокировки
check_lock() {
if [ -f "$LOCK_FILE" ]; then
echo "$(date) Скрипт уже запущен, выход..." >> /var/log/restart_imap.log
exit 1
fi
}
# Функция для установки блокировки
set_lock() {
touch "$LOCK_FILE"
}
# Функция для удаления блокировки
remove_lock() {
rm -f "$LOCK_FILE"
}
# Основной код скрипта
check_lock
set_lock
openssl s_client -connect imap-app.avroid.tech:993 > /dev/null < /dev/null > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo "$(date) Restart imap docker container" >> /var/log/restart_imap.log
docker restart imap
fi
remove_lock