I succeded at using cron for changing ZM states (monitor & modect) depending of the time... In the morning, it sets modect and if the afternoon sets monitor.
The next step i want to do, is a bash script to see if me or my Gf are present in the house to set monitor so that we dont have any fals alarm.
To do it, il'l try to use the wifi of our cellphones.
Both cellphone get their specific IP address from DHCP in my router.
i want to ping them each 15 minutes to see if we are there..
I surely suck at bash and if anybody wants to correct my script...
the pings are ok but the echo in the IF zone dont work...
When it will be working, i'll just change the echo to /usr/local/bin/zmpkg.pl STATE
Code: Select all
#!/bin/bash
#Script pour détection de proximité
((count1 = 3)) # Nombre de ping echoué max
while [[ $count1 -ne 0 ]] ; do
ping -c 1 192.168.1.21 # Premier essaie
simon=$?
if [[ $simon -eq 0 ]] ; then
((count1 = 1)) # Si ca marche, sortir sans essayer plus loin
fi
((count1 = count1 - 1)) # Diminution des essaies
done
((count2 = 3)) # Nombre de ping echoué max
while [[ $count2 -ne 0 ]] ; do
ping -c 1 192.168.1.20 # Premier essaie
sandra=$?
if [[ $sandra -eq 0 ]] ; then
((count2 = 1)) # Si ca marche, sortir sans essayer plus loin
fi
((count2 = count2 - 1)) # Diminution des essaies
done
if [[ $simon -eq 0 && $sandra -eq 0 ]] ; then # Test d'output
echo "Simon et Sandra sont la"
fi
if [[ $simon -eq 0 && $sandra -eq 2 ]] ; then # Test d'output
echo "Simon est la, Sandra est pas la"
fi
if [[ $simon -eq 2 && $sandra -eq 0 ]] ; then # Test d'output
echo "Sandra est la, Simon est pas la"
fi
if [[ $simon -eq 2 && $sandra -eq 2 ]] ; then # Test d'output
echo "Personne a la maison"
fi
Simon