From: Andrew DeFaria Date: Fri, 7 May 2021 14:03:35 +0000 (-0700) Subject: Removed announcement of reestablishment of tunnel X-Git-Url: https://defaria.com/gitweb/?a=commitdiff_plain;h=2dca9460aaac20e49c409da4f9e59c85027c3605;p=clearscm.git Removed announcement of reestablishment of tunnel --- diff --git a/bin/tunnel.pl b/bin/tunnel.pl index 9472e88..43dbfff 100755 --- a/bin/tunnel.pl +++ b/bin/tunnel.pl @@ -85,9 +85,13 @@ my %opts = ( port2 => 25, remotehost => 'defaria.com', maxretries => 3, - daemon => 1, ); +# Perlcritic complains if $DB::OUT is used only once. +no warnings; +$opts{daemon} = 1 unless defined $DB::OUT; +use warnings; + my ($log, $ssh); sub Report ($;$) { @@ -120,7 +124,7 @@ sub tunnel() { RETRY: my ($fh, $filename) = tempfile; - my $ssh = Net::OpenSSH->new( + $ssh = Net::OpenSSH->new( $opts{remotehost}, master_opts => $tunnelStr, default_stderr_file => $filename @@ -135,7 +139,7 @@ RETRY: unlink $filename; - if (grep /address already in use/i, @lines) { + if (grep { /address already in use/i } @lines) { Report 'Unable to start tunnel - Address already in use', 1; } else { my $msg = 'Ssh tunnel '; @@ -154,10 +158,6 @@ RETRY: Report("Ssh tunnel terminated unexpectedly - Maximum retry count hit ($opts{maxretries}) - giving up", 1) if $retryattempts++ >= $opts{maxretries}; - $opts{announce} = $retryattempts; - - Report 'Ssh tunnel terminated unexpectedly - Attempting restart'; - undef $ssh; goto RETRY; @@ -183,11 +183,6 @@ GetOptions ( 'append', ) || Usage; -# Turn off daemon mode if we are in the Perl debugger; -no warnings; # Ignore warning about used only once $DB::OUT when not in debugger -$opts{daemon} = 0 if defined $DB::OUT; -use warnings; - $log = Logger->new( path => '/var/local/log', name => "$Logger::me", @@ -199,11 +194,6 @@ $log->msg("$FindBin::Script v$VERSION"); $SIG{INT} = $SIG{TERM} = \&interrupt; -if ($opts{daemon}) { - # Perl complains if we reference $DB::OUT only once - no warnings; - EnterDaemonMode unless defined $DB::OUT or get_debug; - use warnings; -} # if +EnterDaemonMode unless $opts{daemon} and get_debug; tunnel;