diff --git a/src/Resources/command/SettingsCommand.py b/src/Resources/command/SettingsCommand.py index f4aeea4d..e1b0e0d5 100644 --- a/src/Resources/command/SettingsCommand.py +++ b/src/Resources/command/SettingsCommand.py @@ -362,7 +362,35 @@ def __init__(self): ) ) - enable_ipv6_item = SubmenuItem(enable_ipv6_string, enable_ipv6_menu, menu) + enable_ipv6_item = SubmenuItem( + enable_ipv6_string, enable_ipv6_menu, menu) + + # Windows WLS2 Option + win_wls2_string = "(**Windows only**) Enable WLS2 Support" + win_wls2_menu = SelectionMenu(strings=[], + title=win_wls2_string, + subtitle=current_bool("win_wls2"), + formatter=menu_formatter, + prologue_text="""This option is used only on Windows OS. + Enables the support for Docker using WLS2. + Default is %s.""" % format_bool( + DEFAULTS['win_wls2']) + ) + + win_wls2_menu.append_item(FunctionItem(text="Yes", + function=self.set_setting_value, + args=['win_wls2', True], + should_exit=True + ) + ) + win_wls2_menu.append_item(FunctionItem(text="No", + function=self.set_setting_value, + args=['win_wls2', False], + should_exit=True + ) + ) + + win_wls2_item = SubmenuItem(win_wls2_string, win_wls2_menu, menu) menu.append_item(submenu_item) menu.append_item(manager_item) @@ -375,6 +403,7 @@ def __init__(self): menu.append_item(debug_level_item) menu.append_item(print_startup_log_item) menu.append_item(enable_ipv6_item) + menu.append_item(win_wls2_item) self.menu = menu diff --git a/src/Resources/manager/docker/DockerPlugin.py b/src/Resources/manager/docker/DockerPlugin.py index 0386fbeb..16291f43 100644 --- a/src/Resources/manager/docker/DockerPlugin.py +++ b/src/Resources/manager/docker/DockerPlugin.py @@ -4,6 +4,7 @@ from ... import utils from ...os.Networking import Networking +from ...setting.Setting import Setting PLUGIN_NAME = "kathara/katharanp" BUSTER_TAG = "buster" @@ -22,9 +23,13 @@ def _select_plugin_name_linux(): return "%s:%s" % (PLUGIN_NAME, BUSTER_TAG) if 'nf_tables' in iptables_version else \ "%s:%s" % (PLUGIN_NAME, STRETCH_TAG) - self.plugin_name = utils.exec_by_platform(_select_plugin_name_linux, - lambda: "%s:%s" % (PLUGIN_NAME, BUSTER_TAG), - lambda: "%s:%s" % (PLUGIN_NAME, BUSTER_TAG) + def _select_plugin_name_windows(): + return "%s:%s" % (PLUGIN_NAME, STRETCH_TAG) if Setting.get_instance().win_wls2 else \ + "%s:%s" % (PLUGIN_NAME, BUSTER_TAG) + + self.plugin_name = utils.exec_by_platform(_select_plugin_name_linux, _select_plugin_name_windows, + lambda: "%s:%s" % ( + PLUGIN_NAME, BUSTER_TAG) ) def check_and_download_plugin(self): diff --git a/src/Resources/setting/Setting.py b/src/Resources/setting/Setting.py index 84ac492f..e30b122d 100644 --- a/src/Resources/setting/Setting.py +++ b/src/Resources/setting/Setting.py @@ -29,14 +29,15 @@ "device_prefix": 'kathara', "debug_level": 'INFO', "print_startup_log": True, - "enable_ipv6": False + "enable_ipv6": False, + "win_wls2": False } class Setting(object): __slots__ = ['image', 'manager_type', 'terminal', 'open_terminals', 'hosthome_mount', 'shared_mount', 'device_shell', 'net_prefix', 'device_prefix', 'debug_level', - 'print_startup_log', 'enable_ipv6', 'last_checked'] + 'print_startup_log', 'enable_ipv6', 'last_checked', 'win_wls2'] __instance = None @@ -209,5 +210,6 @@ def _to_dict(self): "debug_level": self.debug_level, "print_startup_log": self.print_startup_log, "last_checked": self.last_checked, - "enable_ipv6": self.enable_ipv6 + "enable_ipv6": self.enable_ipv6, + "win_wls2": self.win_wls2 }