1#!/usr/local/bin/perl 2# -- 3# Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ 4# -- 5# This program is free software: you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation, either version 3 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.txt. 17# -- 18 19## nofilter(TidyAll::Plugin::OTRS::Perl::BinScripts) 20use strict; 21use warnings; 22 23use File::Basename; 24use FindBin qw($RealBin); 25use lib dirname($RealBin); 26use lib dirname($RealBin) . '/Kernel/cpan-lib'; 27use lib dirname($RealBin) . '/Custom'; 28 29# to get it readable for the web server user and writable for otrs 30# group (just in case) 31 32umask 007; 33 34use Getopt::Std; 35use Kernel::System::ObjectManager; 36 37# get options 38my %Opts; 39getopt( 'qtd', \%Opts ); 40if ( $Opts{h} ) { 41 print <<EOF; 42 43Read incoming email from STDIN. 44 45Usage: 46 otrs.PostMaster.pl -q <QUEUE> -t <TRUSTED> 47 48Options: 49 [-d] - Set debug mode. 50 [-q] <QUEUE> - Preselect a target queue by name. 51 [-t] <TRUSTED> - Default is trusted, use '-t 0' to disable trusted mode. This will cause X-OTRS email headers to be ignored. 52 [-h] - Display help for this command. 53 54Help: 55DEPRECATED. This console command is deprecated, please use 'Maint::PostMaster::Read' instead. 56 57 otrs.Console.pl Maint::PostMaster::Read [--target-queue ...] [--untrusted] 58 59EOF 60 exit 1; 61} 62if ( !$Opts{d} ) { 63 $Opts{d} = 0; 64} 65if ( !defined( $Opts{t} ) ) { 66 $Opts{t} = 1; 67} 68if ( !$Opts{q} ) { 69 $Opts{q} = ''; 70} 71 72# create object manager 73local $Kernel::OM = Kernel::System::ObjectManager->new( 74 'Kernel::System::Log' => { 75 LogPrefix => 'OTRS-otrs.PostMaster.pl', 76 }, 77); 78 79# log the use of a deprecated script 80$Kernel::OM->Get('Kernel::System::Log')->Log( 81 Priority => 'error', 82 Message => "otrs.PostMaster.pl is deprecated, please use console command 'Maint::PostMaster::Read' instead.", 83); 84 85# convert arguments to console command format 86my @Params; 87 88if ( $Opts{q} ) { 89 push @Params, '--target-queue'; 90 push @Params, $Opts{q}; 91} 92if ( !$Opts{t} ) { 93 push @Params, '--untrusted'; 94} 95if ( $Opts{d} ) { 96 push @Params, '--debug'; 97} 98 99# execute console command 100my $ExitCode = $Kernel::OM->Get('Kernel::System::Console::Command::Maint::PostMaster::Read')->Execute(@Params); 101 102exit $ExitCode; 103