RE: Terminate a CDROM install from %pre

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



OK, Here is the code from the kickstart.py file that acutally runs a script
(%pre or %post) in anaconda:

    def run(self, chroot, serial):
        scriptRoot = "/"
        if self.inChroot:
            scriptRoot = chroot

        path = scriptRoot + "/tmp/ks-script"

        f = open(path, "w")
        f.write(self.script)
        f.close()
        os.chmod(path, 0700)

        if serial:
            messages = "/tmp/ks-script.log"
        else:
            messages = "/dev/tty3"

        rc = iutil.execWithRedirect(self.interp,
                                    [self.interp,"/tmp/ks-script"],
                                    stdout = messages, stderr = messages,
                                    root = scriptRoot)

        if rc != 0:
            log("WARNING - Error code %s encountered running a kickstart
%%pre/%%post script"
, rc)

        os.unlink(path)

This code essentialy does the following:

     1) Write the script out to /tmp/ks-script or /tmp/ks-script in the
chrooted enviroment.
     2) Set  output from the script  to go to /dev/tty3 or in case of a
serial install to /tmp/ks-script.log.
     3) Run the written out script.
     4) Print a warning if an error was returned.
     5) Remove the script that was written out.

Note there is no return of the status of the script.  So there is the first
problem.

Now here is the code that actually calls the Script.run() methods for %pre
scripts:

        log("Running kickstart %%pre script(s)")
        for script in self.preScripts:
            script.run("/", self.serial)
        log("All kickstart %%pre script(s) have been run")

Note again, it does not check the return code and marches merrily along.
Now this bit of code is in
KickstartBase.setInstallData(), and I am not sure where it is called, but
probably it would need to return
an error to whatever called it, to get the thing to stop properly.  At
anyrate its easy to see that there was no
intention of even caring about return codes from %pre scripts (or %post
scripts for that matter), which I
thinks is the wrong thing to do, or at least there should be an option to
request it to do this, but in most
cases if the %pre goes bad, I don't want the install to continue.  In our
case when %pre goes bad
usually shortly there after anaconda goes completley off the rails and we
get a python exception.

cheers...james





[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux