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] %m %l %n
+log4perl.appender.SIP.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 )"
+ if [ "$logdir" != "" ] && [ "$logdir" != "0" ]; then
+ chown -R $site-koha:$site-koha $logdir
+ else
+ chown -R $site-koha:$site-koha /var/log/koha/$site
+ fi
+done
+
# Bug 14106 - fix the modulePath of existing koha instances so that it'll
# continue to work. This will only patch the files if the exact original string
# that we're fixing them from is there, so we just run it every time. Maybe
# in many years time we can get rid of this, when no one will be running
# Koha < 3.20.
-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}' $( find /etc/koha/sites -name zebra-authorities.cfg -or -name zebra-authorities-dom.cfg -or -name zebra-biblios.cfg -or -name zebra-biblios-dom.cfg )
+for zfile in $( find /etc/koha/sites -name zebra-authorities-dom.cfg -or -name zebra-biblios-dom.cfg ); do
+ 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
db_stop
+# Bug 18250: Correct startup order of koha-common and memcached
+# Since the init script has been updated, we can force the order in rc.d
+# by disabling and enabling again.
+update-rc.d koha-common disable
+update-rc.d koha-common enable
+
exit 0