Bugzilla – Attachment 146567 Details for
Bug 32791
Log4perl configuration files need a tool for updating on package upgrade
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32791: [Alternative] Use "ucf" to manage log4perl.conf
Bug-32791-Alternative-Use-ucf-to-manage-log4perlco.patch (text/plain), 16.72 KB, created by
David Cook
on 2023-02-13 01:48:07 UTC
(
hide
)
Description:
Bug 32791: [Alternative] Use "ucf" to manage log4perl.conf
Filename:
MIME Type:
Creator:
David Cook
Created:
2023-02-13 01:48:07 UTC
Size:
16.72 KB
patch
obsolete
>From 585db3c1d78f5e0f5c4acbcce6b6367eaef67f61 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >Date: Mon, 13 Feb 2023 01:47:08 +0000 >Subject: [PATCH] Bug 32791: [Alternative] Use "ucf" to manage log4perl.conf > >Test plan: >0. Apply patch >1a. ln -s /kohadevbox/koha/debian/scripts/koha-config /usr/sbin/koha-config >1b. koha-config --create-log4perl kohadev >1c. Note that the output looks like a correct log4perl.conf configuration >2. cp debian/koha-common.postinst /var/lib/dpkg/info/koha-common.postinst >3. vi /var/lib/ucf/hashfile >4. Change the first character in the hash for >/etc/koha/sites/kohadev/log4perl.conf to a different letter/number >5. vi /var/lib/ucf/cache/\:etc\:koha\:sites\:kohadev\:log4perl.conf >6. Add a comment to the bottom of the file like "#OLD" >7. vi /etc/koha/sites/kohadev/log4perl.conf >8. Add a commen to the bottom of the file like "#LOCAL" >9. dpkg-reconfigure koha-common >10. Play with the options - especially options 1 and 2 that >install the package version or retain the local version > >11. ucfq --verbose /etc/koha/sites/kohadev/log4perl.conf >12. Note output like the following: >Configuration file Package Exists Changed >/etc/koha/sites/kohadev/log4perl.conf koha-common Yes Yes > >NOTE: We need to think about "ucf" and "ucfr" commands for removing Koha instances, >and removing/purging the Koha package >--- > debian/koha-common.install | 1 + > debian/koha-common.postinst | 134 ++++-------------------------------- > debian/koha-core.install | 1 + > debian/koha-core.postinst | 134 ++++-------------------------------- > debian/scripts/koha-config | 93 +++++++++++++++++++++++++ > 5 files changed, 121 insertions(+), 242 deletions(-) > create mode 100755 debian/scripts/koha-config > >diff --git a/debian/koha-common.install b/debian/koha-common.install >index 2f5c793d11..4ea7f3cc47 100644 >--- a/debian/koha-common.install >+++ b/debian/koha-common.install >@@ -7,6 +7,7 @@ debian/unavailable.html usr/share/koha/intranet/htdocs > debian/unavailable.html usr/share/koha/opac/htdocs > debian/templates/* etc/koha > debian/scripts/koha-functions.sh usr/share/koha/bin >+debian/scripts/koha-config usr/sbin > debian/scripts/koha-create usr/sbin > debian/scripts/koha-create-dirs usr/sbin > debian/scripts/koha-disable usr/sbin >diff --git a/debian/koha-common.postinst b/debian/koha-common.postinst >index 57e26c958c..44eee3f3e8 100644 >--- a/debian/koha-common.postinst >+++ b/debian/koha-common.postinst >@@ -131,127 +131,6 @@ EOF > fi > fi > >-log4perl_component() >-{ >- local config=$1 >- local component=$2 >- >- if grep -q "log4perl.logger.$component" $config; then >- return 0 >- else >- return 1 >- fi >-} >- >-# Take care of the instance's log4perl.conf file >-for site in $(koha-list); do >- log4perl_config="/etc/koha/sites/$site/log4perl.conf" >- if ! log4perl_component $log4perl_config "z3950"; then >- cat <<EOF >> $log4perl_config >-log4perl.logger.z3950 = WARN, Z3950 >-log4perl.appender.Z3950=Log::Log4perl::Appender::File >-log4perl.appender.Z3950.filename=/var/log/koha/$site/z3950-error.log >-log4perl.appender.Z3950.mode=append >-log4perl.appender.Z3950.layout=PatternLayout >-log4perl.appender.Z3950.layout.ConversionPattern=[%d] [%p] %m %l%n >-log4perl.appender.Z3950.utf8=1 >- >-EOF >- fi >- >- if ! log4perl_component $log4perl_config "api"; then >- cat <<EOF >> $log4perl_config >-log4perl.logger.api = WARN, API >-log4perl.appender.API=Log::Log4perl::Appender::File >-log4perl.appender.API.filename=/var/log/koha/$site/api-error.log >-log4perl.appender.API.mode=append >-log4perl.appender.API.layout=PatternLayout >-log4perl.appender.API.layout.ConversionPattern=[%d] [%p] %m %l%n >-log4perl.appender.API.utf8=1 >- >-EOF >- fi >-done >- >-for site in $(koha-list); do >- log4perl_config="/etc/koha/sites/$site/log4perl.conf" >- if ! log4perl_component $log4perl_config "sip"; then >- cat <<EOF >> $log4perl_config >-log4perl.logger.sip = DEBUG, SIP >-log4perl.appender.SIP=Log::Log4perl::Appender::File >-log4perl.appender.SIP.filename=/var/log/koha/$site/sip.log >-log4perl.appender.SIP.mode=append >-log4perl.appender.SIP.layout=PatternLayout >-log4perl.appender.SIP.layout.ConversionPattern=[%d] [%P] [%p] %X{accountid}@%X{peeraddr}: %m %l%n >-log4perl.appender.SIP.utf8=1 >- >-EOF >- fi >-done >- >-for site in $(koha-list); do >- log4perl_config="/etc/koha/sites/$site/log4perl.conf" >- if ! log4perl_component $log4perl_config "plack-opac"; then >- cat <<EOF >> $log4perl_config >-log4perl.logger.plack-opac = WARN, PLACKOPAC >-log4perl.appender.PLACKOPAC=Log::Log4perl::Appender::File >-log4perl.appender.PLACKOPAC.filename=/var/log/koha/$site/plack-opac-error.log >-log4perl.appender.PLACKOPAC.mode=append >-log4perl.appender.PLACKOPAC.layout=PatternLayout >-log4perl.appender.PLACKOPAC.layout.ConversionPattern=[%d] [%p] %m%n >-log4perl.appender.PLACKOPAC.utf8=1 >- >-EOF >- fi >-done >- >-for site in $(koha-list); do >- log4perl_config="/etc/koha/sites/$site/log4perl.conf" >- if ! log4perl_component $log4perl_config "plack-api"; then >- cat <<EOF >> $log4perl_config >-log4perl.logger.plack-api = WARN, PLACKAPI >-log4perl.appender.PLACKAPI=Log::Log4perl::Appender::File >-log4perl.appender.PLACKAPI.filename=/var/log/koha/$site/plack-api-error.log >-log4perl.appender.PLACKAPI.mode=append >-log4perl.appender.PLACKAPI.layout=PatternLayout >-log4perl.appender.PLACKAPI.layout.ConversionPattern=[%d] [%p] %m%n >-log4perl.appender.PLACKAPI.utf8=1 >- >-EOF >- fi >-done >- >-for site in $(koha-list); do >- log4perl_config="/etc/koha/sites/$site/log4perl.conf" >- if ! log4perl_component $log4perl_config "plack-intranet"; then >- cat <<EOF >> $log4perl_config >-log4perl.logger.plack-intranet = WARN, PLACKINTRANET >-log4perl.appender.PLACKINTRANET=Log::Log4perl::Appender::File >-log4perl.appender.PLACKINTRANET.filename=/var/log/koha/$site/plack-intranet-error.log >-log4perl.appender.PLACKINTRANET.mode=append >-log4perl.appender.PLACKINTRANET.layout=PatternLayout >-log4perl.appender.PLACKINTRANET.layout.ConversionPattern=[%d] [%p] %m%n >-log4perl.appender.PLACKINTRANET.utf8=1 >- >-EOF >- fi >-done >- >-for site in $(koha-list); do >- log4perl_config="/etc/koha/sites/$site/log4perl.conf" >- if ! log4perl_component $log4perl_config "worker"; then >- cat <<EOF >> $log4perl_config >-log4perl.logger.worker = WARN, WORKER >-log4perl.appender.WORKER=Log::Log4perl::Appender::Screen >-log4perl.appender.WORKER.stderr=1 >-log4perl.appender.WORKER.layout=PatternLayout >-log4perl.appender.WORKER.layout.ConversionPattern=[%d] [%p] %m %l%n >-log4perl.appender.WORKER.utf8=1 >- >-EOF >- fi >-done >- > for site in $(koha-list); do > kohaconfig="/etc/koha/sites/$site/koha-conf.xml" > logdir="$( xmlstarlet sel -t -v 'yazgfs/config/logdir' $kohaconfig )" >@@ -271,6 +150,19 @@ for zfile in $( find /etc/koha/sites -name zebra-authorities-dom.cfg -or -name z > perl -p -i -e 's{^modulePath: /usr/lib/idzebra-2.0/modules$}{modulePath: /usr/lib/idzebra-2.0/modules:/usr/lib/x86_64-linux-gnu/idzebra-2.0/modules:/usr/lib/i386-linux-gnu/idzebra-2.0/modules:/usr/lib/aarch64-linux-gnu/idzebra-2.0/modules:/usr/lib/arm-linux-gnueabi/idzebra-2.0/modules:/usr/lib/arm-linux-gnueabihf/idzebra-2.0/modules:/usr/lib/mips-linux-gnu/idzebra-2.0/modules:/usr/lib/mipsel-linux-gnu/idzebra-2.0/modules:/usr/lib/powerpc-linux-gnu/idzebra-2.0/modules:/usr/lib/powerpc64le-linux-gnu/idzebra-2.0/modules:/usr/lib/s390x-linux-gnu/idzebra-2.0/modules}' $zfile > done > >+if [ "$1" = "configure" ]; then >+ for site in $(koha-list); do >+ log4perl_file="/etc/koha/sites/$site/log4perl.conf" >+ temp_file=$(mktemp) >+ chmod 640 $temp_file >+ chown $site-koha:$site-koha $temp_file >+ koha-config --create-log4perl $site > $temp_file >+ ucf --debconf-ok $temp_file $log4perl_file >+ ucfr koha-common $log4perl_file >+ rm $temp_file >+ done >+fi >+ > db_stop > > rabbitmq-plugins enable rabbitmq_stomp >diff --git a/debian/koha-core.install b/debian/koha-core.install >index 2f5c793d11..4ea7f3cc47 100644 >--- a/debian/koha-core.install >+++ b/debian/koha-core.install >@@ -7,6 +7,7 @@ debian/unavailable.html usr/share/koha/intranet/htdocs > debian/unavailable.html usr/share/koha/opac/htdocs > debian/templates/* etc/koha > debian/scripts/koha-functions.sh usr/share/koha/bin >+debian/scripts/koha-config usr/sbin > debian/scripts/koha-create usr/sbin > debian/scripts/koha-create-dirs usr/sbin > debian/scripts/koha-disable usr/sbin >diff --git a/debian/koha-core.postinst b/debian/koha-core.postinst >index ad88d83d81..620ec042d1 100644 >--- a/debian/koha-core.postinst >+++ b/debian/koha-core.postinst >@@ -131,127 +131,6 @@ EOF > fi > fi > >-log4perl_component() >-{ >- local config=$1 >- local component=$2 >- >- if grep -q "log4perl.logger.$component" $config; then >- return 0 >- else >- return 1 >- fi >-} >- >-# Take care of the instance's log4perl.conf file >-for site in $(koha-list); do >- log4perl_config="/etc/koha/sites/$site/log4perl.conf" >- if ! log4perl_component $log4perl_config "z3950"; then >- cat <<EOF >> $log4perl_config >-log4perl.logger.z3950 = WARN, Z3950 >-log4perl.appender.Z3950=Log::Log4perl::Appender::File >-log4perl.appender.Z3950.filename=/var/log/koha/$site/z3950-error.log >-log4perl.appender.Z3950.mode=append >-log4perl.appender.Z3950.layout=PatternLayout >-log4perl.appender.Z3950.layout.ConversionPattern=[%d] [%p] %m %l%n >-log4perl.appender.Z3950.utf8=1 >- >-EOF >- fi >- >- if ! log4perl_component $log4perl_config "api"; then >- cat <<EOF >> $log4perl_config >-log4perl.logger.api = WARN, API >-log4perl.appender.API=Log::Log4perl::Appender::File >-log4perl.appender.API.filename=/var/log/koha/$site/api-error.log >-log4perl.appender.API.mode=append >-log4perl.appender.API.layout=PatternLayout >-log4perl.appender.API.layout.ConversionPattern=[%d] [%p] %m %l%n >-log4perl.appender.API.utf8=1 >- >-EOF >- fi >-done >- >-for site in $(koha-list); do >- log4perl_config="/etc/koha/sites/$site/log4perl.conf" >- if ! log4perl_component $log4perl_config "sip"; then >- cat <<EOF >> $log4perl_config >-log4perl.logger.sip = DEBUG, SIP >-log4perl.appender.SIP=Log::Log4perl::Appender::File >-log4perl.appender.SIP.filename=/var/log/koha/$site/sip.log >-log4perl.appender.SIP.mode=append >-log4perl.appender.SIP.layout=PatternLayout >-log4perl.appender.SIP.layout.ConversionPattern=[%d] [%P] [%p] %X{accountid}@%X{peeraddr}: %m %l%n >-log4perl.appender.SIP.utf8=1 >- >-EOF >- fi >-done >- >-for site in $(koha-list); do >- log4perl_config="/etc/koha/sites/$site/log4perl.conf" >- if ! log4perl_component $log4perl_config "plack-opac"; then >- cat <<EOF >> $log4perl_config >-log4perl.logger.plack-opac = WARN, PLACKOPAC >-log4perl.appender.PLACKOPAC=Log::Log4perl::Appender::File >-log4perl.appender.PLACKOPAC.filename=/var/log/koha/$site/plack-opac-error.log >-log4perl.appender.PLACKOPAC.mode=append >-log4perl.appender.PLACKOPAC.layout=PatternLayout >-log4perl.appender.PLACKOPAC.layout.ConversionPattern=[%d] [%p] %m%n >-log4perl.appender.PLACKOPAC.utf8=1 >- >-EOF >- fi >-done >- >-for site in $(koha-list); do >- log4perl_config="/etc/koha/sites/$site/log4perl.conf" >- if ! log4perl_component $log4perl_config "plack-api"; then >- cat <<EOF >> $log4perl_config >-log4perl.logger.plack-api = WARN, PLACKAPI >-log4perl.appender.PLACKAPI=Log::Log4perl::Appender::File >-log4perl.appender.PLACKAPI.filename=/var/log/koha/$site/plack-api-error.log >-log4perl.appender.PLACKAPI.mode=append >-log4perl.appender.PLACKAPI.layout=PatternLayout >-log4perl.appender.PLACKAPI.layout.ConversionPattern=[%d] [%p] %m%n >-log4perl.appender.PLACKAPI.utf8=1 >- >-EOF >- fi >-done >- >-for site in $(koha-list); do >- log4perl_config="/etc/koha/sites/$site/log4perl.conf" >- if ! log4perl_component $log4perl_config "plack-intranet"; then >- cat <<EOF >> $log4perl_config >-log4perl.logger.plack-intranet = WARN, PLACKINTRANET >-log4perl.appender.PLACKINTRANET=Log::Log4perl::Appender::File >-log4perl.appender.PLACKINTRANET.filename=/var/log/koha/$site/plack-intranet-error.log >-log4perl.appender.PLACKINTRANET.mode=append >-log4perl.appender.PLACKINTRANET.layout=PatternLayout >-log4perl.appender.PLACKINTRANET.layout.ConversionPattern=[%d] [%p] %m%n >-log4perl.appender.PLACKINTRANET.utf8=1 >- >-EOF >- fi >-done >- >-for site in $(koha-list); do >- log4perl_config="/etc/koha/sites/$site/log4perl.conf" >- if ! log4perl_component $log4perl_config "worker"; then >- cat <<EOF >> $log4perl_config >-log4perl.logger.worker = WARN, WORKER >-log4perl.appender.WORKER=Log::Log4perl::Appender::Screen >-log4perl.appender.WORKER.stderr=1 >-log4perl.appender.WORKER.layout=PatternLayout >-log4perl.appender.WORKER.layout.ConversionPattern=[%d] [%p] %m %l%n >-log4perl.appender.WORKER.utf8=1 >- >-EOF >- fi >-done >- > for site in $(koha-list); do > kohaconfig="/etc/koha/sites/$site/koha-conf.xml" > logdir="$( xmlstarlet sel -t -v 'yazgfs/config/logdir' $kohaconfig )" >@@ -271,6 +150,19 @@ for zfile in $( find /etc/koha/sites -name zebra-authorities-dom.cfg -or -name z > perl -p -i -e 's{^modulePath: /usr/lib/idzebra-2.0/modules$}{modulePath: /usr/lib/idzebra-2.0/modules:/usr/lib/x86_64-linux-gnu/idzebra-2.0/modules:/usr/lib/i386-linux-gnu/idzebra-2.0/modules:/usr/lib/aarch64-linux-gnu/idzebra-2.0/modules:/usr/lib/arm-linux-gnueabi/idzebra-2.0/modules:/usr/lib/arm-linux-gnueabihf/idzebra-2.0/modules:/usr/lib/mips-linux-gnu/idzebra-2.0/modules:/usr/lib/mipsel-linux-gnu/idzebra-2.0/modules:/usr/lib/powerpc-linux-gnu/idzebra-2.0/modules:/usr/lib/powerpc64le-linux-gnu/idzebra-2.0/modules:/usr/lib/s390x-linux-gnu/idzebra-2.0/modules}' $zfile > done > >+if [ "$1" = "configure" ]; then >+ for site in $(koha-list); do >+ log4perl_file="/etc/koha/sites/$site/log4perl.conf" >+ temp_file=$(mktemp) >+ chmod 640 $temp_file >+ chown $site-koha:$site-koha $temp_file >+ koha-config --create-log4perl $site > $temp_file >+ ucf --debconf-ok $temp_file $log4perl_file >+ ucfr koha-core $log4perl_file >+ rm $temp_file >+ done >+fi >+ > db_stop > > # Bug 18250: Correct startup order of koha-common and memcached >diff --git a/debian/scripts/koha-config b/debian/scripts/koha-config >new file mode 100755 >index 0000000000..74bbe63df0 >--- /dev/null >+++ b/debian/scripts/koha-config >@@ -0,0 +1,93 @@ >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>.a >+ >+use Getopt::Long; >+use Modern::Perl; >+use File::Slurp qw(read_file); >+ >+my $show_help; >+my $create_log4perl; >+ >+my $res = GetOptions( >+ "help|h" => \$show_help, >+ "create-log4perl" => \$create_log4perl, >+); >+ >+if ( !$res || $show_help ) { >+ show_help( !$res ); >+ exit( !$res ); >+} >+ >+if ( !@ARGV ) { >+ show_help( 1, "An instance name must be supplied." ); >+ exit(1); >+} >+my $instance = shift @ARGV; >+if ( !-e "/etc/koha/sites/$instance" ) { >+ show_help( 1, "The instance doesn't exist: $instance" ); >+ exit(1); >+} >+ >+if ($create_log4perl) { >+ my $log4perl = create_log4perl( { instance => $instance, } ); >+ print $log4perl; >+} >+ >+sub create_log4perl { >+ my ($args) = @_; >+ my $instance = $args->{instance}; >+ if ($instance) { >+ my $template = _get_template( { filename => 'log4perl-site.conf.in' } ); >+ my $replacement = sprintf( '/var/log/koha/%s', $instance ); >+ $template =~ s/__LOG_DIR__/$replacement/g; >+ return $template; >+ } >+} >+ >+sub _get_template { >+ my ($args) = @_; >+ my $template; >+ my $filename = $args->{filename}; >+ if ($filename) { >+ my $path = sprintf( '/etc/koha/%s', $filename ); >+ if ( -f $path ) { >+ my $text = read_file($path); >+ if ($text) { >+ $template = $text; >+ } >+ } >+ } >+ return $template; >+} >+ >+sub show_help { >+ my ( $err, $msg ) = @_; >+ >+ my $fh = $err ? *STDERR : *STDOUT; >+ say $fh "Error: " . $msg if $msg; >+ print $fh $_ while <DATA>; >+} >+ >+__DATA__ >+koha-config -- tool for working with Koha configuration >+ >+Usage: koha-config [options] [instance name] >+ >+Options: >+ -h, --help show this help and quit >+ --create-log4perl create log4perl config for this instance >+ >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32791
:
145985
|
145986
| 146567