Add Socket Support to zmupdate (#1867)

* Update zmupdate.pl.in

* Fix spacing

* Update zmupdate.pl.in
This commit is contained in:
Joshua Ruehlig 2017-05-17 08:31:13 -07:00 committed by Isaac Connor
parent 200f92b1ad
commit 3e35fc24a3
1 changed files with 33 additions and 6 deletions

View File

@ -410,10 +410,23 @@ if ( $version )
if ( $response =~ /^[yY]$/ ) if ( $response =~ /^[yY]$/ )
{ {
my ( $host, $port ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ ); my ( $host, $portOrSocket ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
my $command = "mysqldump"; my $command = "mysqldump";
$command .= " -h".$host if defined($host); if ( defined($portOrSocket) )
$command .= " -P".$port if defined($port); {
if ( $portOrSocket =~ /^\// )
{
$command .= " -S".$portOrSocket;
}
else
{
$command .= " -h".$host." -P".$portOrSocket;
}
}
else
{
$command .= " -h".$host;
}
if ( $dbUser ) if ( $dbUser )
{ {
$command .= ' -u'.$dbUser; $command .= ' -u'.$dbUser;
@ -449,9 +462,23 @@ if ( $version )
my $dbh = shift; my $dbh = shift;
my $version = shift; my $version = shift;
my ( $host, $port ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ ); my ( $host, $portOrSocket ) = ( $Config{ZM_DB_HOST} =~ /^([^:]+)(?::(.+))?$/ );
my $command = "mysql -h".$host; my $command = "mysql";
$command .= " -P".$port if defined($port); if ( defined($portOrSocket) )
{
if ( $portOrSocket =~ /^\// )
{
$command .= " -S".$portOrSocket;
}
else
{
$command .= " -h".$host." -P".$portOrSocket;
}
}
else
{
$command .= " -h".$host;
}
if ( $dbUser ) if ( $dbUser )
{ {
$command .= " -u".$dbUser; $command .= " -u".$dbUser;