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 19use strict; 20use warnings; 21use utf8; 22 23# use ../ as lib location 24use File::Basename; 25use FindBin qw($RealBin); 26use lib dirname($RealBin); 27use lib dirname($RealBin) . '/Kernel/cpan-lib'; 28 29use Kernel::System::ObjectManager; 30 31use Getopt::Long; 32 33local $Kernel::OM = Kernel::System::ObjectManager->new( 34 'Kernel::System::Log' => { 35 LogPrefix => 'OTRS-DBUpdate-to-6.pl', 36 }, 37); 38 39# get options 40my %Options = ( 41 Help => 0, 42 NonInteractive => 0, 43 Timing => 0, 44 Verbose => 0, 45); 46Getopt::Long::GetOptions( 47 'help', \$Options{Help}, 48 'non-interactive', \$Options{NonInteractive}, 49 'cleanup-orphaned-articles', \$Options{CleanupOrphanedArticles}, 50 'timing', \$Options{Timing}, 51 'verbose', \$Options{Verbose}, 52); 53 54{ 55 if ( $Options{Help} ) { 56 print <<"EOF"; 57 58DBUpdate-to-6.pl - Upgrade script for OTRS 5 to 6 migration. 59Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ 60 61Usage: $0 62 Options are as follows: 63 --help display this help 64 --non-interactive skip interactive input and display steps to execute after script has been executed 65 --cleanup-orphaned-articles delete orphaned article data if no corresponding ticket exists anymore (can only be used with non-interactive) 66 --timing shows how much time is consumed on each task execution in the script 67 --verbose shows details on some migration steps, not just failing. 68 69EOF 70 exit 1; 71 } 72 73 # UID check 74 if ( $> == 0 ) { # $EFFECTIVE_USER_ID 75 die " 76Cannot run this program as root. 77Please run it as the 'otrs' user or with the help of su: 78 su -c \"$0\" -s /bin/bash otrs 79"; 80 } 81 82 # Allow cleanup-orphaned-articles only if also non-interactive is set. 83 if ( $Options{CleanupOrphanedArticles} && !$Options{NonInteractive} ) { 84 $Options{CleanupOrphanedArticles} = 0; 85 } 86 87 $Kernel::OM->Create('scripts::DBUpdateTo6')->Run( 88 CommandlineOptions => \%Options, 89 ); 90 91 exit 0; 92} 93 941; 95