Bug 40901: (QA follow-up) Make koha-disable/koha-enable symmetric and fix koha-remove/koha-create
koha-disable had gained "koha-sip --disable" and an unconditional "koha-plack --disable". On both backends those are not just systemd bookkeeping: on SysV the former deletes the sip.enabled flag and the latter comments the Plack includes out of the Apache vhost (which koha-disable then restarts Apache to apply). koha-enable was unchanged, so "koha-disable x && koha-enable x" left the instance on CGI with SIP off. Go back to stopping the daemons only (the new Plack and ES indexer stops are kept), and under systemd stop and disable the per-instance koha@<inst>.target so the instance stays down across reboots while the individual units keep their enablement. koha-enable re-enables and starts that target, so an enabled instance comes back exactly as it was. koha-remove nested every --disable inside "if is_*_running", so a unit that was enabled but stopped kept its symlink in koha@<inst>.target.wants/ after the instance was gone, which is the very thing the block below it says it prevents. Disable unconditionally. koha-create aborted after the database and vhost existed if a systemd-only --enable failed, because the helpers run under set -e; guard them like the systemctl calls already were. It also only started koha.target, which is a no-op when the target is already active, so the new instance's units were not started; start koha@<name>.target itself. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
0bdb94bfbb
commit
ffe8b55b57
|
|
@ -908,26 +908,29 @@ then
|
|||
fi
|
||||
service apache2 restart
|
||||
|
||||
# Enable & start Zebra.
|
||||
koha-zebra --enable "$name"
|
||||
# Enable & start Zebra. The --enable calls are systemd-only no-ops on
|
||||
# SysV and must not abort instance creation (the database and vhost
|
||||
# already exist at this point), hence the || true.
|
||||
koha-zebra --enable "$name" || true
|
||||
koha-zebra --start "$name"
|
||||
|
||||
# Start workers
|
||||
koha-worker --all-queues --enable "$name"
|
||||
koha-worker --all-queues --enable "$name" || true
|
||||
koha-worker --all-queues --start "$name"
|
||||
|
||||
if [ "$USE_INDEXER_DAEMON" = "yes" ]; then
|
||||
# Start Indexer daemon
|
||||
koha-indexer --enable "$name"
|
||||
koha-indexer --enable "$name" || true
|
||||
koha-indexer --start "$name"
|
||||
fi
|
||||
|
||||
# systemd-only: enable the per-instance target and the
|
||||
# create-dirs oneshot so the instance comes back up on reboot.
|
||||
# systemd-only: enable the per-instance target and the create-dirs
|
||||
# oneshot so the instance comes back up on reboot, and start the
|
||||
# target so the instance is fully up now.
|
||||
if [ "$(koha_init_backend)" = "systemd" ]; then
|
||||
systemctl enable koha-create-dirs@${name}.service 2>/dev/null || true
|
||||
systemctl enable koha@${name}.target 2>/dev/null || true
|
||||
systemctl start koha.target 2>/dev/null || true
|
||||
systemctl enable "koha-create-dirs@${name}.service" 2>/dev/null || true
|
||||
systemctl enable "koha@${name}.target" 2>/dev/null || true
|
||||
systemctl start "koha@${name}.target" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
if [ "$CLO_LETSENCRYPT" = "yes" ]; then
|
||||
|
|
|
|||
|
|
@ -63,28 +63,34 @@ do
|
|||
RET=$(disable_instance $name)
|
||||
if [ "$RET" = 0 ]; then
|
||||
restart_apache="yes"
|
||||
# Stop the instance's daemons. Their configuration (SIP flag
|
||||
# file, Plack in the Apache vhost, unit enablement) is left
|
||||
# alone so that koha-enable brings back exactly what was
|
||||
# running before.
|
||||
if is_sip_enabled $name; then
|
||||
koha-sip --stop $name
|
||||
koha-sip --disable $name
|
||||
fi
|
||||
if is_plack_running $name; then
|
||||
koha-plack --stop $name
|
||||
fi
|
||||
koha-plack --disable $name || true
|
||||
if is_zebra_running $name; then
|
||||
koha-zebra --stop $name
|
||||
fi
|
||||
koha-zebra --disable $name || true
|
||||
if is_indexer_running $name; then
|
||||
koha-indexer --stop $name
|
||||
fi
|
||||
koha-indexer --disable $name || true
|
||||
if is_es_indexer_running $name; then
|
||||
koha-es-indexer --stop $name
|
||||
fi
|
||||
koha-es-indexer --disable $name || true
|
||||
koha-worker --all-queues --stop $name || /bin/true
|
||||
koha-worker --all-queues --disable $name || /bin/true
|
||||
|
||||
# Under systemd, keep the instance from coming back at boot:
|
||||
# only the per-instance target is disabled, the individual
|
||||
# units keep their enablement.
|
||||
if [ "$(koha_init_backend)" = "systemd" ]; then
|
||||
systemctl stop "koha@${name}.target" 2>/dev/null || true
|
||||
systemctl disable "koha@${name}.target" 2>/dev/null || true
|
||||
fi
|
||||
elif [ "$RET" = 2 ]; then
|
||||
warn "Error: Apache configuration file not present for instance $name."
|
||||
else
|
||||
|
|
|
|||
|
|
@ -62,6 +62,14 @@ do
|
|||
if is_instance $name ; then
|
||||
if enable_instance $name; then
|
||||
restart_apache="yes"
|
||||
# Under systemd, re-enable the per-instance target that
|
||||
# koha-disable turned off and start the instance's units. (On
|
||||
# SysV the daemons come back with the next koha-common restart,
|
||||
# as before.)
|
||||
if [ "$(koha_init_backend)" = "systemd" ]; then
|
||||
systemctl enable "koha@${name}.target" 2>/dev/null || true
|
||||
systemctl start "koha@${name}.target" 2>/dev/null || true
|
||||
fi
|
||||
else
|
||||
warn "Instance $name already enabled."
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -73,34 +73,31 @@ FLUSH PRIVILEGES;
|
|||
eof
|
||||
fi #`
|
||||
|
||||
# Stop the Zebra server if needed
|
||||
# Stop the instance's daemons if needed, and disable them regardless:
|
||||
# under systemd a stopped-but-enabled unit would otherwise leave its
|
||||
# symlink behind in koha@<instance>.target.wants/.
|
||||
if is_zebra_running $name; then
|
||||
koha-zebra --stop $name || /bin/true
|
||||
koha-zebra --disable $name || /bin/true
|
||||
fi
|
||||
# Stop the indexer daemon if needed
|
||||
koha-zebra --disable $name || /bin/true
|
||||
if is_indexer_running $name; then
|
||||
koha-indexer --stop $name || /bin/true
|
||||
koha-indexer --disable $name || /bin/true
|
||||
fi
|
||||
# Stop the worker daemons if needed
|
||||
koha-indexer --disable $name || /bin/true
|
||||
koha-worker --all-queues --stop $name || /bin/true
|
||||
koha-worker --all-queues --disable $name || /bin/true
|
||||
# Stop the Plack server if needed
|
||||
if is_plack_running $name; then
|
||||
koha-plack --stop $name || /bin/true
|
||||
koha-plack --disable $name || /bin/true
|
||||
fi
|
||||
# Stop the SIP server if needed
|
||||
koha-plack --disable $name || /bin/true
|
||||
if is_sip_running $name; then
|
||||
koha-sip --stop $name || /bin/true
|
||||
koha-sip --disable $name || /bin/true
|
||||
fi
|
||||
# Stop the ES indexing daemon if needed
|
||||
koha-sip --disable $name || /bin/true
|
||||
if is_es_indexer_running $name; then
|
||||
koha-es-indexer --stop $name || /bin/true
|
||||
koha-es-indexer --disable $name || /bin/true
|
||||
fi
|
||||
koha-es-indexer --disable $name || /bin/true
|
||||
|
||||
# Under systemd, disable the per-instance target and create-dirs
|
||||
# oneshot so we don't leave dangling symlinks under
|
||||
|
|
|
|||
Loading…
Reference in New Issue