update description to reflect that zmupdate.pl now does all the things it will someday do. Meantion how -c works better. When in interactive mode, check once and print out the result instead of daemonising. Fix formatting osf usage

This commit is contained in:
Isaac Connor 2022-01-13 09:37:54 -05:00
parent 04bdf0ac6b
commit cb1cbed8e7
1 changed files with 29 additions and 22 deletions

View File

@ -2,7 +2,7 @@
# #
# ========================================================================== # ==========================================================================
# #
# ZoneMinder Update Script, $Date$, $Revision$ # ZoneMinder Update Script
# Copyright (C) 2001-2008 Philip Coombes # Copyright (C) 2001-2008 Philip Coombes
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
@ -31,13 +31,15 @@ zmupdate.pl -c,--check | -f,--freshen | -v<version>,--version=<version> [-u <dbu
=head1 DESCRIPTION =head1 DESCRIPTION
This script just checks what the most recent release of ZoneMinder is This script checks what the most recent release of ZoneMinder is
at the the moment. It will eventually be responsible for applying and at the the moment by downloading https://update.zoneminder.com/version.txt.
configuring upgrades etc, including on the fly upgrades. It can also apply and configure upgrades etc, including on the fly upgrades.
=head1 OPTIONS =head1 OPTIONS
-c, --check - Check for updated versions of ZoneMinder -c, --check - Check for updated versions of ZoneMinder.
If not interactive zmupdate.pl will stay running, checking every hour.
If interactive will try once, print out result and quit.
-f, --freshen - Freshen the configuration in the database. Equivalent of old zmconfig.pl -noi -f, --freshen - Freshen the configuration in the database. Equivalent of old zmconfig.pl -noi
--migrate-events - Update database structures as per USE_DEEP_STORAGE setting. --migrate-events - Update database structures as per USE_DEEP_STORAGE setting.
-v <version>, --version=<version> - Force upgrade to the current version from <version> -v <version>, --version=<version> - Force upgrade to the current version from <version>
@ -52,8 +54,6 @@ configuring upgrades etc, including on the fly upgrades.
use strict; use strict;
use bytes; use bytes;
use version; use version;
use Crypt::Eksblowfish::Bcrypt;
use Data::Entropy::Algorithms qw(rand_bits);
# ========================================================================== # ==========================================================================
# #
@ -122,9 +122,8 @@ GetOptions(
) or pod2usage(-exitstatus => -1); ) or pod2usage(-exitstatus => -1);
my $dbh = zmDbConnect(undef, { mysql_multi_statements=>1 } ); my $dbh = zmDbConnect(undef, { mysql_multi_statements=>1 } );
if ( !$dbh ) { die "Unable to connect to db\n" if !$dbh;
die "Unable to connect to db\n";
}
$Config{ZM_DB_USER} = $dbUser; $Config{ZM_DB_USER} = $dbUser;
$Config{ZM_DB_PASS} = $dbPass; $Config{ZM_DB_PASS} = $dbPass;
# we escape dbpass with single quotes so that $ in the password has no effect, but dbpass could have a ' in it. # we escape dbpass with single quotes so that $ in the password has no effect, but dbpass could have a ' in it.
@ -181,6 +180,7 @@ if ( $check && $Config{ZM_CHECK_FOR_UPDATES} ) {
Info('Got version: '.$lastVersion); Info('Got version: '.$lastVersion);
my $lv_sql = 'UPDATE Config SET Value = ? WHERE Name = \'ZM_DYN_LAST_VERSION\''; 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()); my $lv_sth = $dbh->prepare_cached($lv_sql) or die("Can't prepare '$lv_sql': ".$dbh->errstr());
my $lv_res = $lv_sth->execute($lastVersion) or die("Can't execute: ".$lv_sth->errstr()); my $lv_res = $lv_sth->execute($lastVersion) or die("Can't execute: ".$lv_sth->errstr());
@ -190,6 +190,11 @@ if ( $check && $Config{ZM_CHECK_FOR_UPDATES} ) {
my $lc_sth = $dbh->prepare_cached($lc_sql) or die("Can't prepare '$lc_sql': ".$dbh->errstr()); my $lc_sth = $dbh->prepare_cached($lc_sql) or die("Can't prepare '$lc_sql': ".$dbh->errstr());
my $lc_res = $lc_sth->execute($lastCheck) or die("Can't execute: ".$lc_sth->errstr()); my $lc_res = $lc_sth->execute($lastCheck) or die("Can't execute: ".$lc_sth->errstr());
$lc_sth->finish(); $lc_sth->finish();
if ($interactive) {
print("Hello");
print("Latest version $lastVersion, our version " . ZM_VERSION."\n");
exit(0);
}
} else { } else {
Error('Error check failed: \''.$res->status_line().'\''); Error('Error check failed: \''.$res->status_line().'\'');
} }
@ -1044,6 +1049,8 @@ sub patchDB {
} # end sub patchDB } # end sub patchDB
sub migratePasswords { sub migratePasswords {
use Crypt::Eksblowfish::Bcrypt;
use Data::Entropy::Algorithms qw(rand_bits);
print("Migratings passwords, if any...\n"); print("Migratings passwords, if any...\n");
my $sql = 'SELECT * FROM `Users`'; my $sql = 'SELECT * FROM `Users`';
my $sth = $dbh->prepare_cached($sql) or die( "Can't prepare '$sql': ".$dbh->errstr() ); my $sth = $dbh->prepare_cached($sql) or die( "Can't prepare '$sql': ".$dbh->errstr() );