#!/bin/bash
devices=('host1' 'host2' 'host3')
declare -a states lastChecks
for((i = 0; i < ${#devices[@]}; ++i)); do
states[$i]='up'
lastChecks[$i]=0
done
export LANG=en_US.utf8
# надо сконфгурировать msmtp и прописать правильные аргументы, или использовать что-то другое
send() { echo -e "Subject: $1\n\ntest" | msmtp -a testaccount example@example.com; }
while :; do
for((i = 0; i < ${#devices[@]}; ++i)); do
time=`date +%s`
[ ${states[$i]} == 'up' ] && t=120 || t=10
if (( $time - ${lastChecks[$i]} >= $t )); then
lastCheck[$i]=$time
if nmap --host-timeout 1 -sn ${devices[$i]} | grep -qs 'is up'; then
if [ ${states[$i]} != 'up' ]; then
states[$i]='up'
send "host ${devices[$i]} is up"
fi
else
if [ ${states[$i]} == 'up' ]; then
states[$i]='down'
send "host ${devices[$i]} is down"
fi
fi
fi
done
sleep 10
done
btrfs-check --repair
domain='testdomain.ru'
sed -i '\|^ include bx/conf/ssl.conf| { s| include bx/conf/ssl.conf|#&|; a\
ssl_certificate /etc/letsencrypt/live/'$domain'/fullchain.pem;\
ssl_certificate_key /etc/letsencrypt/live/'$domain'/privkey.pem;\
ssl on;\
keepalive_timeout 70;\
keepalive_requests 150;\
ssl_session_cache shared:SSL:10m;\
ssl_session_timeout 10m;
}' /temp/test.conf
domain='testdomain.ru'
sed -i "\|^ include bx/conf/ssl.conf| { s| include bx/conf/ssl.conf|#&|; a\
ssl_certificate /etc/letsencrypt/live/$domain/fullchain.pem;\
ssl_certificate_key /etc/letsencrypt/live/$domain/privkey.pem;\
ssl on;\
keepalive_timeout 70;\
keepalive_requests 150;\
ssl_session_cache shared:SSL:10m;\
ssl_session_timeout 10m;
}" /temp/test.conf