diff --git a/debian/scripts/koha-create b/debian/scripts/koha-create index 22961df400..69780f9006 100755 --- a/debian/scripts/koha-create +++ b/debian/scripts/koha-create @@ -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 diff --git a/debian/scripts/koha-disable b/debian/scripts/koha-disable index 64c9bb0074..ca78e4b919 100755 --- a/debian/scripts/koha-disable +++ b/debian/scripts/koha-disable @@ -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 diff --git a/debian/scripts/koha-enable b/debian/scripts/koha-enable index 4aef82849d..8dda6c2938 100755 --- a/debian/scripts/koha-enable +++ b/debian/scripts/koha-enable @@ -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 diff --git a/debian/scripts/koha-remove b/debian/scripts/koha-remove index 24426b5865..93eda68807 100755 --- a/debian/scripts/koha-remove +++ b/debian/scripts/koha-remove @@ -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@.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