tpotce/installer/bin/check.sh

42 lines
1.1 KiB
Bash
Raw Normal View History

2015-01-27 16:46:52 +00:00
#!/bin/bash
########################################################
2015-12-08 14:47:39 +00:00
# T-Pot #
2015-01-27 16:46:52 +00:00
# Check container and services script #
# #
2016-05-12 17:26:06 +00:00
# v16.10.0 by mo, DTAG, 2016-05-12 #
2015-01-27 16:46:52 +00:00
########################################################
2015-01-30 20:40:01 +00:00
if [ -a /var/run/check.lock ];
2016-03-09 13:05:06 +00:00
then
echo "Lock exists. Exiting now."
exit
2015-01-27 16:46:52 +00:00
fi
2015-01-28 16:08:34 +00:00
myIMAGES=$(cat /data/images.conf)
2015-01-27 16:46:52 +00:00
touch /var/run/check.lock
myUPTIME=$(awk '{print int($1/60)}' /proc/uptime)
2015-01-28 16:08:34 +00:00
for i in $myIMAGES
2015-08-07 20:32:15 +00:00
do
if [ "$i" != "ui-for-docker" ] && [ "$i" != "netdata" ];
then
myCIDSTATUS=$(docker exec $i supervisorctl status)
if [ $? -ne 0 ];
then
myCIDSTATUS=1
else
myCIDSTATUS=$(echo $myCIDSTATUS | egrep -c "(STOPPED|FATAL)")
fi
if [ $myUPTIME -gt 4 ] && [ $myCIDSTATUS -gt 0 ];
then
echo "Restarting "$i"."
systemctl stop $i
sleep 5
systemctl start $i
fi
fi
2015-01-27 16:46:52 +00:00
done
2016-03-09 13:05:06 +00:00
2015-01-27 16:46:52 +00:00
rm /var/run/check.lock