X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fsbin%2Frt-clean-sessions.in;h=8490f065519c97198281fd142f60741277549ea6;hp=4ec6c49ad735316957a7952d30875ad5181ad018;hb=HEAD;hpb=fc6209f398899f0211cfcedeb81a3cd65e04a941 diff --git a/rt/sbin/rt-clean-sessions.in b/rt/sbin/rt-clean-sessions.in index 4ec6c49ad..ac82eae03 100644 --- a/rt/sbin/rt-clean-sessions.in +++ b/rt/sbin/rt-clean-sessions.in @@ -3,7 +3,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2019 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -50,39 +50,31 @@ use strict; use warnings; # fix lib paths, some may be relative -BEGIN { +BEGIN { # BEGIN RT CMD BOILERPLATE require File::Spec; + require Cwd; my @libs = ("@RT_LIB_PATH@", "@LOCAL_LIB_PATH@"); my $bin_path; for my $lib (@libs) { unless ( File::Spec->file_name_is_absolute($lib) ) { - unless ($bin_path) { - if ( File::Spec->file_name_is_absolute(__FILE__) ) { - $bin_path = ( File::Spec->splitpath(__FILE__) )[1]; - } - else { - require FindBin; - no warnings "once"; - $bin_path = $FindBin::Bin; - } - } + $bin_path ||= ( File::Spec->splitpath(Cwd::abs_path(__FILE__)) )[1]; $lib = File::Spec->catfile( $bin_path, File::Spec->updir, $lib ); } unshift @INC, $lib; } + } use Getopt::Long; my %opt; -GetOptions( \%opt, "older=s", "debug", "help", "skip-user"); +GetOptions( \%opt, "older=s", "debug", "help|h", "skip-user" ); if ( $opt{help} ) { require Pod::Usage; - import Pod::Usage; - pod2usage({ -message => "RT Session cleanup tool\n", verbose => 1 }); - exit 1; + Pod::Usage::pod2usage({ verbose => 2 }); + exit; } @@ -103,9 +95,9 @@ require RT; RT::LoadConfig(); if( $opt{'debug'} ) { - RT->Config->Set( LogToScreen => 'debug' ); + RT->Config->Set( LogToSTDERR => 'debug' ); } else { - RT->Config->Set( LogToScreen => undef ); + RT->Config->Set( LogToSTDERR => undef ); } RT::ConnectToDatabase(); @@ -113,7 +105,8 @@ RT::InitLogging(); require RT::Interface::Web::Session; -if( $opt{'older'} or my $alogoff = int RT->Config->Get('AutoLogoff') ) { +my $alogoff = int RT->Config->Get('AutoLogoff'); +if ( $opt{'older'} or $alogoff ) { my $min; foreach ($alogoff*60, $opt{'older'}) { next unless $_; @@ -137,13 +130,13 @@ rt-clean-sessions - clean old and duplicate RT sessions =head1 SYNOPSIS - rt-clean-sessions [--debug] [--older [H|D|M|Y]] + rt-clean-sessions [--debug] [--older [H|D|M|Y]] - rt-clean-sessions - rt-clean-sessions --debug - rt-clean-sessions --older 10D - rt-clean-sessions --debug --older 1M - rt-clean-sessions --older 10D --skip-user + rt-clean-sessions + rt-clean-sessions --debug + rt-clean-sessions --older 10D + rt-clean-sessions --debug --older 1M + rt-clean-sessions --older 10D --skip-user =head1 DESCRIPTION