diff --git a/scripts/distro.py b/scripts/distro.py index 046e327..1067be1 100644 --- a/scripts/distro.py +++ b/scripts/distro.py @@ -137,6 +137,8 @@ def distro(iso_cfg_ext_dir, iso_link): return 'grub2only' elif re.search(r'BOOT_IMAGE=rising', string, re.I): return 'rising-av' + elif re.search(r'Avira Rescue System', string, re.I): + return 'Avira-RS' distro = detect_iso_from_file_list(iso_link) diff --git a/scripts/grub.py b/scripts/grub.py index e9518da..58e7e09 100644 --- a/scripts/grub.py +++ b/scripts/grub.py @@ -106,13 +106,19 @@ def mbusb_update_grub_cfg(): def write_custom_gurb_cfg(): + """ + Create custom grub loopback.cfg file for known distros. Custom menu entries are stored on munus.py module + :return: + """ loopback_cfg_path = os.path.join(config.usb_mount, 'multibootusb', iso.iso_basename(config.image_path), 'loopback.cfg') + menu = False if config.distro == 'pc-tool': menu = menus.pc_tool_config(syslinux=False, grub=True) elif config.distro == 'rising-av': menu = menus.rising(syslinux=False, grub=True) - if menus: + if menu is not False: + gen.log('Writing custom loopback.cfg file...') write_to_file(loopback_cfg_path, menu) diff --git a/scripts/install.py b/scripts/install.py index f820011..292f289 100644 --- a/scripts/install.py +++ b/scripts/install.py @@ -97,6 +97,18 @@ def install_distro(): iso_extract_full(config.image_path, usb_mount) elif config.distro == 'grub4dos_iso' or config.distro == 'raw_iso': copy_iso(config.image_path, install_dir) + elif config.distro == 'Avira-RS': + iso_extract_full(config.image_path, install_dir) + # we want following directories on root of the USB drive. Ensure the previous directories are removed before moving. + if os.path.exists(os.path.join(usb_mount, 'antivir')): + shutil.rmtree(os.path.join(usb_mount, 'antivir')) + shutil.move(os.path.join(install_dir, 'antivir'), os.path.join(usb_mount)) + if os.path.exists(os.path.join(usb_mount, 'avupdate')): + shutil.rmtree(os.path.join(usb_mount, 'avupdate')) + shutil.move(os.path.join(install_dir, 'avupdate'), os.path.join(usb_mount)) + if os.path.exists(os.path.join(usb_mount, 'system')): + shutil.rmtree(os.path.join(usb_mount, 'system')) + shutil.move(os.path.join(install_dir, 'system'), os.path.join(usb_mount)) else: iso.iso_extract_full(config.image_path, install_dir) diff --git a/scripts/uninstall_distro.py b/scripts/uninstall_distro.py index 85f0a86..d07b84e 100644 --- a/scripts/uninstall_distro.py +++ b/scripts/uninstall_distro.py @@ -73,11 +73,14 @@ def delete_frm_file_list(): gen.log('Could not remove ldlinux.sys') if os.path.exists(os.path.join(usb_mount, f)): - if os.path.isfile(os.path.join(usb_mount, f)): - gen.log("Removing " + (os.path.join(usb_mount, f))) + if os.path.isdir(os.path.join(usb_mount, f)): + gen.log("Removing directory " + (os.path.join(usb_mount, f))) + shutil.rmtree(os.path.join(usb_mount, f)) + + elif os.path.isfile(os.path.join(usb_mount, f)): + gen.log("Removing file " + (os.path.join(usb_mount, f))) os.remove(os.path.join(usb_mount, f)) - elif os.path.isdir(os.path.join(usb_mount, f)): - shutil.rmtree(os.path.join(usb_mount, f)) + if os.path.exists(os.path.join(usb_mount, "multibootusb", config.uninstall_distro_dir_name, "generic.cfg")): with open(os.path.join(usb_mount, "multibootusb", config.uninstall_distro_dir_name, "generic.cfg"), "r") as generic_cfg: @@ -127,6 +130,7 @@ def uninstall_distro(): os.remove(os.path.join(usb_mount, config.uninstall_distro_dir_name + ".iso")) elif config.distro == "windows" or config.distro == "alpine" or config.distro == "generic": delete_frm_file_list() + if config.distro == "ipfire": files = os.listdir(usb_mount) for f in files: