For the case you have a template and just want to change a few things via script or command line, you can use a XSLT processor like sablot for this. Lets say you have an autoyast profile and you want to fillout the hostname via script for any reason (maybe because you have to do it so often, you want to script it)
First you have to create an XSL file
Example 3.1. Example file for replacing hostname/domain by script
<?xml version="1.0" encoding="utf-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:y2="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns" xmlns="http://www.suse.com/1.0/yast2ns" version="1.0"> <xsl:output method="xml" encoding="UTF-8" indent="yes" omit-xml-declaration="no" cdata-section-elements="source"/> <!-- the parameter names --> <xsl:param name="hostname"/> <xsl:param name="domain"/> <xsl:template match="/"> <xsl:apply-templates select="@*|node()"/> </xsl:template> <xsl:template match="y2:dns"> <xsl:copy> <!-- where to copy the parameters --> <domain><xsl:value-of select="string($domain)"/></domain> <hostname><xsl:value-of select="string($hostname)"/></hostname> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> <xsl:template match="@*|node()" > <xsl:copy> <xsl:apply-templates select="@*|node()"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
As you can see, this file expects the "hostname" and the "domain" as parameters from the user.
<xsl:param name="hostname"/> <xsl:param name="domain"/>
There will be a "copy" of those parameters in the "dns" section of the control file. That means, if there already is a domain element in the dns section, you'll get a second one (no good).
If you want to create a new autoyast profile now from the template plus the XSL file, run the following command:
sabcmd add_hostname.xsl \$hostname=myHost \$domain=my.domain template.xml
You'll get a filled out autoyast profile then on STDOUT.
If you have multiple XSL files you want to apply to a template, do it like this
sabcmd add_hd_vg.xsl \$device=/dev/sda \$partition=p2 \$vg=system \ | sabcmd add_harddisk.xsl \$device=/dev/system \$lvm=true \ | sabcmd .... | sabcmd add_hostname.xsl \$hostname=myHost \$domain=my.domain
So you just pipe the output of each sabcmd to the next sabcmd.
For more information aout XSLT, go to the official webpage www.w3.org/TR/xslt