diff --git a/scripts/zmaudit.pl b/scripts/zmaudit.pl index 534974bf6..03354dc7f 100644 --- a/scripts/zmaudit.pl +++ b/scripts/zmaudit.pl @@ -38,7 +38,6 @@ use bytes; # # ========================================================================== -use constant LOG_FILE => ZM_PATH_LOGS.'/zmaudit.log'; use constant MIN_AGE => 300; # Minimum age when we will delete anything use constant RECOVER_TAG => "(r)"; # Tag to append to event name when recovered use constant RECOVER_TEXT => "Recovered."; # Text to append to event notes when recovered @@ -57,6 +56,7 @@ use POSIX; use Time::HiRes qw/gettimeofday/; use Getopt::Long; +use constant LOG_FILE => ZM_PATH_LOGS.'/zmaudit.log'; use constant IMAGE_PATH => ZM_PATH_WEB.'/'.ZM_DIR_IMAGES; use constant EVENT_PATH => ZM_PATH_WEB.'/'.ZM_DIR_EVENTS; @@ -222,7 +222,7 @@ if ( $report && $yes ) usage(); } -my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); +my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS ); chdir( EVENT_PATH ); if ( $delay ) # Background mode diff --git a/scripts/zmcontrol-axis-v2.pl b/scripts/zmcontrol-axis-v2.pl index f7424b5d7..aa1a0d94c 100644 --- a/scripts/zmcontrol-axis-v2.pl +++ b/scripts/zmcontrol-axis-v2.pl @@ -33,7 +33,7 @@ use strict; # # ========================================================================== -use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-axis-v2.log'; +# None # ========================================================================== @@ -41,6 +41,8 @@ use ZoneMinder; use Getopt::Long; use Device::SerialPort; +use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-axis-v2.log'; + $| = 1; $ENV{PATH} = '/bin:/usr/bin'; diff --git a/scripts/zmcontrol-kx-hcm10.pl b/scripts/zmcontrol-kx-hcm10.pl index 1622beab0..81c7f249a 100644 --- a/scripts/zmcontrol-kx-hcm10.pl +++ b/scripts/zmcontrol-kx-hcm10.pl @@ -33,7 +33,7 @@ use strict; # # ========================================================================== -use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-kx-hcm10.log'; +# None # ========================================================================== @@ -41,6 +41,8 @@ use ZoneMinder; use Getopt::Long; use Device::SerialPort; +use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-kx-hcm10.log'; + $| = 1; $ENV{PATH} = '/bin:/usr/bin'; diff --git a/scripts/zmcontrol-pelco-d.pl b/scripts/zmcontrol-pelco-d.pl index b5cabbd1f..2b26edcb4 100644 --- a/scripts/zmcontrol-pelco-d.pl +++ b/scripts/zmcontrol-pelco-d.pl @@ -33,7 +33,7 @@ use strict; # # ========================================================================== -use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-pelco-d.log'; +# None # ========================================================================== @@ -42,6 +42,8 @@ use Getopt::Long; use Device::SerialPort; use Time::HiRes qw( usleep ); +use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-pelco-d.log'; + $| = 1; $ENV{PATH} = '/bin:/usr/bin'; diff --git a/scripts/zmcontrol-pelco-p.pl b/scripts/zmcontrol-pelco-p.pl index f2173fc78..4b221a626 100644 --- a/scripts/zmcontrol-pelco-p.pl +++ b/scripts/zmcontrol-pelco-p.pl @@ -33,7 +33,7 @@ use strict; # # ========================================================================== -use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-pelco-p.log'; +# None # ========================================================================== @@ -43,6 +43,8 @@ use Getopt::Long; use Device::SerialPort; use Time::HiRes qw( usleep ); +use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-pelco-p.log'; + $| = 1; $ENV{PATH} = '/bin:/usr/bin'; diff --git a/scripts/zmcontrol-visca.pl b/scripts/zmcontrol-visca.pl index a2c176585..ff4beffec 100644 --- a/scripts/zmcontrol-visca.pl +++ b/scripts/zmcontrol-visca.pl @@ -33,7 +33,7 @@ use strict; # # ========================================================================== -use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-visca.log'; +# None # ========================================================================== @@ -41,6 +41,8 @@ use ZoneMinder; use Getopt::Long; use Device::SerialPort; +use constant LOG_FILE => ZM_PATH_LOGS.'/zmcontrol-visca.log'; + $| = 1; $ENV{PATH} = '/bin:/usr/bin'; diff --git a/scripts/zmdc.pl b/scripts/zmdc.pl index 98b06f445..7eb92f55f 100644 --- a/scripts/zmdc.pl +++ b/scripts/zmdc.pl @@ -36,8 +36,6 @@ use bytes; # # ========================================================================== -use constant DC_SOCK_FILE => ZM_PATH_SOCKS.'/zmdc.sock'; -use constant DC_LOG_FILE => ZM_PATH_LOGS.'/zmdc.log'; use constant MAX_CONNECT_DELAY => 10; use constant VERBOSE => 0; # Whether to output more verbose debug @@ -53,6 +51,9 @@ use Socket; use IO::Handle; use Data::Dumper; +use constant DC_SOCK_FILE => ZM_PATH_SOCKS.'/zmdc.sock'; +use constant DC_LOG_FILE => ZM_PATH_LOGS.'/zmdc.log'; + $| = 1; $ENV{PATH} = '/bin:/usr/bin'; diff --git a/scripts/zmfilter.pl b/scripts/zmfilter.pl index 184f20f71..79c69cd66 100644 --- a/scripts/zmfilter.pl +++ b/scripts/zmfilter.pl @@ -34,11 +34,26 @@ use bytes; # # ========================================================================== -use constant LOG_FILE => ZM_PATH_LOGS.'/zmfilter.log'; use constant START_DELAY => 5; # How long to wait before starting - use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug +# ========================================================================== +# +# You shouldn't need to change anything from here downwards +# +# ========================================================================== + +use ZoneMinder; +use DBI; +use POSIX; +use Time::HiRes qw/gettimeofday/; +use Date::Manip; +use Data::Dumper; +use Getopt::Long; + +use constant EVENT_PATH => ZM_PATH_WEB.'/'.ZM_DIR_EVENTS; +use constant LOG_FILE => ZM_PATH_LOGS.'/zmfilter.log'; + if ( ZM_OPT_UPLOAD ) { # Comment these out if you don't have them and don't want to upload @@ -88,21 +103,6 @@ if ( ZM_OPT_MESSAGE ) ( $message_subject, $message_body ) = ZM_MESSAGE_TEXT =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"/ms; } -# ========================================================================== -# -# You shouldn't need to change anything from here downwards -# -# ========================================================================== - -use ZoneMinder; -use DBI; -use POSIX; -use Time::HiRes qw/gettimeofday/; -use Date::Manip; -use Data::Dumper; -use Getopt::Long; - -use constant EVENT_PATH => ZM_PATH_WEB.'/'.ZM_DIR_EVENTS; $| = 1; diff --git a/scripts/zmpkg.pl b/scripts/zmpkg.pl index 279e01000..17bdc406e 100644 --- a/scripts/zmpkg.pl +++ b/scripts/zmpkg.pl @@ -33,7 +33,6 @@ use bytes; # # ========================================================================== -use constant LOG_FILE => ZM_PATH_LOGS.'/zmpkg.log'; use constant DBG_LEVEL => 0; # 0 is errors, warnings and info only, > 0 for debug # ========================================================================== @@ -47,6 +46,8 @@ use DBI; use POSIX; use Time::HiRes qw/gettimeofday/; +use constant LOG_FILE => ZM_PATH_LOGS.'/zmpkg.log'; + # Detaint our environment $ENV{PATH} = '/bin:/usr/bin'; $ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL}; @@ -56,7 +57,7 @@ my $command = $ARGV[0]; my $state; -my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); +my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS ); if ( !$command || $command !~ /^(?:start|stop|restart|status)$/ ) { diff --git a/scripts/zmtrack.pl b/scripts/zmtrack.pl index 79be1fac1..c5b7bbb02 100644 --- a/scripts/zmtrack.pl +++ b/scripts/zmtrack.pl @@ -33,7 +33,6 @@ use bytes; # # ========================================================================== -use constant LOG_FILE => ZM_PATH_LOGS.'/zmtrack-%s.log'; use constant SLEEP_TIME => 10000; # In microseconds use constant VERBOSE => 1; # Whether to output more verbose debug @@ -50,6 +49,8 @@ use Data::Dumper; use Getopt::Long; use Time::HiRes qw( usleep ); +use constant LOG_FILE => ZM_PATH_LOGS.'/zmtrack-%s.log'; + $| = 1; $ENV{PATH} = '/bin:/usr/bin'; diff --git a/scripts/zmtrigger.pl b/scripts/zmtrigger.pl index 768c311df..20cb59f4b 100644 --- a/scripts/zmtrigger.pl +++ b/scripts/zmtrigger.pl @@ -33,7 +33,6 @@ use bytes; # # ========================================================================== -use constant LOG_FILE => ZM_PATH_LOGS.'/zmtrigger.log'; use constant MAX_CONNECT_DELAY => 10; use constant VERBOSE => 0; # Whether to output more verbose debug @@ -65,6 +64,8 @@ use Socket; use IO::Handle; use Data::Dumper; +use constant LOG_FILE => ZM_PATH_LOGS.'/zmtrigger.log'; + $| = 1; $ENV{PATH} = '/bin:/usr/bin'; diff --git a/scripts/zmupdate.pl b/scripts/zmupdate.pl index 9285bdad2..30481fb80 100644 --- a/scripts/zmupdate.pl +++ b/scripts/zmupdate.pl @@ -34,7 +34,6 @@ use bytes; # # ========================================================================== -use constant UPDATE_LOG_FILE => ZM_PATH_LOGS.'/zmupdate.log'; use constant CHECK_INTERVAL => (1*24*60*60); # Interval between version checks use constant VERBOSE => 0; # Whether to output more verbose debug @@ -51,6 +50,7 @@ use Getopt::Long; use Data::Dumper; use constant EVENT_PATH => ZM_PATH_WEB.'/'.ZM_DIR_EVENTS; +use constant UPDATE_LOG_FILE => ZM_PATH_LOGS.'/zmupdate.log'; $| = 1; @@ -110,7 +110,7 @@ print( "Update agent starting at ".strftime( '%y/%m/%d %H:%M:%S', localtime() ). if ( $check && ZM_CHECK_FOR_UPDATES ) { - my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); + my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS ); my $curr_version = ZM_DYN_CURR_VERSION; my $last_version = ZM_DYN_LAST_VERSION; @@ -148,7 +148,7 @@ if ( $check && ZM_CHECK_FOR_UPDATES ) print( "Got version: '".$last_version."'\n" ); - my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); + my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS ); my $lv_sql = "update Config set Value = ? where Name = 'ZM_DYN_LAST_VERSION'"; my $lv_sth = $dbh->prepare_cached( $lv_sql ) or die( "Can't prepare '$lv_sql': ".$dbh->errstr() ); @@ -200,7 +200,7 @@ if ( $zone_fix ) { require DBI; - my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); + my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS ); my $sql = "select Z.*, M.Width as MonitorWidth, M.Height as MonitorHeight from Zones as Z inner join Monitors as M on Z.MonitorId = M.Id where Z.Units = 'Percent'"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); @@ -255,7 +255,7 @@ if ( $version ) if ( $response =~ /^[yY]$/ ) { - my $command = "mysqldump -h".ZM_DB_SERVER; + my $command = "mysqldump -h".ZM_DB_HOST; if ( $db_user ) { $command .= " -u".$db_user; @@ -295,7 +295,7 @@ if ( $version ) my $dbh = shift; my $version = shift; - my $command = "mysql -h".ZM_DB_SERVER; + my $command = "mysql -h".ZM_DB_HOST; if ( $db_user ) { $command .= " -u".$db_user; @@ -334,7 +334,7 @@ if ( $version ) print( "\nUpgrading database to version ".ZM_VERSION."\n" ); - my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); + my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS ); my $cascade = undef; if ( $cascade || $version eq "1.19.0" ) diff --git a/scripts/zmvideo.pl b/scripts/zmvideo.pl index c6e1adc53..6dbf4e5a7 100644 --- a/scripts/zmvideo.pl +++ b/scripts/zmvideo.pl @@ -33,7 +33,6 @@ use bytes; # # ========================================================================== -use constant LOG_FILE => ZM_PATH_LOGS.'/zmvideo.log'; use constant VERBOSE => 0; # Whether to output more verbose debug # ========================================================================== @@ -47,6 +46,8 @@ use DBI; use Data::Dumper; use Getopt::Long qw(:config no_ignore_case ); +use constant LOG_FILE => ZM_PATH_LOGS.'/zmvideo.log'; + $| = 1; $ENV{PATH} = '/bin:/usr/bin'; @@ -163,7 +164,7 @@ open( STDERR, ">&LOG" ) || die( "Can't dup stderr: $!" ); select( STDERR ); $| = 1; select( LOG ); $| = 1; -my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); +my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS ); my @filters; my $sql = "select max(F.Delta)-min(F.Delta) as FullLength, E.*, M.Name as MonitorName, M.Width as MonitorWidth, M.Height as MonitorHeight, M.Palette from Frames as F inner join Events as E on F.EventId = E.Id inner join Monitors as M on E.MonitorId = M.Id where EventId = '$event_id' group by F.EventId"; diff --git a/scripts/zmwatch.pl b/scripts/zmwatch.pl index dc28abb0a..a5565852a 100644 --- a/scripts/zmwatch.pl +++ b/scripts/zmwatch.pl @@ -34,7 +34,6 @@ use bytes; # # ========================================================================== -use constant WATCH_LOG_FILE => ZM_PATH_LOGS.'/zmwatch.log'; use constant START_DELAY => 30; # To give everything else time to start use constant VERBOSE => 0; # Whether to output more verbose debug @@ -49,6 +48,8 @@ use POSIX; use DBI; use Data::Dumper; +use constant WATCH_LOG_FILE => ZM_PATH_LOGS.'/zmwatch.log'; + $| = 1; $ENV{PATH} = '/bin:/usr/bin'; @@ -73,7 +74,7 @@ print( "Watchdog starting at ".strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n" print( "Watchdog pausing for ".START_DELAY." seconds\n" ); sleep( START_DELAY ); -my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USER, ZM_DB_PASS ); +my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS ); my $sql = "select * from Monitors"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); diff --git a/scripts/zmx10.pl b/scripts/zmx10.pl index 59a198abb..27cb23b3e 100644 --- a/scripts/zmx10.pl +++ b/scripts/zmx10.pl @@ -33,8 +33,6 @@ use bytes; # # ========================================================================== -use constant X10_SOCK_FILE => ZM_PATH_SOCKS.'/zmx10.sock'; -use constant X10_LOG_FILE => ZM_PATH_LOGS.'/zmx10.log'; use constant VERBOSE => 0; # Whether to output more verbose debug # ========================================================================== @@ -49,6 +47,9 @@ use Socket; use Getopt::Long; use Data::Dumper; +use constant X10_SOCK_FILE => ZM_PATH_SOCKS.'/zmx10.sock'; +use constant X10_LOG_FILE => ZM_PATH_LOGS.'/zmx10.log'; + $| = 1; $ENV{PATH} = '/bin:/usr/bin';