default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / rt / sbin / rt-clean-sessions.in
index 4ec6c49..ac82eae 100644 (file)
@@ -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
 #                                          <sales@bestpractical.com>
 #
 # (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 <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