def mount_root(self): """Mounts selected root and runs scripts.""" # mount root fs try: mount_existing_system(self._storage.fsset, self.root.device, read_only=self.ro) log.info("System has been mounted under: %s", iutil.getSysroot()) except StorageError as e: log.error("Mounting system under %s failed: %s", iutil.getSysroot(), e) self.status = RescueModeStatus.MOUNT_FAILED return False # turn on swap if not flags.imageInstall or not self.ro: try: self._storage.turn_on_swap() except StorageError: log.error("Error enabling swap.") # turn on selinux also if flags.selinux: # we have to catch the possible exception, because we # support read-only mounting try: fd = open("%s/.autorelabel" % iutil.getSysroot(), "w+") fd.close() except IOError as e: log.warning("Error turning on selinux: %s", e) # set a libpath to use mounted fs libdirs = os.environ.get("LD_LIBRARY_PATH", "").split(":") mounted = ["/mnt/sysimage%s" % ldir for ldir in libdirs] iutil.setenv("LD_LIBRARY_PATH", ":".join(libdirs + mounted)) # do we have bash? try: if os.access("/usr/bin/bash", os.R_OK): os.symlink("/usr/bin/bash", "/bin/bash") except OSError as e: log.error("Error symlinking bash: %s", e) # make resolv.conf in chroot if not self.ro: self._storage.make_mtab() try: makeResolvConf(iutil.getSysroot()) except (OSError, IOError) as e: log.error("Error making resolv.conf: %s", e) # create /etc/fstab in ramdisk so it's easier to work with RO mounted fs makeFStab() # run %post if we've mounted everything if not self.ro and self._scripts: runPostScripts(self._scripts) self.status = RescueModeStatus.MOUNTED return True
def mount_root(self): """Mounts selected root and runs scripts.""" # mount root fs try: mount_existing_system(self._storage.fsset, self.root.device, read_only=self.ro) log.info("System has been mounted under: %s", iutil.getSysroot()) except StorageError as e: log.error("Mounting system under %s failed: %s", iutil.getSysroot(), e) self.status = RescueModeStatus.MOUNT_FAILED return False # turn on swap if not flags.imageInstall or not self.ro: try: self._storage.turn_on_swap() except StorageError: log.error("Error enabling swap.") # turn on selinux also if flags.selinux: # we have to catch the possible exception, because we # support read-only mounting try: fd = open("%s/.autorelabel" % iutil.getSysroot(), "w+") fd.close() except IOError as e: log.warning("Error turning on selinux: %s", e) # set a libpath to use mounted fs libdirs = os.environ.get("LD_LIBRARY_PATH", "").split(":") mounted = ["/mnt/sysimage%s" % ldir for ldir in libdirs] iutil.setenv("LD_LIBRARY_PATH", ":".join(libdirs + mounted)) # do we have bash? try: if os.access("/usr/bin/bash", os.R_OK): os.symlink("/usr/bin/bash", "/bin/bash") except OSError as e: log.error("Error symlinking bash: %s", e) # make resolv.conf in chroot if not self.ro: self._storage.make_mtab() try: makeResolvConf(iutil.getSysroot()) except(OSError, IOError) as e: log.error("Error making resolv.conf: %s", e) # create /etc/fstab in ramdisk so it's easier to work with RO mounted fs makeFStab() # run %post if we've mounted everything if not self.ro and self._scripts: runPostScripts(self._scripts) self.status = RescueModeStatus.MOUNTED return True
def refresh(self, args=None): NormalTUISpoke.refresh(self, args) if self._root: try: mount_existing_system(self.storage.fsset, self._root.device, read_only=self.readOnly) if flags.automatedInstall: log.info("System has been mounted under: %s", iutil.getSysroot()) else: text = TextWidget( _("Your system has been mounted under %(mountpoint)s.\n\n" "If you would like to make the root of your system the " "root of the active system, run the command:\n\n" "\tchroot %(mountpoint)s\n") % {"mountpoint": iutil.getSysroot()}) self._window.append(text) rootmounted = True # now turn on swap if not flags.imageInstall or not self.readOnly: try: self.storage.turn_on_swap() except StorageError: log.error("Error enabling swap.") # turn on selinux also if flags.selinux: # we have to catch the possible exception, because we # support read-only mounting try: fd = open("%s/.autorelabel" % iutil.getSysroot(), "w+") fd.close() except IOError: log.warning("Cannot touch %s/.autorelabel", iutil.getSysroot()) # set a libpath to use mounted fs libdirs = os.environ.get("LD_LIBRARY_PATH", "").split(":") mounted = list( map(lambda dir: "/mnt/sysimage%s" % dir, libdirs)) iutil.setenv("LD_LIBRARY_PATH", ":".join(libdirs + mounted)) # do we have bash? try: if os.access("/usr/bin/bash", os.R_OK): os.symlink("/usr/bin/bash", "/bin/bash") except OSError: pass except (ValueError, LookupError, SyntaxError, NameError): pass except (OSError, StorageError) as e: if flags.automatedInstall: msg = _( "Run %s to unmount the system when you are finished.\n" ) % ANACONDA_CLEANUP text = TextWidget( _("An error occurred trying to mount some or all of " "your system. Some of it may be mounted under %s\n\n") + iutil.getSysroot() + msg) self._window.append(text) return True else: if flags.automatedInstall and self.data.reboot.action in [ KS_REBOOT, KS_SHUTDOWN ]: log.info("No Linux partitions found.") text = TextWidget( _("You don't have any Linux partitions. Rebooting.\n")) self._window.append(text) # should probably wait a few seconds to show the message time.sleep(5) iutil.execWithRedirect("systemctl", ["--no-wall", "reboot"]) else: if not flags.imageInstall: msg = _( "The system will reboot automatically when you exit" " from the shell.\n") else: msg = "" text = TextWidget( _("You don't have any Linux partitions. %s\n") % msg) self._window.append(text) return True if rootmounted and not self.readOnly: self.storage.make_mtab() try: makeResolvConf(iutil.getSysroot()) except (OSError, IOError) as e: log.error("Error making resolv.conf: %s", e) text = TextWidget( _("Your system is mounted under the %s directory.") % iutil.getSysroot()) self._window.append(text) # create /etc/fstab in ramdisk so it's easier to work with RO mounted fs makeFStab() # run %post if we've mounted everything if rootmounted and not self.readOnly and flags.automatedInstall: runPostScripts(self.data.scripts) return True
def refresh(self, args=None): NormalTUISpoke.refresh(self, args) if self._root: try: mount_existing_system(self.storage.fsset, self._root.device, read_only=self.readOnly) if flags.automatedInstall: log.info("System has been mounted under: %s", iutil.getSysroot()) else: text = TextWidget(_("Your system has been mounted under %(mountpoint)s.\n\nIf " "you would like to make your system the root " "environment, run the command:\n\n\tchroot %(mountpoint)s\n") % {"mountpoint": iutil.getSysroot()} ) self._window.append(text) rootmounted = True # now turn on swap if not flags.imageInstall or not self.readOnly: try: self.storage.turn_on_swap() except StorageError: log.error("Error enabling swap.") # turn on selinux also if flags.selinux: # we have to catch the possible exception, because we # support read-only mounting try: fd = open("%s/.autorelabel" % iutil.getSysroot(), "w+") fd.close() except IOError: log.warning("Cannot touch %s/.autorelabel", iutil.getSysroot()) # set a libpath to use mounted fs libdirs = os.environ.get("LD_LIBRARY_PATH", "").split(":") mounted = list(map(lambda dir: "/mnt/sysimage%s" % dir, libdirs)) iutil.setenv("LD_LIBRARY_PATH", ":".join(libdirs + mounted)) # do we have bash? try: if os.access("/usr/bin/bash", os.R_OK): os.symlink("/usr/bin/bash", "/bin/bash") except OSError: pass except (ValueError, LookupError, SyntaxError, NameError): pass except (OSError, StorageError) as e: if flags.automatedInstall: msg = _("Run %s to unmount the system when you are finished.\n") % ANACONDA_CLEANUP text = TextWidget(_("An error occurred trying to mount some or all of " "your system. Some of it may be mounted under %s\n\n") + iutil.getSysroot() + msg) self._window.append(text) return True else: if flags.automatedInstall and self.data.reboot.action in [KS_REBOOT, KS_SHUTDOWN]: log.info("No Linux partitions found.") text = TextWidget(_("You don't have any Linux partitions. Rebooting.\n")) self._window.append(text) # should probably wait a few seconds to show the message time.sleep(5) iutil.execWithRedirect("systemctl", ["--no-wall", "reboot"]) else: if not flags.imageInstall: msg = _("The system will reboot automatically when you exit" " from the shell.\n") else: msg = "" text = TextWidget(_("You don't have any Linux partitions. %s\n") % msg) self._window.append(text) return True if rootmounted and not self.readOnly: self.storage.make_mtab() try: makeResolvConf(iutil.getSysroot()) except(OSError, IOError) as e: log.error("Error making resolv.conf: %s", e) text = TextWidget(_("Your system is mounted under the %s directory.") % iutil.getSysroot()) self._window.append(text) # create /etc/fstab in ramdisk so it's easier to work with RO mounted fs makeFStab() # run %post if we've mounted everything if rootmounted and not self.readOnly and flags.automatedInstall: runPostScripts(self.data.scripts) return True