This script checks if specified disks are mounted and restarts Docker containers accordingly. It sends notifications to a Telegram channel for status updates.
Edit the _input_folder_containers.txt
file to specify the disk paths and associated Docker container names:
/mnt/folder1 container_name_1 container_name_2 container_name_3
/mnt/folder2 container_name_4
Create an env_vars.env file and set the following environment variables:
# Telegram bot token and chat ID
TELEGRAM_BOT_TOKEN="<YOUR-BOT-TOKEN-HERE>"
TELEGRAM_CHAT_ID="<YOUR-CHAT-ID-HERE>"
# Path to input file
CONFIG_FILE="/path/to/_input_folder_containers.txt"
Check if the path to the env_vars.env file is correctly set in the checker.sh script:
#!/bin/bash
# Source the environment variables.
source /path/to/env_vars.env # CHANGE with your custom path
# ... rest of the script ...
Give execution permissions to the checker.sh script:
chmod +x checker.sh
Configure the cron job for the root user:
sudo crontab -u root -e
Add the following line to run the script every 5 minutes:
*/5 * * * * /absolute/path/to/checker.sh
Replace /absolute/path/to/checker.sh with the actual path to your checker.sh script.
The script will automatically check the specified disks, mount them if necessary, and restart the associated Docker containers. Telegram notifications will be sent for status updates.
This project is licensed under the Apache License 2.0.