Bug 247 - More refinements.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1788 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2006-01-12 15:38:24 +00:00
parent 954922707f
commit 0554f3c07b
1 changed files with 9 additions and 10 deletions

View File

@ -68,7 +68,7 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
my $report = 0; my $report = 0;
my $interactive = 0; my $interactive = 0;
my $has_term = 0; my $continuous = 0;
sub usage sub usage
{ {
@ -77,6 +77,7 @@ Usage: zmaudit.pl [-r,-report|-i,-interactive]
Parameters are :- Parameters are :-
-r, --report - Just report don't actually do anything -r, --report - Just report don't actually do anything
-i, --interactive - Ask before applying any changes -i, --interactive - Ask before applying any changes
-c, --continuous - Run continuously
"); ");
exit( -1 ); exit( -1 );
} }
@ -84,7 +85,7 @@ Parameters are :-
sub aud_print sub aud_print
{ {
my $string = shift; my $string = shift;
if ( $has_term ) if ( !$continuous )
{ {
print( $string ); print( $string );
} }
@ -121,7 +122,7 @@ sub confirm
} }
else else
{ {
if ( $has_term ) if ( !$continuous )
{ {
print( ", $action\n" ); print( ", $action\n" );
} }
@ -136,19 +137,17 @@ sub confirm
zmDbgInit( DBG_ID, level=>DBG_LEVEL ); zmDbgInit( DBG_ID, level=>DBG_LEVEL );
if ( !GetOptions( 'report'=>\$report, 'interactive'=>\$interactive ) ) if ( !GetOptions( 'report'=>\$report, 'interactive'=>\$interactive, 'continuous'=>\$continuous ) )
{ {
usage(); usage();
} }
if ( $report && $interactive ) if ( ($report + $interactive + $continuous) > 1 )
{ {
print( STDERR "Error, only one of --report and --interactive may be specified\n" ); print( STDERR "Error, only option may be specified\n" );
usage(); usage();
} }
$has_term = ($report || $interactive || -t STDOUT);
my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, 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 ); chdir( EVENT_PATH );
@ -324,5 +323,5 @@ do
unlink( split( ";", $untainted_old_files ) ); unlink( split( ";", $untainted_old_files ) );
} }
sleep( ZM_AUDIT_CHECK_INTERVAL ) if ( !$has_term ); sleep( ZM_AUDIT_CHECK_INTERVAL ) if ( $continuous );
} while( !$has_term ); } while( $continuous );