*** empty log message ***

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@309 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2003-01-14 11:47:24 +00:00
parent e515a3481f
commit a50f3a5031
4 changed files with 193 additions and 9 deletions

View File

@ -78,11 +78,12 @@ bin_SCRIPTS = zmdc.pl zmaudit.pl zmfilter.pl zmx10.pl zmwatch.pl
EXTRA_DIST = $(bin_SCRIPTS)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h
CONFIG_CLEAN_FILES = zmdc.pl zmx10.pl zmaudit.pl zmfilter.pl zmwatch.pl
CONFIG_CLEAN_FILES = zmdc.pl zmx10.pl zmaudit.pl zmfilter.pl zmwatch.pl \
zmpkg.pl zm
SCRIPTS = $(bin_SCRIPTS)
DIST_COMMON = Makefile.am Makefile.in zmaudit.pl.in zmdc.pl.in \
zmfilter.pl.in zmwatch.pl.in zmx10.pl.in
DIST_COMMON = Makefile.am Makefile.in zm.in zmaudit.pl.in zmdc.pl.in \
zmfilter.pl.in zmpkg.pl.in zmwatch.pl.in zmx10.pl.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
@ -108,6 +109,10 @@ zmfilter.pl: $(top_builddir)/config.status zmfilter.pl.in
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
zmwatch.pl: $(top_builddir)/config.status zmwatch.pl.in
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
zmpkg.pl: $(top_builddir)/config.status zmpkg.pl.in
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
zm: $(top_builddir)/config.status zm.in
cd $(top_builddir) && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
install-binSCRIPTS: $(bin_SCRIPTS)
@$(NORMAL_INSTALL)

49
scripts/zm.z Executable file
View File

@ -0,0 +1,49 @@
#!/bin/sh
# description: Control ZoneMinder as a Service
# chkconfig: 2345 99 99
command="@prefix@/bin/zmpkg.pl"
case "$1" in
'start')
$command start
status=$?
if [ "$status" = "0" ]; then
touch /var/lock/subsys/zm
fi
;;
'stop')
$command stop
status=$?
if [ "$status" = "0" ]; then
rm -f /var/lock/subsys/zm
fi
;;
'restart')
$command stop
status=$?
if [ "$status" = "0" ]; then
rm -f /var/lock/subsys/zm
fi
$command start
status=$?
if [ "$status" = "0" ]; then
touch /var/lock/subsys/zm
fi
;;
'status')
result=`$command status`
if [ "$result" = "running" ]; then
echo "ZoneMinder is running"
status=0
else
echo "ZoneMinder is stopped"
status=1
fi
;;
*)
echo "Usage: $0 { start | stop | restart | status }"
status=1
;;
esac
exit $status

125
scripts/zmpkg.pl.z Executable file
View File

