#
# COPYRIGHT:
#
-# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+# This software is Copyright (c) 1996-2015 Best Practical Solutions, LLC
# <sales@bestpractical.com>
#
# (Except where explicitly superseded by other copyright notices)
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;
}
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();
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 $_;
=head1 SYNOPSIS
- rt-clean-sessions [--debug] [--older <NUM>[H|D|M|Y]]
+ rt-clean-sessions [--debug] [--older <NUM>[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