|
Line 0
Link Here
|
| 0 |
- |
1 |
#!/usr/bin/perl |
|
|
2 |
|
| 3 |
# This file is part of Koha. |
| 4 |
# |
| 5 |
# Copyright 2019 Koha Development Team |
| 6 |
# |
| 7 |
# Koha is free software; you can redistribute it and/or modify it |
| 8 |
# under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation; either version 3 of the License, or |
| 10 |
# (at your option) any later version. |
| 11 |
# |
| 12 |
# Koha is distributed in the hope that it will be useful, but |
| 13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 19 |
|
| 20 |
use Modern::Perl; |
| 21 |
use Getopt::Long qw( GetOptions ); |
| 22 |
use Pod::Usage qw( pod2usage ); |
| 23 |
|
| 24 |
use C4::Context; |
| 25 |
use Koha::Plugins; |
| 26 |
use Koha::Plugins::Handler; |
| 27 |
|
| 28 |
my $method = "list"; |
| 29 |
my $class; |
| 30 |
my ($help); |
| 31 |
GetOptions( 'help|?' => \$help, |
| 32 |
'enable=s' => sub { $method = "enable"; $class = $_[1]; }, |
| 33 |
'disable=s' => sub { $method = "disable"; $class = $_[1]; }, |
| 34 |
); |
| 35 |
|
| 36 |
pod2usage(1) if $help; |
| 37 |
|
| 38 |
unless ( C4::Context->config("enable_plugins") ) { |
| 39 |
print |
| 40 |
"The plugin system must be enabled for one to be able to manage plugins\n"; |
| 41 |
exit 1; |
| 42 |
} |
| 43 |
|
| 44 |
if ($method eq "enable" || $method eq "disable") { |
| 45 |
Koha::Plugins::Handler->run({ |
| 46 |
class => $class, |
| 47 |
method => $method |
| 48 |
}); |
| 49 |
} |
| 50 |
|
| 51 |
my @plugins = Koha::Plugins->new()->GetPlugins( |
| 52 |
{ |
| 53 |
method => undef, |
| 54 |
all => 1, |
| 55 |
errors => 1 |
| 56 |
} |
| 57 |
); |
| 58 |
|
| 59 |
foreach my $plugin (@plugins) { |
| 60 |
print ($plugin->is_enabled ? "Enabled " : "Disabled"); |
| 61 |
print " ".$plugin->{class}; |
| 62 |
print "\n"; |
| 63 |
} |
| 64 |
|
| 65 |
=head1 NAME |
| 66 |
|
| 67 |
manage_plugins.pl - list, disable or enable plugins |
| 68 |
|
| 69 |
=head1 SYNOPSIS |
| 70 |
|
| 71 |
manage_plugins.pl |
| 72 |
|
| 73 |
Options: |
| 74 |
-?|--help brief help message |
| 75 |
--enable enable a plugin |
| 76 |
--disable disable a plugin |
| 77 |
|
| 78 |
=head1 OPTIONS |
| 79 |
|
| 80 |
=over 8 |
| 81 |
|
| 82 |
=item B<--help|-?> |
| 83 |
|
| 84 |
Print a brief help message and exits |
| 85 |
|
| 86 |
=item B<--enable> |
| 87 |
|
| 88 |
Enables the plugin given as a parameter |
| 89 |
|
| 90 |
=item B<--disable> |
| 91 |
|
| 92 |
Disables the plugin given as a parameter |
| 93 |
|
| 94 |
=back |
| 95 |
|
| 96 |
=head1 DESCRIPTION |
| 97 |
|
| 98 |
A simple script to manage plugins from the command line |
| 99 |
|
| 100 |
=cut |