#! /bin/bash
while true;do 
nc -z -v -w5 192.168.0.1 22 #éxecute une commande netcat pour tester le port 22
if [ $? -ne 0 ]; then
python /home/user1/Desktop/LEDj3on.py
echo "port 22 $(date)" >> "/home/user1/port_failures.log"
else
python /home/user1/Desktop/LEDj3off.py
fi

nc -z -v -w5 192.168.0.1 443 #test le port 443
if [ $? -ne 0 ]; then
python /home/user1/Desktop/LEDj3on.py
echo "port 443 $(date)" >> "/home/user1/port_failures.log"
else
python /home/user1/Desktop/LEDj3off.py
fi

if [ -s /home/user1/port_failures.log ]; then
python /home/user1/Desktop/LEDr3on.py
else 
python /home/user1/Desktop/LEDr3off.py
fi

if [ -s /home/user1/port_failures.log ]; then
python /home/user1/Desktop/LEDv3off.py
else 
python /home/user1/Desktop/LEDv3on.py
fi

sleep 1
done
