From 6f42f1c6d8b740ad16901f4b14b93f3d93162463 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 6 Jan 2015 20:49:33 -0500 Subject: [PATCH 01/12] add version command line argument to zmc --- src/zmc.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/zmc.cpp b/src/zmc.cpp index 2d25822b4..397468140 100644 --- a/src/zmc.cpp +++ b/src/zmc.cpp @@ -45,6 +45,7 @@ void Usage() fprintf( stderr, " -f, --file : For local images, jpg file to access.\n" ); fprintf( stderr, " -m, --monitor : For sources associated with a single monitor\n" ); fprintf( stderr, " -h, --help : This screen\n" ); + fprintf( stderr, " -v, --version : Report the installed version of ZoneMinder\n" ); exit( 0 ); } @@ -71,6 +72,7 @@ int main( int argc, char *argv[] ) {"file", 1, 0, 'f'}, {"monitor", 1, 0, 'm'}, {"help", 0, 0, 'h'}, + {"version", 0, 0, 'v'}, {0, 0, 0, 0} }; @@ -78,7 +80,7 @@ int main( int argc, char *argv[] ) { int option_index = 0; - int c = getopt_long (argc, argv, "d:H:P:p:f:m:h", long_options, &option_index); + int c = getopt_long (argc, argv, "d:H:P:p:f:m:h:v", long_options, &option_index); if (c == -1) { break; @@ -108,6 +110,9 @@ int main( int argc, char *argv[] ) case '?': Usage(); break; + case 'v': + cout << ZM_VERSION << "\n"; + exit(0); default: //fprintf( stderr, "?? getopt returned character code 0%o ??\n", c ); break; From 85e51528a69755d180161eb5c37242aa65628511 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 6 Jan 2015 20:52:18 -0500 Subject: [PATCH 02/12] add version command line argument to zma --- src/zma.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/zma.cpp b/src/zma.cpp index 117ada241..cb6ddb4e8 100644 --- a/src/zma.cpp +++ b/src/zma.cpp @@ -31,6 +31,7 @@ void Usage() fprintf( stderr, "Options:\n" ); fprintf( stderr, " -m, --monitor : Specify which monitor to use\n" ); fprintf( stderr, " -h, --help : This screen\n" ); + fprintf( stderr, " -v, --version : Report the installed version of ZoneMinder\n" ); exit( 0 ); } @@ -45,6 +46,7 @@ int main( int argc, char *argv[] ) static struct option long_options[] = { {"monitor", 1, 0, 'm'}, {"help", 0, 0, 'h'}, + {"version", 0, 0, 'v'}, {0, 0, 0, 0} }; @@ -52,7 +54,7 @@ int main( int argc, char *argv[] ) { int option_index = 0; - int c = getopt_long (argc, argv, "m:h", long_options, &option_index); + int c = getopt_long (argc, argv, "m:h:v", long_options, &option_index); if (c == -1) { break; @@ -67,6 +69,9 @@ int main( int argc, char *argv[] ) case '?': Usage(); break; + case 'v': + cout << ZM_VERSION << "\n"; + exit(0); default: //fprintf( stderr, "?? getopt returned character code 0%o ??\n", c ); break; From 258c97f75f7f1565d1abb369a32cd6ed8ccc9dae Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 6 Jan 2015 20:54:49 -0500 Subject: [PATCH 03/12] add version command line argument to zmf --- src/zmf.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/zmf.cpp b/src/zmf.cpp index 663e57076..d97a9e5d5 100644 --- a/src/zmf.cpp +++ b/src/zmf.cpp @@ -99,6 +99,7 @@ void Usage() fprintf( stderr, "Options:\n" ); fprintf( stderr, " -m, --monitor : Specify which monitor to use\n" ); fprintf( stderr, " -h, --help : This screen\n" ); + fprintf( stderr, " -v, --version : Report the installed version of ZoneMinder\n" ); exit( 0 ); } @@ -113,6 +114,7 @@ int main( int argc, char *argv[] ) static struct option long_options[] = { {"monitor", 1, 0, 'm'}, {"help", 0, 0, 'h'}, + {"version", 0, 0, 'v'}, {0, 0, 0, 0} }; @@ -120,7 +122,7 @@ int main( int argc, char *argv[] ) { int option_index = 0; - int c = getopt_long (argc, argv, "m:h", long_options, &option_index); + int c = getopt_long (argc, argv, "m:h:v", long_options, &option_index); if (c == -1) { break; @@ -135,6 +137,9 @@ int main( int argc, char *argv[] ) case '?': Usage(); break; + case 'v': + cout << ZM_VERSION << "\n"; + exit(0); default: //fprintf( stderr, "?? getopt returned character code 0%o ??\n", c ); break; From 1adb1478998e3a69c176a612cbd052a4392ddfee Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 6 Jan 2015 20:59:03 -0500 Subject: [PATCH 04/12] add version command line argument to zmstreamer. Also add -h for consistency with other programs --- src/zmstreamer.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/zmstreamer.cpp b/src/zmstreamer.cpp index 873d2fcd5..5c11cfbea 100644 --- a/src/zmstreamer.cpp +++ b/src/zmstreamer.cpp @@ -33,7 +33,7 @@ #include "zm_stream.h" // Possible command-line options -#define OPTIONS "e:o:u:f:s:b:m:d:i:?" +#define OPTIONS "e:o:u:f:s:b:m:d:i:?:h:v" // Default ZMS values #define ZMS_DEFAULT_DEBUG 0 @@ -87,6 +87,7 @@ int main(int argc, char** argv) { case 'd': debug = atoi(optarg); break; + case 'h': case 'i': case '?': printf("-e : Specify output mode: mpeg/jpg/zip/single/raw. Default = %s\n", ZMS_DEFAULT_MODE); @@ -97,8 +98,12 @@ int main(int argc, char** argv) { printf("-b : Specify bitrate. Default = %d\n", ZMS_DEFAULT_BITRATE); printf("-m : Specify monitor id. Default = %d\n", ZMS_DEFAULT_ID); printf("-d : 0 = off, 1 = no streaming, 2 = with streaming. Default = 0\n"); - printf("-i or -? : This information\n"); + printf("-i or -? or -h: This information\n"); + printf("-v : This installed version of ZoneMinder\n"); return EXIT_SUCCESS; + case 'v': + cout << ZM_VERSION << "\n"; + exit(0); } } From 71c94475ff7eddae2179f0af8afb966bd2d5db23 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 6 Jan 2015 21:08:41 -0500 Subject: [PATCH 05/12] Add -v --version command line parameters to zmaudit.pl --- scripts/zmaudit.pl.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/zmaudit.pl.in b/scripts/zmaudit.pl.in index b3dab1004..ce01b0782 100644 --- a/scripts/zmaudit.pl.in +++ b/scripts/zmaudit.pl.in @@ -69,6 +69,7 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; my $report = 0; my $interactive = 0; my $continuous = 0; +my $version; sub usage { @@ -78,6 +79,7 @@ Parameters are :- -r, --report - Just report don't actually do anything -i, --interactive - Ask before applying any changes -c, --continuous - Run continuously +-v, --version - Print the installed version of ZoneMinder "); exit( -1 ); } @@ -89,14 +91,18 @@ sub deleteSwapImage(); logInit(); logSetSignal(); -if ( !GetOptions( 'report'=>\$report, 'interactive'=>\$interactive, 'continuous'=>\$continuous ) ) +if ( !GetOptions( report=>\$report, interactive=>\$interactive, continuous=>\$continuous, version=>\$version ) ) { usage(); } +if ( $version ) { + print( ZoneMinder::Base::ZM_VERSION . "\n"); + exit(0); +} if ( ($report + $interactive + $continuous) > 1 ) { - print( STDERR "Error, only option may be specified\n" ); + print( STDERR "Error, only one option may be specified\n" ); usage(); } From 76d0dfa47556a475107c10d5d4b987d879c787ba Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 7 Jan 2015 08:43:51 -0500 Subject: [PATCH 06/12] Add -v --version command line param to zmcamtool.pl --- scripts/zmcamtool.pl.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/zmcamtool.pl.in b/scripts/zmcamtool.pl.in index 6efd5deb0..cb4e036a9 100644 --- a/scripts/zmcamtool.pl.in +++ b/scripts/zmcamtool.pl.in @@ -55,15 +55,20 @@ my $noregex = 0; my $sqlfile = ''; my $dbUser = $Config{ZM_DB_USER}; my $dbPass = $Config{ZM_DB_PASS}; +my $version = 0; # Process commandline parameters with getopt long -if ( !GetOptions( 'export'=>\$export, 'import'=>\$import, 'overwrite'=>\$overwrite, 'help'=>\$help, 'topreset'=>\$topreset, 'noregex'=>\$noregex, 'user:s'=>\$dbUser, 'pass:s'=>\$dbPass ) ) { +if ( !GetOptions( 'export'=>\$export, 'import'=>\$import, 'overwrite'=>\$overwrite, 'help'=>\$help, 'topreset'=>\$topreset, 'noregex'=>\$noregex, 'user:s'=>\$dbUser, 'pass:s'=>\$dbPass, 'version'=>\$version ) ) { Usage(); } $Config{ZM_DB_USER} = $dbUser; $Config{ZM_DB_PASS} = $dbPass; +if ( $version ) { + print( ZoneMinder::Base::ZM_VERSION . "\n"); + exit(0); +} # Check to make sure commandline params make sense if ( ((!$help) && ($import + $export + $topreset) != 1 )) { print( STDERR qq/Please give only one of the following: "import", "export", or "topreset".\n/ ); From 94e0ec542a9346e8c227bcc531cded6d824c0f8a Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 7 Jan 2015 08:47:32 -0500 Subject: [PATCH 07/12] Add -v --version command line param to zmdc.pl --- scripts/zmdc.pl.in | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/zmdc.pl.in b/scripts/zmdc.pl.in index 23cd02a2e..c209ae63f 100644 --- a/scripts/zmdc.pl.in +++ b/scripts/zmdc.pl.in @@ -78,7 +78,7 @@ sub Usage Usage: zmdc.pl [daemon [options]] Parameters are :- - One of 'startup|shutdown|status|check|logrot' or - 'start|stop|restart|reload'. + 'start|stop|restart|reload|version'. [daemon [options]] - Daemon name and options, required for second group of commands "); exit( -1 ); @@ -90,7 +90,11 @@ if( !$command ) print( STDERR "No command given\n" ); Usage(); } -my $needs_daemon = $command !~ /(?:startup|shutdown|status|check|logrot)/; +if ( $command eq 'version' ) { + print ZoneMinder::Base::ZM_VERSION."\n"; + exit( 0 ); +} +my $needs_daemon = $command !~ /(?:startup|shutdown|status|check|logrot|version)/; my $daemon = shift( @ARGV ); if( $needs_daemon && !$daemon ) { From 8ea01e631b5fe079cc75bb74b62464a0f78b116a Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 7 Jan 2015 09:00:46 -0500 Subject: [PATCH 08/12] Add -v --version command line param to zmfilter.pl --- scripts/zmfilter.pl.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/zmfilter.pl.in b/scripts/zmfilter.pl.in index ca380e539..ac5d7b6e0 100755 --- a/scripts/zmfilter.pl.in +++ b/scripts/zmfilter.pl.in @@ -115,11 +115,12 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; my $delay = $Config{ZM_FILTER_EXECUTE_INTERVAL}; my $event_id = 0; my $filter_parm = ""; +my $version = 0; sub Usage { print( " -Usage: zmfilter.pl [-f ,--filter=] +Usage: zmfilter.pl [-f ,--filter=] | -v, --version Parameters are :- -f, --filter= - The name of a specific filter to run "); @@ -158,10 +159,14 @@ sub DateTimeToSQL return( strftime( "%Y-%m-%d %H:%M:%S", localtime( $dt_val ) ) ); } -if ( !GetOptions( 'filter=s'=>\$filter_parm ) ) +if ( !GetOptions( 'filter=s'=>\$filter_parm, version=>\$version ) ) { Usage(); } +if ( $version ) { + print ZoneMinder::Base::ZM_VERSION . "\n"; + exit(0); +} if ( ! EVENT_PATH ) { Error( "No event path defined. Config was $Config{ZM_DIR_EVENTS}\n" ); From 3013d8778332936e0500290e4f1f5c8e3de51066 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 7 Jan 2015 09:05:16 -0500 Subject: [PATCH 09/12] Add -v --version command line param to zmpkg.pl --- scripts/zmpkg.pl.in | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/zmpkg.pl.in b/scripts/zmpkg.pl.in index cdbca5dba..084747bad 100644 --- a/scripts/zmpkg.pl.in +++ b/scripts/zmpkg.pl.in @@ -47,15 +47,20 @@ delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; logInit(); my $command = $ARGV[0]; +if ( $command eq 'version' ) { + print ZoneMinder::Base::ZM_VERSION . "\n"; + exit(0); +} my $state; -my $dbh = zmDbConnect(); +my $dbh; -if ( !$command || $command !~ /^(?:start|stop|restart|status|logrot)$/ ) +if ( !$command || $command !~ /^(?:start|stop|restart|status|logrot|version)$/ ) { if ( $command ) { + $dbh = zmDbConnect(); # Check to see if it's a valid run state my $sql = 'select * from States where Name = ?'; my $sth = $dbh->prepare_cached( $sql ) or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); @@ -78,10 +83,11 @@ if ( !$command || $command !~ /^(?:start|stop|restart|status|logrot)$/ ) } if ( !$command ) { - print( "Usage: zmpkg.pl \n" ); + print( "Usage: zmpkg.pl \n" ); exit( -1 ); } } +$dbh = zmDbConnect() if ! $dbh; # Move to the right place chdir( $Config{ZM_PATH_WEB} ) or Fatal( "Can't chdir to '".$Config{ZM_PATH_WEB}."': $!" ); From 5b79139a05c86d7e78a2a2c2f8c0a813572de9e3 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 7 Jan 2015 09:07:40 -0500 Subject: [PATCH 10/12] Add version to the usage line in zmsystemctl.pl --- scripts/zmsystemctl.pl.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/zmsystemctl.pl.in b/scripts/zmsystemctl.pl.in index cb3eb74ee..450fc2189 100644 --- a/scripts/zmsystemctl.pl.in +++ b/scripts/zmsystemctl.pl.in @@ -35,10 +35,10 @@ use ZoneMinder::Logger qw(:all); my $command = $ARGV[0]; -if ( (scalar(@ARGV) == 1) && ($command =~ /^(start|stop|restart)$/ )) { +if ( (scalar(@ARGV) == 1) && ($command =~ /^(start|stop|restart|version)$/ )) { $command = $1; } else { - die(" USAGE: zmsystemctl.pl \n"); + die(" USAGE: zmsystemctl.pl \n"); } my $path = qx(which systemctl); From 7f934e0e6943b3730e251960a23462d376a16003 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 7 Jan 2015 09:11:07 -0500 Subject: [PATCH 11/12] Add version to the usage line in zmvideo.pl --- scripts/zmvideo.pl.in | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/zmvideo.pl.in b/scripts/zmvideo.pl.in index 46cf83998..2b6765420 100644 --- a/scripts/zmvideo.pl.in +++ b/scripts/zmvideo.pl.in @@ -55,6 +55,7 @@ my $scale = ''; my $fps = ''; my $size = ''; my $overwrite = 0; +my $version = 0; my @formats = split( /\s+/, $Config{ZM_FFMPEG_FORMATS} ); for ( my $i = 0; $i < @formats; $i++ ) @@ -77,15 +78,21 @@ Parameters are :- -F, --fps= - Absolute frame rate, in frames per second -S, --size= - Absolute video size, WxH or other specification supported by ffmpeg -o, --overwrite - Whether to overwrite an existing file, off by default. +-v, --version - Outputs the currently installed version of ZoneMinder "); exit( -1 ); } -if ( !GetOptions( 'event=i'=>\$event_id, 'format|f=s'=>\$format, 'rate|r=f'=>\$rate, 'scale|s=f'=>\$scale, 'fps|F=f'=>\$fps, 'size|S=s'=>\$size, 'overwrite'=>\$overwrite ) ) +if ( !GetOptions( 'event=i'=>\$event_id, 'format|f=s'=>\$format, 'rate|r=f'=>\$rate, 'scale|s=f'=>\$scale, 'fps|F=f'=>\$fps, 'size|S=s'=>\$size, 'overwrite'=>\$overwrite, version=>\$version ) ) { Usage(); } +if ( $version ) { + print ZoneMinder::Base::ZM_VERSION . "\n"; + exit(0); +} + if ( !$event_id || $event_id < 0 ) { print( STDERR "Please give a valid event id\n" ); From a10f2aa31ca83fec2349ab86942e74c535943edc Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 7 Jan 2015 09:14:00 -0500 Subject: [PATCH 12/12] Add version to the usage line in zmx10.pl --- scripts/zmx10.pl.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/zmx10.pl.in b/scripts/zmx10.pl.in index f661e656f..add59034d 100644 --- a/scripts/zmx10.pl.in +++ b/scripts/zmx10.pl.in @@ -63,6 +63,7 @@ Usage: zmx10.pl -c ,--command= [-u ,--unit-code=, --command= - Command to issue, one of 'on','off','dim','bright','status','shutdown' -u , --unit-code= - Unit code to act on required for all commands except 'status' (optional) and 'shutdown' +-v, --verison - Pirnts the currently installed version of ZoneMinder "); exit( -1 ); } @@ -72,11 +73,16 @@ logSetSignal(); my $command; my $unit_code; +my $version; -if ( !GetOptions( 'command=s'=>\$command, 'unit-code=i'=>\$unit_code ) ) +if ( !GetOptions( 'command=s'=>\$command, 'unit-code=i'=>\$unit_code, version=>\$version ) ) { Usage(); } +if ( $version ) { + print ZoneMinder::Base::ZM_VERSION; + exit(0); +} die( "No command given" ) unless( $command ); die( "No unit code given" ) unless( $unit_code || ($command =~ /(?:start|status|shutdown)/) );