From 425cb6ec25210a7832ca0de39e2404daae1c8bc2 Mon Sep 17 00:00:00 2001 From: Mason James Date: Thu, 26 Nov 2020 01:04:27 +1300 Subject: [PATCH] Bug 26672: Add additional koha-core and koha-full files to ./debian Signed-off-by: Tomas Cohen Arazi Signed-off-by: Jonathan Druart --- debian/koha-core.bash-completion | 342 +++++++++++++++++++++++++++++++ debian/koha-core.config | 61 ++++++ debian/koha-core.default | 37 ++++ debian/koha-core.dirs | 6 + debian/koha-core.docs | 5 + debian/koha-core.init | 226 ++++++++++++++++++++ debian/koha-core.install | 40 ++++ debian/koha-core.links | 8 + debian/koha-core.logrotate | 15 ++ debian/koha-core.postinst | 267 ++++++++++++++++++++++++ debian/koha-core.preinst | 11 + debian/koha-core.templates | 25 +++ debian/koha-full.postinst | 11 + debian/templates/koha-core.conf | 17 ++ 14 files changed, 1071 insertions(+) create mode 100644 debian/koha-core.bash-completion create mode 100755 debian/koha-core.config create mode 100644 debian/koha-core.default create mode 100644 debian/koha-core.dirs create mode 100644 debian/koha-core.docs create mode 100755 debian/koha-core.init create mode 100644 debian/koha-core.install create mode 100644 debian/koha-core.links create mode 100644 debian/koha-core.logrotate create mode 100644 debian/koha-core.postinst create mode 100644 debian/koha-core.preinst create mode 100644 debian/koha-core.templates create mode 100644 debian/koha-full.postinst create mode 100644 debian/templates/koha-core.conf diff --git a/debian/koha-core.bash-completion b/debian/koha-core.bash-completion new file mode 100644 index 0000000000..8ee72320bf --- /dev/null +++ b/debian/koha-core.bash-completion @@ -0,0 +1,342 @@ +#!/bin/bash +# +# koha-core.bash-completion script for koha-* commands +# +# This file is part of Koha. +# +# Copyright 2013 Universidad Nacional de Cordoba +# Tomas Cohen Arazi +# +# 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 . + +_build_substract_switches() +{ + local substract + + for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do + if [[ ${COMP_WORDS[i]} == -* ]]; then + substract="$substract -e ${COMP_WORDS[i]}" + fi + done + + echo "$substract" +} + +_build_substract_instances() +{ + local substract + + for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do + substract="$substract -e ${COMP_WORDS[i]}" + done + + echo "$substract" +} + +_koha_single_instance() +{ + local filter=$1 + + cur=${COMP_WORDS[COMP_CWORD]} + prev=${COMP_WORDS[COMP_CWORD-1]} + if [ $COMP_CWORD -eq 1 ]; then + COMPREPLY=( $( compgen -W "$(koha-list $filter)" $cur ) ) + else + COMPREPLY=() + fi + + return 0 +} + +_koha_list_cmd() +{ + local filter=$1 + + local cur substract instancelist + _get_comp_words_by_ref cur + + # Build a list of the already used words + substract=`_build_substract_instances` + + if [[ "$substract" != "" ]]; then + instancelist=$( koha-list $filter | grep -v -x $substract ) + else + instancelist=$( koha-list $filter ) + fi + + COMPREPLY=( $(compgen -W "$instancelist" -- $cur ) ) + return 0 +} + +_koha_email_disable() +{ + _koha_list_cmd "--email" + return 0 +} +complete -F _koha_email_disable koha-email-disable + +_koha_email_enable() +{ + _koha_list_cmd "--noemail" + return 0 +} +complete -F _koha_email_enable koha-email-enable + +_koha_sip_enabled_instances() +{ + _koha_list_cmd "--sip" + return 0 +} + +_koha_sip_disabled() +{ + _koha_list_cmd "--nosip" + return 0 +} + +_koha_disabled_instances() +{ + _koha_list_cmd "--disabled" + return 0 +} + +_koha_enabled_instances() +{ + _koha_list_cmd "--enabled" + return 0 +} + +# koha-enable autocompletes with disabled instances +complete -F _koha_disabled_instances koha-enable + +# koha-disable autocompletes with enabled instances +complete -F _koha_enabled_instances koha-disable + +# koha-mysql autocompletes with a single instance name +complete -F _koha_single_instance koha-mysql + +_koha_list() +{ + local cur opts substract + + COMPREPLY=() + _get_comp_words_by_ref cur + opts="--enabled --disabled --email --noemail --plack --noplack --sip --nosip --help -h" + + # Build a list of the already used option switches + for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do + if [[ ${COMP_WORDS[i]} == -* ]]; then + case ${COMP_WORDS[i]} in + --disabled) + substract="$substract -e --enabled"; ;; + --enabled) + substract="$substract -e --disabled"; ;; + --email) + substract="$substract -e --noemail"; ;; + --noemail) + substract="$substract -e --email"; ;; + --plack) + substract="$substract -e --noplack"; ;; + --noplack) + substract="$substract -e --plack"; ;; + --sip) + substract="$substract -e --nosip"; ;; + --nosip) + substract="$substract -e --sip"; ;; + --help) + substract="$substract -e -h"; ;; + -h) + substract="$substract -e --help"; ;; + esac + substract="$substract -e ${COMP_WORDS[i]}" + fi + done + + if [[ "$substract" != "" ]]; then + opts=$( echo $opts | sed -e 's/ /\n/g' | grep -v -x $substract ) + fi + + COMPREPLY=( $(compgen -W "$opts" -- $cur ) ) + + return 0 +} +complete -F _koha_list koha-list + +_koha_plack_instances() +{ + _koha_list_cmd "--plack" + return 0 +} + +_koha_noplack_instances() +{ + _koha_list_cmd "--noplack" + return 0 +} + +_koha-plack() +{ + local cur opts substract + + COMPREPLY=() + _get_comp_words_by_ref cur + opts="--start --stop --restart --enable --disable --quiet -q --help -h" + + # Build a list of the already used option switches + for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do + if [[ ${COMP_WORDS[i]} == -* ]]; then + case ${COMP_WORDS[i]} in + --start) _koha_plack_instances ; return 0 ;; + --stop) _koha_plack_instances ; return 0 ;; + --restart) _koha_plack_instances ; return 0 ;; + --enable) _koha_noplack_instances ; return 0 ;; + --disable) _koha_plack_instances ; return 0 ;; + --help) COMPREPLY=() ; return 0 ;; # no more completions + -h) COMPREPLY=() ; return 0 ;; # no more completions + --quiet) # filter the other quiet switches and go on + substract="$substract -e -q"; ;; + -q) # filter the other quiet switches and go on + substract="$substract -e --quiet"; ;; + esac + substract="$substract -e ${COMP_WORDS[i]}" + fi + done + + if [[ "$substract" != "" ]]; then + opts=$( echo $opts | sed -e 's/ /\n/g' | grep -v -x $substract ) + fi + + COMPREPLY=( $(compgen -W "$opts" -- $cur ) ) + + return 0 +} +complete -F _koha-plack koha-plack + +_koha-indexer() +{ + local cur opts substract + + COMPREPLY=() + _get_comp_words_by_ref cur + opts="--start --stop --restart --quiet -q --help -h" + + # Build a list of the already used option switches + for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do + if [[ ${COMP_WORDS[i]} == -* ]]; then + case ${COMP_WORDS[i]} in + --start) _koha_list_cmd ; return 0 ;; + --stop) _koha_list_cmd ; return 0 ;; + --restart) _koha_list_cmd ; return 0 ;; + --help) COMPREPLY=() ; return 0 ;; # no more completions + -h) COMPREPLY=() ; return 0 ;; # no more completions + --quiet) # filter the other quiet switches and go on + substract="$substract -e -q"; ;; + -q) # filter the other quiet switches and go on + substract="$substract -e --quiet"; ;; + esac + substract="$substract -e ${COMP_WORDS[i]}" + fi + done + + if [[ "$substract" != "" ]]; then + opts=$( echo $opts | sed -e 's/ /\n/g' | grep -v -x $substract ) + fi + + COMPREPLY=( $(compgen -W "$opts" -- $cur ) ) + + return 0 +} +complete -F _koha-indexer koha-indexer + +_koha-zebra() +{ + local cur opts substract + + COMPREPLY=() + _get_comp_words_by_ref cur + opts="--start --stop --restart --status --quiet -q --help -h" + + # Build a list of the already used option switches + for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do + if [[ ${COMP_WORDS[i]} == -* ]]; then + case ${COMP_WORDS[i]} in + --start) _koha_list_cmd ; return 0 ;; + --stop) _koha_list_cmd ; return 0 ;; + --restart) _koha_list_cmd ; return 0 ;; + --status) _koha_list_cmd ; return 0 ;; + --help) COMPREPLY=() ; return 0 ;; # no more completions + -h) COMPREPLY=() ; return 0 ;; # no more completions + --quiet) # filter the other quiet switches and go on + substract="$substract -e -q"; ;; + -q) # filter the other quiet switches and go on + substract="$substract -e --quiet"; ;; + esac + substract="$substract -e ${COMP_WORDS[i]}" + fi + done + + if [[ "$substract" != "" ]]; then + opts=$( echo $opts | sed -e 's/ /\n/g' | grep -v -x $substract ) + fi + + COMPREPLY=( $(compgen -W "$opts" -- $cur ) ) + + return 0 +} +complete -F _koha-zebra koha-zebra + +_koha-sip() +{ + local cur opts substract + + COMPREPLY=() + _get_comp_words_by_ref cur + opts="--start --stop --restart --status --enable --verbose -v --help -h" + + # Build a list of the already used option switches + for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do + if [[ ${COMP_WORDS[i]} == -* ]]; then + case ${COMP_WORDS[i]} in + --start) _koha_sip_enabled_instances ; return 0 ;; + --stop) _koha_sip_enabled_instances ; return 0 ;; + --restart) _koha_sip_enabled_instances ; return 0 ;; + --status) _koha_sip_enabled_instances ; return 0 ;; + --enable) _koha_sip_disabled ; return 0 ;; + --help) COMPREPLY=() ; return 0 ;; # no more completions + -h) COMPREPLY=() ; return 0 ;; # no more completions + --verbose) # filter the other quiet switches and go on + substract="$substract -e -q"; ;; + -v) # filter the other quiet switches and go on + substract="$substract -e --verbose"; ;; + esac + substract="$substract -e ${COMP_WORDS[i]}" + fi + done + + if [[ "$substract" != "" ]]; then + opts=$( echo $opts | sed -e 's/ /\n/g' | grep -v -x $substract ) + fi + + COMPREPLY=( $(compgen -W "$opts" -- $cur ) ) + + return 0 +} +complete -F _koha-sip koha-sip + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh diff --git a/debian/koha-core.config b/debian/koha-core.config new file mode 100755 index 0000000000..c3e4ede62d --- /dev/null +++ b/debian/koha-core.config @@ -0,0 +1,61 @@ +#!/bin/sh + +# koha-core.config - ensures that debconf stuff is all handled properly +# +# Copyright 2011 Catalyst IT, Ltd +# +# This program 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. +# +# This program 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 this program. If not, see . + +set -e + +. /usr/share/debconf/confmodule + +CONFIGFILE=/etc/koha/koha-common.conf + +if [ -e $CONFIGFILE ]; then + . $CONFIGFILE || true + # Put the current values into debconf + UPDATE="true" + if [ "$AUTOMATIC_TRANSLATIONS_UPDATE" = "no" ] ; then + UPDATE="false" + fi + db_set koha-core/automatically-update-translations "$UPDATE" +else + # True is the default + db_set koha-core/automatically-update-translations true +fi + +if dpkg --compare-versions "$2" lt-nl 3.4 ; then + db_input high koha-core/3.2-3.4-upgrade-notice || true +fi + +db_input medium koha-core/automatically-update-translations || true + +# Determine if we should ask the user about upgrading - there's no point +# if this is a fresh install anyway. +if [ -e /usr/sbin/koha-list ]; then + RENAME_APACHE_FILES="no" + for vhost in $(koha-list); do + if [ -f "/etc/apache2/sites-available/$vhost" ] && \ + [ ! -f "/etc/apache2/sites-available/$vhost.conf" ]; then + RENAME_APACHE_FILES="yes" + break # at least one, trigger renaming + fi + done + if [ "$RENAME_APACHE_FILES" = "yes" ]; then + db_input high koha-core/rename-apache-vhost-files || true + fi +fi + +db_go || true diff --git a/debian/koha-core.default b/debian/koha-core.default new file mode 100644 index 0000000000..b0e0bc4cc9 --- /dev/null +++ b/debian/koha-core.default @@ -0,0 +1,37 @@ +## General koha-common default options file + +PERL5LIB="/usr/share/koha/lib" +KOHA_HOME="/usr/share/koha" + +## Background record indexing +# +# The following options control the use of an indexing daemon for +# Koha instances. +# +# More information can be found here: +# +# http://wiki.koha-community.org/wiki/PackagesIndexDaemon +# +# USE_INDEXER_DAEMON: "no" | "yes" +# +USE_INDEXER_DAEMON="no" + +# Set an alternate indexer daemon. The default is to use the rebuild_zebra.pl +# in daemon mode. +# +# Example: ALTERNATE_INDEXER_DAEMON="koha-index-daemon" +# +# ALTERNATE_INDEXER_DAEMON="" + +# Lookup/indexing frecquency (in seconds) for the indexing daemon. +# +# The default value is 5 +# +INDEXER_TIMEOUT=5 + +# Parameters to be passed to the indexer daemon. Useful for alternate indexers. +# Defaults to INDEXER_PARAMS="-daemon -sleep $INDEXER_TIMEOUT" +# +# INDEXER_PARAMS="" + +## End of general koha-common default options diff --git a/debian/koha-core.dirs b/debian/koha-core.dirs new file mode 100644 index 0000000000..b98541d007 --- /dev/null +++ b/debian/koha-core.dirs @@ -0,0 +1,6 @@ +etc/koha/sites +var/cache/koha +var/lib/koha +var/log/koha +var/lock/koha +var/spool/koha diff --git a/debian/koha-core.docs b/debian/koha-core.docs new file mode 100644 index 0000000000..fc95b8e530 --- /dev/null +++ b/debian/koha-core.docs @@ -0,0 +1,5 @@ +debian/docs/LEEME.Debian +misc/release_notes/release_notes_3*.txt +docs/history.txt +docs/contributors.yaml +docs/teams.yaml diff --git a/debian/koha-core.init b/debian/koha-core.init new file mode 100755 index 0000000000..a7efbd8812 --- /dev/null +++ b/debian/koha-core.init @@ -0,0 +1,226 @@ +#! /bin/sh +### BEGIN INIT INFO +# Provides: koha-core +# Required-Start: $remote_fs memcached +# Required-Stop: $remote_fs +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Start required services for each Koha instance +# Description: For each enabled Koha instance on this host, +# if enabled, start: +# - a Zebra server (using koha-zebra) +# - a Plack server (using koha-plack) +# - a SIP server (using koha-sip) +# - a Z3950 server (using koha-z3950-responder) +### END INIT INFO + +# Author: Lars Wirzenius + +# Do NOT "set -e" + +# PATH should only include /usr/* if it runs after the mountnfs.sh script +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC="Koha ILS" +NAME="koha-core" +SCRIPTNAME=/etc/init.d/$NAME + +# Exit if the package is not installed +[ -x /usr/sbin/koha-zebra ] || exit 0 + +# Read configuration variable file if it is present +if [ -r /etc/default/$NAME ]; then + # Debian / Ubuntu + . /etc/default/$NAME +elif [ -r /etc/sysconfig/$NAME ]; then + # RedHat / SuSE + . /etc/sysconfig/$NAME +fi + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# include helper functions +if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then + . "/usr/share/koha/bin/koha-functions.sh" +else + echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2 + exit 1 +fi + +# +# Function that starts the daemon/service +# +do_start() +{ + # We insure all required directories exist, including disabled ones. + koha-create-dirs $(koha-list) +## koha-zebra --start $(koha-list --enabled) +## koha-sip --start $(koha-list --enabled --sip) +## koha-plack --start $(koha-list --enabled --plack) +## koha-z3950-responder --start --quiet $(koha-list --enabled --z3950) +## koha-worker --start $(koha-list --enabled) + + if [ "$USE_INDEXER_DAEMON" = "yes" ]; then + koha-indexer --start --quiet $(koha-list --enabled) + fi +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # We stop everything, including disabled ones. +## koha-zebra --stop $(koha-list) || true +## koha-sip --stop $(koha-list --sip) +## koha-plack --stop --quiet $(koha-list --enabled --plack) +## koha-z3950-responder --stop --quiet $(koha-list --enabled --z3950) +## koha-worker --stop --quiet $(koha-list --enabled) + + if [ "$USE_INDEXER_DAEMON" = "yes" ]; then + koha-indexer --stop --quiet $(koha-list --enabled) + fi +} + +# +# Function that sends a SIGHUP to the daemon/service +# +do_reload() { +## koha-zebra --restart $(koha-list --enabled) +## koha-sip --restart $(koha-list --enabled --sip) +## koha-plack --restart --quiet $(koha-list --enabled --plack) +## koha-z3950-responder --restart --quiet $(koha-list --enabled --z3950) +## koha-worker --restart --quiet $(koha-list --enabled) + + if [ "$USE_INDEXER_DAEMON" = "yes" ]; then + koha-indexer --restart --quiet $(koha-list --enabled) + fi +} + +# +# Function that shows the status of the zebrasrv daemon for +# enabled instances +# +zebra_status() +{ + for instance in $(koha-list --enabled); do + + log_daemon_msg "Zebra server running for instance $instance" + + if is_zebra_running $instance ; then + log_end_msg 0 + else + log_end_msg 1 + fi + done +} + +# +# Function that shows the status of the SIP server daemon for +# enabled instances +# +sip_status() +{ + for instance in $(koha-list --enabled --sip); do + + log_daemon_msg "SIP server running for instance $instance" + + if is_sip_running $instance ; then + log_end_msg 0 + else + log_end_msg 1 + fi + done +} + +# +# Function that shows the status of the Plack server daemon for +# enabled instances +# +plack_status() +{ + for instance in $(koha-list --enabled --plack); do + + log_daemon_msg "Plack server running for instance ${instance}" + + if is_plack_running $instance ; then + log_end_msg 0 + else + log_end_msg 1 + fi + done +} + +# +# Function that shows the status of the Z39.50/SRU server daemon for +# enabled instances +# +z3950_status() +{ + for instance in $(koha-list --enabled --z3950); do + + log_daemon_msg "Z39.50/SRU daemon running for instance ${instance}" + + if is_z3950_running $instance ; then + log_end_msg 0 + else + log_end_msg 1 + fi + done +} + +case "$1" in + start) + [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME" + do_start + case "$?" in + 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + *) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + stop) + [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0) [ "$VERBOSE" != no ] && log_end_msg 0 ;; + *) [ "$VERBOSE" != no ] && log_end_msg 1 ;; + esac + ;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0) + do_start + case "$?" in + 0) log_end_msg 0 ;; + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + status) + zebra_status + sip_status + plack_status + z3950_status + ;; + *) + echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2 + exit 3 + ;; +esac + +: diff --git a/debian/koha-core.install b/debian/koha-core.install new file mode 100644 index 0000000000..7bc5b7e781 --- /dev/null +++ b/debian/koha-core.install @@ -0,0 +1,40 @@ +debian/tmp/usr/* usr +debian/tmp/etc/koha/pazpar2 +debian/tmp/etc/koha/zebradb/[!z]* +debian/tmp/etc/koha/z3950 +debian/templates/* etc/koha +debian/koha-post-install-setup usr/sbin +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-create usr/sbin +debian/scripts/koha-create-dirs usr/sbin +debian/scripts/koha-disable usr/sbin +debian/scripts/koha-dump usr/sbin +debian/scripts/koha-dump-defaults usr/sbin +debian/scripts/koha-elasticsearch usr/sbin +debian/scripts/koha-email-disable usr/sbin +debian/scripts/koha-email-enable usr/sbin +debian/scripts/koha-enable usr/sbin +debian/scripts/koha-foreach usr/sbin +debian/scripts/koha-indexer usr/sbin +debian/scripts/koha-list usr/sbin +debian/scripts/koha-mysql usr/sbin +debian/scripts/koha-passwd usr/sbin +debian/scripts/koha-plack usr/sbin +debian/scripts/koha-rebuild-zebra usr/sbin +debian/scripts/koha-remove usr/sbin +debian/scripts/koha-reset-passwd usr/sbin +debian/scripts/koha-restore usr/sbin +debian/scripts/koha-run-backups usr/sbin +debian/scripts/koha-shell usr/sbin +debian/scripts/koha-sip usr/sbin +debian/scripts/koha-sitemap usr/sbin +debian/scripts/koha-translate usr/sbin +debian/scripts/koha-upgrade-schema usr/sbin +debian/scripts/koha-upgrade-to-3.4 usr/sbin +debian/scripts/koha-worker usr/sbin +debian/scripts/koha-z3950-responder usr/sbin +debian/scripts/koha-zebra usr/sbin +debian/tmp_docbook/*.8 usr/share/man/man8 diff --git a/debian/koha-core.links b/debian/koha-core.links new file mode 100644 index 0000000000..31ecd3f14c --- /dev/null +++ b/debian/koha-core.links @@ -0,0 +1,8 @@ +usr/sbin/koha-zebra usr/sbin/koha-start-zebra +usr/sbin/koha-zebra usr/sbin/koha-stop-zebra +usr/sbin/koha-zebra usr/sbin/koha-restart-zebra +usr/sbin/koha-sip usr/sbin/koha-enable-sip +usr/sbin/koha-sip usr/sbin/koha-start-sip +usr/sbin/koha-sip usr/sbin/koha-stop-sip +usr/sbin/koha-sip usr/sbin/koha-stop-sip +etc/default/koha-core etc/default/koha-common diff --git a/debian/koha-core.logrotate b/debian/koha-core.logrotate new file mode 100644 index 0000000000..1f083fe69a --- /dev/null +++ b/debian/koha-core.logrotate @@ -0,0 +1,15 @@ +# Rotate log files for all Koha instances. + +/var/log/koha/*/*.log { + rotate 5 + weekly + missingok + copytruncate + compress + delaycompress + notifempty + sharedscripts + postrotate + /etc/init.d/apache2 reload > /dev/null + endscript +} diff --git a/debian/koha-core.postinst b/debian/koha-core.postinst new file mode 100644 index 0000000000..379b9e89cc --- /dev/null +++ b/debian/koha-core.postinst @@ -0,0 +1,267 @@ +#!/bin/sh + +set -e + +# Default to "yes" +AUTOMATIC_TRANSLATIONS_UPDATE="yes" + +. /usr/share/debconf/confmodule + +# Read configuration variable file if it is present +CONFIG=/etc/koha/koha-common.conf +if [ -r $CONFIG ]; then + . $CONFIG +fi + +conf=/etc/mysql/koha-common.cnf +if [ ! -e "$conf" ] && [ ! -L "$conf" ] +then + ln -s debian.cnf "$conf" +fi + +#DEBHELPER# + +koha-upgrade-schema $(koha-list) + +# Generate a config file if one doesn't exist already +if [ ! -e $CONFIG ]; then + cat < $CONFIG +## Automatic template translation update +# +# This variable controls whether template translations should +# be updated automatically on koha-common package upgrades. +# Options: 'yes' (default) +# 'no' +# Note: if you choose 'no' then you will have to issue +# $ koha-translate --update +# +AUTOMATIC_TRANSLATIONS_UPDATE="yes" +EOF +fi + +# Substitute the values from debconf into the file. +db_get koha-core/automatically-update-translations +UPDATE="$RET" +if [ "$UPDATE" = "false" ]; then + UPDATE="no" +else + UPDATE="yes" +fi +# In case they were removed/commented out, we add it in. +grep -Eq '^ *AUTOMATIC_TRANSLATIONS_UPDATE=' $CONFIG || \ + echo "AUTOMATIC_TRANSLATIONS_UPDATE=" >> $CONFIG + +sed -e "s/^ *AUTOMATIC_TRANSLATIONS_UPDATE=.*/AUTOMATIC_TRANSLATIONS_UPDATE=\"$UPDATE\"/" < $CONFIG > $CONFIG.tmp +mv -f $CONFIG.tmp $CONFIG + +if [ "$AUTOMATIC_TRANSLATIONS_UPDATE" = "yes" ]; then + for lang in $(koha-translate --list | grep -v -x "en"); do + if koha-translate --update $lang; then + echo "Updated the $lang translations." + else + cat <&2 +ERROR: an error was found when updating '$lang' translations. Please manually +run 'koha-translate --update $lang'. Run man koha-translate for more options. +EOF + fi + done +else + # no auto-update, check update needed and warn if needed + if koha-translate --list | grep -v -q -x "en"; then + # translations installed, update needed + cat <&2 +Warning: template translations are not set to be automatically updated. +Please manually run 'koha-translate --update lang_code' to update them. + +You can run 'koha-translate --list' to get a list of the installed translations codes. +EOF + fi +fi + +# Check if we need to rename the Apache vhost files +RENAME_APACHE_FILES="no" +for vhost in $(koha-list); do + if [ -f "/etc/apache2/sites-available/$vhost" ] && \ + [ ! -f "/etc/apache2/sites-available/$vhost.conf" ]; then + RENAME_APACHE_FILES="yes" + break # at least one, trigger renaming + fi +done + +if [ "$RENAME_APACHE_FILES" = "yes" ]; then + # If the user agreed we now rename their Apache files + db_get koha-core/rename-apache-vhost-files + if [ "$RET" = "false" ]; then + # We're not renaming the files, just print a warning + cat <&2 +Warning: you have chosen not to migrate your Apache virtual hosts files to the +Apache 2.4 naming schema. You can do it manually by running this for each +Koha instance: + + $ sudo a2dissite instance + $ sudo mv /etc/apache2/sites-available/instance \ + /etc/apache2/sites-available/instance.conf + $ sudo a2ensite instance +EOF + else + # We have to rename the Apache files + for site in $(koha-list); do + ENABLE_VHOST="yes" + if [ -f "/etc/apache2/sites-available/$site" ] && \ + [ ! -f "/etc/apache2/sites-available/$site.conf" ]; then + if [ ! -f "/etc/apache2/sites-enabled/$site" ]; then + ENABLE_VHOST="no" + fi + a2dissite $site > /dev/null 2>&1 || true + rm -f "/etc/apache2/sites-enabled/$site" + # Rename the vhost definition files + mv "/etc/apache2/sites-available/$site" \ + "/etc/apache2/sites-available/$site.conf" + + if [ "$ENABLE_VHOST" = "yes" ]; then + if ! { + a2ensite "$site" > /dev/null 2>&1 || + a2ensite "${site}.conf" > /dev/null 2>&1 + }; then + echo "Warning: problem enabling $site in Apache" >&2 + fi + fi + fi + done + 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 <> $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 <> $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 <> $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 + log4perl_config="/etc/koha/sites/$site/log4perl.conf" + if ! log4perl_component $log4perl_config "plack-opac"; then + cat <> $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 +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 <> $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 +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 <> $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 +log4perl.appender.PLACKINTRANET.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. +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-core disable +update-rc.d koha-core enable + +exit 0 diff --git a/debian/koha-core.preinst b/debian/koha-core.preinst new file mode 100644 index 0000000000..648a2e1632 --- /dev/null +++ b/debian/koha-core.preinst @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +# Bug 14055 - remove the yui symlink if there's one in the way preventing upgrades +[ -h /usr/share/koha/opac/htdocs/opac-tmpl/lib/yui ] && rm /usr/share/koha/opac/htdocs/opac-tmpl/lib/yui + +# Bug 25485: remove the tiny_mce symlink if there's one in the way preventing upgrades +[ -h /usr/share/koha/intranet/htdocs/intranet-tmpl/lib/tiny_mce ] && rm /usr/share/koha/intranet/htdocs/intranet-tmpl/lib/tiny_mce + +exit 0 diff --git a/debian/koha-core.templates b/debian/koha-core.templates new file mode 100644 index 0000000000..1d6fdfb6d7 --- /dev/null +++ b/debian/koha-core.templates @@ -0,0 +1,25 @@ +Template: koha-core/3.2-3.4-upgrade-notice +Type: note +Description: koha-core upgrade actions required + If you are upgrading from a Koha 3.2 to 3.4 release, you must run: + sudo /usr/sbin/koha-upgrade-to-3.4 + . + For large catalogues, running this may take a while. Your Koha installation + should be largely operational during the process, but some things, + particularly to do with items, may appear strange until the upgrade and + re-index is complete. + +Template: koha-core/automatically-update-translations +Type: boolean +Default: true +Description: automatically update translations + When Koha is upgraded, any existing translated templates can be regenerated + to keep everything in sync. Select "yes" if you want this. + +Template: koha-core/rename-apache-vhost-files +Type: boolean +Default: true +Description: Rename the Apache virtual hosts files for Koha instances? + When Koha is upgraded, the Apache's virtual host definition files can be + renamed to match the needs of the newer Apache 2.4. Previously defined + Koha instances will get their Apache files appended '.conf'. diff --git a/debian/koha-full.postinst b/debian/koha-full.postinst new file mode 100644 index 0000000000..2e16772c8b --- /dev/null +++ b/debian/koha-full.postinst @@ -0,0 +1,11 @@ +#!/bin/sh + +set -e + +a2enmod mpm_itk rewrite cgi rewrite headers proxy_http +service apache2 restart + +rabbitmq-plugins enable rabbitmq_stomp +service rabbitmq-server restart + +exit 0 diff --git a/debian/templates/koha-core.conf b/debian/templates/koha-core.conf new file mode 100644 index 0000000000..92eff636b5 --- /dev/null +++ b/debian/templates/koha-core.conf @@ -0,0 +1,17 @@ +### Configuration settings for all Koha sites +# +# This file contains configuration settings that apply +# to all Koha sites on this server or which apply to +# the koha-core package itself. +# + +## Automatic template translation update +# +# This variable controls whether template translations should +# be updated automatically on koha-core package upgrades. +# Options: 'yes' (default) +# 'no' +# Note: if you choose 'no' then you will have to issue +# $ koha-translate --update +# +AUTOMATIC_TRANSLATIONS_UPDATE="yes" -- 2.39.5