upgrades: Disable searx during dist-upgrade

Avoid high CPU usage due to uwsgi continuously restarting before searx
config is upgraded.

Helps #1644.

Tests: Ran dist-upgrade for each case:

- Without searx installed -> no log messages related to searx.

- With searx installed but not enabled -> searx config is upgraded.

- With searx installed and enabled -> searx is disabled, later config
  is upgraded, and searx is re-enabled. Searx page can be accessed at
  the end.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
James Valleroy 2021-02-20 09:29:32 -05:00 committed by Veiko Aasa
parent 826b20c1d9
commit db993ecb16
No known key found for this signature in database
GPG Key ID: 478539CAE680674E

View File

@ -420,6 +420,16 @@ def _perform_dist_upgrade():
print('Snapshots are not supported, skip taking a snapshot.',
flush=True)
# If searx is enabled, disable it until we can upgrade it properly.
searx_is_enabled = pathlib.Path(
'/etc/uwsgi/apps-enabled/searx.ini').exists()
if searx_is_enabled:
print('Disabling searx...', flush=True)
subprocess.run([
'/usr/share/plinth/actions/apache', 'uwsgi-disable', '--name',
'searx'
], check=True)
# Hold freedombox package during entire dist upgrade.
print('Holding freedombox package...', flush=True)
with apt_hold():
@ -462,6 +472,12 @@ def _perform_dist_upgrade():
print('Updating searx search engines list...', flush=True)
subprocess.run(['/usr/share/plinth/actions/searx', 'setup'],
check=True)
if searx_is_enabled:
print('Re-enabling searx after upgrade...', flush=True)
subprocess.run([
'/usr/share/plinth/actions/apache', 'uwsgi-enable',
'--name', 'searx'
], check=True)
print('Running apt autoremove...', flush=True)
run_apt_command(['autoremove'])