diff --git a/server/MANIFEST.in b/server/MANIFEST.in index fa52d9d1e..955baca41 100644 --- a/server/MANIFEST.in +++ b/server/MANIFEST.in @@ -2,4 +2,5 @@ include walt/server/processes/main/images/walt-* include walt/server/processes/main/network/walt-*.kpxe include walt/server/processes/main/vpn-proxy-setup.sh include walt/server/setup/*.service +include walt/server/setup/conmon.gz include walt/server/processes/blocking/snmp/mibs/*.mib diff --git a/server/walt/server/setup/conmon.gz b/server/walt/server/setup/conmon.gz new file mode 100644 index 000000000..fb42a60b0 Binary files /dev/null and b/server/walt/server/setup/conmon.gz differ diff --git a/server/walt/server/setup/ossetup.py b/server/walt/server/setup/ossetup.py index d196e9391..5e471845d 100644 --- a/server/walt/server/setup/ossetup.py +++ b/server/walt/server/setup/ossetup.py @@ -1,5 +1,6 @@ -import shlex, datetime, requests, subprocess, json, sys +import shlex, datetime, requests, subprocess, json, sys, gzip from pathlib import Path +from pkg_resources import resource_filename from walt.common.version import __version__ as WALT_VERSION from walt.server.setup.pip import install_pip, pip from walt.server.setup.apt import fix_dpkg_options, package_is_installed, get_debconf_selection, \ @@ -203,3 +204,29 @@ def install_os_on_image(): fix_docker_keyring() fix_dpkg_options() fix_packets(upgrade_packets = True) # have up-to-date packets on image + +def has_diversion(path): + diversion = subprocess.run(f'dpkg-divert --list {path}'.split(), + stdout=subprocess.PIPE).stdout.strip() + return len(diversion) > 0 + +def divert(path, diverted_path): + subprocess.run(f'dpkg-divert --divert {diverted_path} --rename {path}'.split(), + check=True, stdout=subprocess.PIPE) + +# 'conmon' binary distributed in bullseye has a serious issue +# causing possibly truncated stdout in podman [run|exec]). +# we replace it with a more up-to-date binary statically compiled +# using the nix-based method. +def fix_conmon(): + if not has_diversion('/usr/bin/conmon'): + print('Fixing issue with conmon tool... ', end=''); sys.stdout.flush() + divert('/usr/bin/conmon', '/usr/bin/conmon.distrib') + conmon_gz_path = resource_filename(__name__, 'conmon.gz') + conmon_gz_content = Path(conmon_gz_path).read_bytes() + conmon_content = gzip.decompress(conmon_gz_content) + conmon_fixed_path = Path('/usr/bin/conmon.fixed') + conmon_fixed_path.write_bytes(conmon_content) + conmon_fixed_path.chmod(0o755) + print('done') + Path('/usr/bin/conmon').symlink_to('/usr/bin/conmon.fixed') diff --git a/server/walt/server/setup/setup.py b/server/walt/server/setup/setup.py index 19dca1e6c..55e9e3683 100644 --- a/server/walt/server/setup/setup.py +++ b/server/walt/server/setup/setup.py @@ -4,7 +4,7 @@ from walt.common import systemd from walt.common.setup import WaltGenericSetup from walt.common.tools import verify_root_login_shell -from walt.server.setup.ossetup import get_os_codename, upgrade_os, install_os, fix_os, install_os_on_image +from walt.server.setup.ossetup import get_os_codename, upgrade_os, install_os, fix_os, fix_conmon, install_os_on_image from walt.server.setup.conf import fix_other_conf_files, setup_default_server_conf, ask_server_conf WALT_SERVICES = [ @@ -29,18 +29,18 @@ OS_ACTIONS = { 'image-install': { - 'bullseye': ('install_os_on_image', 'disable_os_services', 'setup_walt_services', + 'bullseye': ('install_os_on_image', 'fix_conmon', 'disable_os_services', 'setup_walt_services', 'fix_other_conf_files', 'setup_default_server_conf', 'update_completion'), }, 'install': { - 'bullseye': ('install_os', 'disable_os_services', 'setup_walt_services', + 'bullseye': ('install_os', 'fix_conmon', 'disable_os_services', 'setup_walt_services', 'fix_other_conf_files', 'ask_server_conf', 'systemd_reload', 'start_walt_services', 'update_completion', 'msg_ready'), }, 'upgrade': { - 'buster': ('stop_services', 'upgrade_os', 'disable_os_services', 'setup_walt_services', + 'buster': ('stop_services', 'upgrade_os', 'fix_conmon', 'disable_os_services', 'setup_walt_services', 'fix_other_conf_files', 'update_completion', 'msg_reboot'), - 'bullseye': ('stop_services', 'fix_os', 'disable_os_services', 'setup_walt_services', + 'bullseye': ('stop_services', 'fix_os', 'fix_conmon', 'disable_os_services', 'setup_walt_services', 'fix_other_conf_files', 'may_ask_server_conf', 'systemd_reload', 'start_walt_services', 'update_completion', 'msg_ready'), } @@ -135,6 +135,9 @@ def install_os(self): def fix_os(self): fix_os() + def fix_conmon(self): + fix_conmon() + def install_os_on_image(self): install_os_on_image()