Installing Kiwix packages and service in Raspberry Pi and Debian installer scripts.

This commit is contained in:
Roland 2023-07-11 08:29:17 -06:00
parent 0eb321de9f
commit 1fff928d4e
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
11 changed files with 134 additions and 8 deletions

View file

@ -108,6 +108,11 @@ class KiwixZimDownloader(Downloader):
else:
background_task(refresh_files([output_path, ]))
# Restart Kiwix serve, so it finds the new zim file.
return_code = await lib.restart_kiwix()
if return_code != 0:
logger.error(f'Failed to restart kiwix')
# Location is just the generic Kiwix viewer.
return DownloadResult(success=True, location='/zim')

View file

@ -482,3 +482,19 @@ def flag_kiwix_restart():
flags.kiwix_restart.set()
else:
logger.debug(f'Not setting kiwix_restart flag because this is not Dockerized')
async def restart_kiwix():
if DOCKERIZED:
logger.warning('Unable to restart Kiwix serve because it is in a docker container')
return
logger.info('Restarting Kiwix serve')
cmd = f'sudo /usr/bin/systemctl restart wrolpi-kiwix.service'
proc = await asyncio.create_subprocess_shell(cmd)
stdout, stderr = await proc.communicate()
logger.debug(f'systemctl returned {proc.returncode}')
if proc.returncode != 0 and stderr:
logger.debug(stderr)
return proc.returncode