update_manager: make system updates optional
Remove the "distro" config option as it is not necessary. If there is a need to identify the linux distribution that can now be done through the distro dependency. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
7c56a8fa74
commit
627db24c63
|
@ -1,14 +1,14 @@
|
||||||
# Supplemental configuration for Moonraker's Update Manager
|
# Supplemental configuration for Moonraker's Update Manager
|
||||||
# component. This file should not be modified.
|
# component. This file should not be modified.
|
||||||
|
|
||||||
[update_manager static debian moonraker]
|
[update_manager moonraker]
|
||||||
origin: https://github.com/arksine/moonraker.git
|
origin: https://github.com/arksine/moonraker.git
|
||||||
requirements: scripts/moonraker-requirements.txt
|
requirements: scripts/moonraker-requirements.txt
|
||||||
venv_args: -p python3
|
venv_args: -p python3
|
||||||
install_script: scripts/install-moonraker.sh
|
install_script: scripts/install-moonraker.sh
|
||||||
|
|
||||||
|
|
||||||
[update_manager static debian klipper]
|
[update_manager klipper]
|
||||||
origin: https://github.com/kevinoconnor/klipper.git
|
origin: https://github.com/kevinoconnor/klipper.git
|
||||||
requirements: scripts/klippy-requirements.txt
|
requirements: scripts/klippy-requirements.txt
|
||||||
venv_args: -p python2
|
venv_args: -p python2
|
||||||
|
|
|
@ -50,7 +50,6 @@ MOONRAKER_PATH = os.path.normpath(os.path.join(
|
||||||
SUPPLEMENTAL_CFG_PATH = os.path.join(
|
SUPPLEMENTAL_CFG_PATH = os.path.join(
|
||||||
os.path.dirname(__file__), "update_manager.conf")
|
os.path.dirname(__file__), "update_manager.conf")
|
||||||
APT_CMD = "sudo DEBIAN_FRONTEND=noninteractive apt-get"
|
APT_CMD = "sudo DEBIAN_FRONTEND=noninteractive apt-get"
|
||||||
SUPPORTED_DISTROS = ["debian"]
|
|
||||||
|
|
||||||
# Check To see if Updates are necessary each hour
|
# Check To see if Updates are necessary each hour
|
||||||
UPDATE_REFRESH_INTERVAL_MS = 3600000
|
UPDATE_REFRESH_INTERVAL_MS = 3600000
|
||||||
|
@ -65,17 +64,16 @@ class UpdateManager:
|
||||||
self.config = config
|
self.config = config
|
||||||
self.config.read_supplemental_config(SUPPLEMENTAL_CFG_PATH)
|
self.config.read_supplemental_config(SUPPLEMENTAL_CFG_PATH)
|
||||||
auto_refresh_enabled = config.getboolean('enable_auto_refresh', False)
|
auto_refresh_enabled = config.getboolean('enable_auto_refresh', False)
|
||||||
self.distro = config.get('distro', "debian").lower()
|
enable_sys_updates = config.get('enable_system_updates', True)
|
||||||
if self.distro not in SUPPORTED_DISTROS:
|
|
||||||
raise config.error(f"Unsupported distro: {self.distro}")
|
|
||||||
self.cmd_helper = CommandHelper(config)
|
self.cmd_helper = CommandHelper(config)
|
||||||
env = sys.executable
|
env = sys.executable
|
||||||
mooncfg = self.config[f"update_manager static {self.distro} moonraker"]
|
mooncfg = self.config[f"update_manager moonraker"]
|
||||||
self.updaters: Dict[str, BaseUpdater] = {
|
self.updaters: Dict[str, BaseUpdater] = {
|
||||||
"system": PackageUpdater(config, self.cmd_helper),
|
|
||||||
"moonraker": GitUpdater(mooncfg, self.cmd_helper,
|
"moonraker": GitUpdater(mooncfg, self.cmd_helper,
|
||||||
MOONRAKER_PATH, env)
|
MOONRAKER_PATH, env)
|
||||||
}
|
}
|
||||||
|
if enable_sys_updates:
|
||||||
|
self.updaters['system'] = PackageUpdater(config, self.cmd_helper)
|
||||||
# TODO: The below check may be removed when invalid config options
|
# TODO: The below check may be removed when invalid config options
|
||||||
# raise a config error.
|
# raise a config error.
|
||||||
if config.get("client_repo", None) is not None or \
|
if config.get("client_repo", None) is not None or \
|
||||||
|
@ -84,8 +82,7 @@ class UpdateManager:
|
||||||
"The deprecated 'client_repo' and 'client_path' options\n"
|
"The deprecated 'client_repo' and 'client_path' options\n"
|
||||||
"have been removed. See Moonraker's configuration docs\n"
|
"have been removed. See Moonraker's configuration docs\n"
|
||||||
"for details on client configuration.")
|
"for details on client configuration.")
|
||||||
client_sections = self.config.get_prefix_sections(
|
client_sections = self.config.get_prefix_sections("update_manager")
|
||||||
"update_manager client")
|
|
||||||
for section in client_sections:
|
for section in client_sections:
|
||||||
cfg = self.config[section]
|
cfg = self.config[section]
|
||||||
name = section.split()[-1]
|
name = section.split()[-1]
|
||||||
|
@ -171,7 +168,7 @@ class UpdateManager:
|
||||||
kupdater.env == env:
|
kupdater.env == env:
|
||||||
# Current Klipper Updater is valid
|
# Current Klipper Updater is valid
|
||||||
return
|
return
|
||||||
kcfg = self.config[f"update_manager static {self.distro} klipper"]
|
kcfg = self.config[f"update_manager klipper"]
|
||||||
need_notification = "klipper" not in self.updaters
|
need_notification = "klipper" not in self.updaters
|
||||||
self.updaters['klipper'] = GitUpdater(kcfg, self.cmd_helper, kpath, env)
|
self.updaters['klipper'] = GitUpdater(kcfg, self.cmd_helper, kpath, env)
|
||||||
async with self.cmd_request_lock:
|
async with self.cmd_request_lock:
|
||||||
|
@ -531,6 +528,9 @@ class CommandHelper:
|
||||||
self.server.send_event(
|
self.server.send_event(
|
||||||
"update_manager:update_response", notification)
|
"update_manager:update_response", notification)
|
||||||
|
|
||||||
|
def get_system_update_command(self):
|
||||||
|
return APT_CMD
|
||||||
|
|
||||||
def close(self) -> None:
|
def close(self) -> None:
|
||||||
self.http_client.close()
|
self.http_client.close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue