here for change state http://www.zoneminder.com/forums/viewtopic.php?t=15321
But somme changes
After compile c program
2) Find your location (GPS or in google maps/earth)
3) Create script like this
Code: Select all
#! /bin/bash
# /root/timeup
# Author: fvillant
# Date: 2007.10.10.
# Recuperation du lever et du coucher du Soleil a Porto-Vecchio pour la date du lendemain
/root/sunrise `date -d "+1 day" "+%Y %m %d"` 41.41 -9.22
4.1) At the end ad the commande line 30 23 * * * root /root/editcron
5) Create a script /root/editcron
Code: Select all
#!/usr/bin/perl -w
#
# 28 Janvier 2010 Creation Flavien Villant
# Edition crontab pour modification sunset
# sunrise selon le jour et l'heure la la
#
#
#
#
system("/root/timeup > sun.txt");
open(FILE,"sun.txt");
@arr = <FILE>;
for $line (@arr) {
chomp $line;
# Recuperation des horaires
$sunriseH=substr($line,21,2);
$sunriseM=substr($line,24,2);
$sunsetH=substr($line,51,2);
$sunsetM=substr($line,54,2);
$sunsetrise = "# Mode Jour/Nuit Zoneminder ".$Line." NE PAS DECOMMENTER";
$jour = $sunriseM." ".$sunriseH." * * * root /root/zmday";
$nuit = $sunsetM." ".$sunsetH." * * * root /zmnight";
}
close(FILE);
open(FILE,"/etc/crontab");
my @crn = <FILE>;
close(FILE);
$crn[23] = $sunsetrise;
$crn[24] = $jour;
$crn[25] = $nuit;
open(FILE, ">/etc/crontab") || die "Erreur E/S:$!\n";
foreach my $ligne (@crn) {
chomp $ligne;
print FILE "$ligne\n";
}
system("chmod 754 /etc/crontab");
system("chmod +x /etc/crontab");
exit;
BEWARE NEVER AD LINE BEFORE THIS
Creat two files
/root/zmday
zmday code :
Code: Select all
#!/usr/bin/perl -w
#
# 20 Fevrier 2010 Creation Flavien Villant
#
#
#
#
# databse connection info ...
$username = "zmuser";
$password = "zmpass";
$database = "zm";
# @host = ("localhost");
# Insertion SQL Zones de Jour
system("mysql --user=".$username." --password=".$password." ".$database." < /root/ZonesDay.sql");
# Lancement ZM Mode State Jour
system("/usr/bin/zmpkg.pl Day");
exit;
zmnight code :
Code: Select all
#!/usr/bin/perl -w
#
# 20 Fevrier 2010 Creation Flavien Villant
#
#
#
#
# databse connection info ...
$username = "zmuser";
$password = "zmpass";
$database = "zm";
# @host = ("localhost");
# Insertion SQL Zones de Nuit
system("mysql --user=".$username." --password=".$password." ".$database." < /root/ZonesNight.sql");
# Lancement ZM Mode State Nuit
system("/usr/bin/zmpkg.pl Night");
exit;