/** * Add a KickstartScript to the KickstartData * * @param ksIn to add */ public void addScript(KickstartScript ksIn) { // The ordering goes: Pre scripts and post (chroot) scripts have // positive positions, post nochroot scripts have negative // positions where the most negative script is run right before // Red Hat's scripts. The user can adjust these default positions // later, but this allows us to preserve previous behavor where // adding a nochroot post script added it right before Red Hat's // post scripts and adding a post (chroot) script added it as the // last script that runs. if (ksIn.getScriptType().equals(KickstartScript.TYPE_POST) && !ksIn.thisScriptIsChroot()) { Long minPosition = 0L; for (KickstartScript script : scripts) { if (script.getPosition() < minPosition) { minPosition = script.getPosition(); } } ksIn.setPosition(minPosition - 1); } else { Long maxPosition = 0L; for (KickstartScript script : scripts) { if (script.getPosition() > maxPosition) { maxPosition = script.getPosition(); } } ksIn.setPosition(maxPosition + 1); } ksIn.setKsdata(this); scripts.add(ksIn); }
private KickstartScript lookupScriptByType(String typeIn) { if (this.getScripts() != null && this.getScripts().size() > 0) { Iterator<KickstartScript> i = this.getScripts().iterator(); while (i.hasNext()) { KickstartScript kss = i.next(); if (kss.getScriptType().equals(typeIn)) { return kss; } } } return null; }