X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=rt%2Fsbin%2Frt-email-dashboards.in;h=e828002e8b92cf3c19213aaac591649bb4a51994;hp=aa5ce649fa7db527c4b52224da33ee55368467a9;hb=681a340f6be4184b1472a8e1fa9cd5d074f6f325;hpb=a6fe07e49e3fc12169e801b1ed6874c3a5bd8500 diff --git a/rt/sbin/rt-email-dashboards.in b/rt/sbin/rt-email-dashboards.in index aa5ce649f..e828002e8 100644 --- a/rt/sbin/rt-email-dashboards.in +++ b/rt/sbin/rt-email-dashboards.in @@ -3,7 +3,7 @@ # # COPYRIGHT: # -# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +# This software is Copyright (c) 1996-2016 Best Practical Solutions, LLC # # # (Except where explicitly superseded by other copyright notices) @@ -50,23 +50,15 @@ 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; @@ -78,7 +70,7 @@ BEGIN { my %opts; use Getopt::Long; GetOptions( \%opts, - "help|h", "dryrun", "time=i", "epoch=i", "all" + "help|h", "dryrun", "time=i", "epoch=i", "all", "log=s" ); if ($opts{'help'}) { @@ -89,14 +81,14 @@ if ($opts{'help'}) { require RT; require RT::Interface::CLI; -RT::Interface::CLI->import(qw{ CleanEnv loc }); - -# Clean out all the nasties from the environment -CleanEnv(); +RT::Interface::CLI->import(qw{ loc }); # Load the config file RT::LoadConfig(); +# adjust logging to the screen according to options +RT->Config->Set( LogToSTDERR => $opts{log} ) if $opts{log}; + # Connect to the database and get RT::SystemUser and RT::Nobody loaded RT::Init(); @@ -130,7 +122,7 @@ are taken to be in the user's timezone if available, UTC otherwise. You'll need to have cron run this script every hour. Here's an example crontab entry to do this. - 0 * * * * @PERL@ /opt/rt4/local/sbin/rt-email-dashboards + 0 * * * * @RT_SBIN_PATH_R@/rt-email-dashboards This will run the script every hour on the hour. This may need some further tweaking to be run as the correct user. @@ -167,6 +159,10 @@ Back-compat for --time SECONDS. Ignore subscription frequency when considering each dashboard (should only be used with --dryrun for testing and debugging) +=item --log LEVEL + +Adjust LogToSTDERR config option + =back =cut