@ -0,0 +1,125 @@
#!/usr/bin/perl -wT
#
# ==========================================================================
#
# Zone Minder Package Control Script, $Date$, $Revision$
# Copyright (C) 2003 Philip Coombes
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ==========================================================================
#
# This script is used to start and stop the ZoneMinder package primarily to
# allow command line control for automatic restart on reboot (see zm script)
#
use strict;
# ==========================================================================
#
# These are the elements you need to edit to suit your installation
#
# ==========================================================================
use constant ZM_DB_SERVER => "<from zmconfig>";
use constant ZM_DB_NAME => "<from zmconfig>";
use constant ZM_DB_USERA => "<from zmconfig>";
use constant ZM_DB_PASSA => "<from zmconfig>";
use constant ZM_PATH_LOGS => "<from zmconfig>";
use constant ZM_OPT_FAST_DELETE => "<from zmconfig>";
use constant ZM_OPT_X10 => "<from zmconfig>";
use constant LOG_FILE => ZM_PATH_LOGS.'/zmpkg.log';
use constant COMMAND_PATH => '@prefix@/bin/';
use constant WEB_USER => '@WEB_USER@/';
use constant VERBOSE => 0; # Whether to output more verbose debug
# ==========================================================================
#
# Don't change anything below here
#
# ==========================================================================
use DBI;
# Detaint our environment
$ENV{PATH} = '/bin:/usr/bin';
$ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL};
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
my $command = $ARGV[0];
if ( !$command || $command !~ /^(?:start|stop|restart)$/ )
{
print( "Usage: zmpkg.pl <start|stop|restart>\n" );
exit( -1 );
}
my $log_file = LOG_FILE;
open( LOG, ">>$log_file" ) or die( "Can't open log file: $!" );
open( STDOUT, ">&LOG" ) || die( "Can't dup stdout: $!" );
select( STDOUT ); $| = 1;
open( STDERR, ">&LOG" ) || die( "Can't dup stderr: $!" );
select( STDERR ); $| = 1;
select( LOG ); $| = 1;
if ( $command =~ /^(?:stop|restart)$/ )
{
execute( COMMAND_PATH."/zmdc.pl shutdown" );
}
if ( $command =~ /^(?:start|restart)$/ )
{
execute( COMMAND_PATH."/zmfix" );
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_SERVER, ZM_DB_USERA, ZM_DB_PASSA );
my $sql = "select * from Monitors";
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
while( my $monitor = $sth->fetchrow_hashref() )
{
if ( $monitor->{Function} ne 'None' )
{
execute( COMMAND_PATH."/zmdc.pl start zmc -d $monitor->{Device}" );
if ( $monitor->{Function} ne 'Passive' )
{
execute( COMMAND_PATH."/zmdc.pl start zma -m $monitor->{Id}" );
}
}
execute( COMMAND_PATH."/zmdc.pl start zmfilter.pl -m $monitor->{Id} -e -1" );
}
$sth->finish();
if ( ZM_OPT_FAST_DELETE )
{
execute( COMMAND_PATH."/zmdc.pl start zmaudit.pl -d 900 -y" );
}
if ( ZM_OPT_X10 )
{
execute( COMMAND_PATH."/zmdc.pl start zmx10.pl -c start" );
}
execute( COMMAND_PATH."/zmdc.pl start zmwatch.pl" );
}
if ( $command eq "status" )
{
print( execute( COMMAND_PATH."/zmdc.pl check" ) );
}
sub execute
{
my $command = shift;
my $su_command = "su @WEB_USER@ --shell=/bin/sh --command='$command'";
print( "Executing: $su_command\n" );
return( qx( $su_command ) );
}

View File

@ -161,10 +161,15 @@ our %pending_tasks;
sub runServer
{
open( LOG, '>>'.main::X10_LOG_FILE ) or die( "Can't open log file: $!" );
select( LOG );
$| = 1;
print( LOG "X10 server starting at ".strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n" );
my $log_file = main::X10_LOG_FILE;
open( LOG, ">>$log_file" ) or die( "Can't open log file: $!" );
open( STDOUT, ">&LOG" ) || die( "Can't dup stdout: $!" );
select( STDOUT ); $| = 1;
open( STDERR, ">&LOG" ) || die( "Can't dup stderr: $!" );
select( STDERR ); $| = 1;
select( LOG ); $| = 1;
print( "X10 server starting at ".strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n" );
socket( SERVER, PF_UNIX, SOCK_STREAM, 0 ) or die( "Can't open socket: $!" );
unlink( main::X10_SOCK_FILE );
@ -346,7 +351,7 @@ sub runServer
}
}
}
print( LOG "X10 server exiting at ".strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n" );
print( "X10 server exiting at ".strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n" );
close( LOG );
close( SERVER );
exit();
@ -661,7 +666,7 @@ sub x10listen
}
}
}
print( LOG strftime( "%y/%m/%d %H:%M:%S", localtime() )." - ".$event->as_string()."\n" );
print( strftime( "%y/%m/%d %H:%M:%S", localtime() )." - ".$event->as_string()."\n" );
}
}