<ask>
<title>Customize the automatic installation</title>
<dialog config:type=”integer”>1</dialog>
<element config:type=”integer”>1</element>
<!– remove direct assignment and use script instead
<pathlist config:type=”list”>
<path>networking,dns,hostname</path>
</pathlist>
//–>
<question>Enter Hostname (server name)</question>
<stage>initial</stage>
<default>linux</default>
<script>
<feedback config:type=”boolean”>true</feedback>
<rerun_on_error config:type=”boolean”>true</rerun_on_error>
<environment config:type=”boolean”>true</environment>
<debug config:type=”boolean”>true</debug>
<filename>my-host.sh</filename>
<source>
<![CDATA[
#!/bin/bash
HOSTNAME=$VAL
sed -e “s/%%HOSTNAME%%/$HOSTNAME/g”
-e “/^s*<ask-list/,/ask-list>$/d”
/tmp/profile/autoinst.xml > /tmp/profile/modified.xml
]]>
</source>
</script>
</ask>… <dns>
<dhcp_hostname config:type=”boolean”>true</dhcp_hostname>
<domain>example.suse.de</domain>
<hostname>%%HOSTNAME%%</hostname>
—snap—
“%%HOSTNAME%%” is used as placeholder within the XML to fill in asked results.
$HOSTNAME is assigned the $VAL and used by sed command to replace and create the modified.xml.
To process 2 asks or more you need to run a script for each.
Note, # and ## work from the left end (beginning) of string,
# % and %% work from the right end.
Another example with several ask:
….
<ask-list config:type=”list”>
<!– BEGIN Dialog 20 – Network –>
<ask>
<title>Customize your network settings</title>
<dialog config:type=”integer”>20</dialog>
<element config:type=”integer”>1</element>
<width config:type=”integer”>70</width>
<height config:type=”integer”>20</height>
<help><![CDATA[
<p><b>Hostname</b><br>Enter a hostname without the domain part.</p>
]]></help>
<pathlist config:type=”list”>
<path>networking,dns,hostname</path>
</pathlist>
<file>/tmp/may_q_hostname</file>
<question>Hostname</question>
<stage>initial</stage>
<default>linuxbox</default>
<script>
<filename>my_host.sh</filename>
<rerun_on_error config:type=”boolean”>true</rerun_on_error>
<environment config:type=”boolean”>true</environment>
<source><![CDATA[
HOSTNAME=$VAL
sed -e “s/%%HOSTNAME%%/$HOSTNAME/g”
/tmp/profile/autoinst.xml >/tmp/profile/modified.xml
]]></source>
<debug config:type=”boolean”>false</debug>
<feedback config:type=”boolean”>true</feedback>
</script>
</ask>
<ask>
<dialog config:type=”integer”>30</dialog>
<element config:type=”integer”>1</element>
<help><![CDATA[
<p><b>Network Domain</b><br>Enter the domain for your network.</p>
]]></help>
<pathlist config:type=”list”>
<path>networking,dns,domain</path>
</pathlist>
<file>/tmp/may_q_dnsdomain</file>
<question>Network Domain</question>
<stage>initial</stage>
<default>example.com</default>
<script>
<filename>my_host.sh</filename>
<rerun_on_error config:type=”boolean”>true</rerun_on_error>
<environment config:type=”boolean”>true</environment>
<source><![CDATA[
DOMAIN=$VAL
sed -i -e “s/%%DOMAIN%%/$DOMAIN/g”
/tmp/profile/modified.xml
]]></source>
<debug config:type=”boolean”>false</debug>
<feedback config:type=”boolean”>true</feedback>
</script>
</ask>
<ask>
<dialog config:type=”integer”>30</dialog>
<element config:type=”integer”>2</element>
<help><![CDATA[
<p><b>IP Address</b><br>Enter a free IP address for this host.</p>
]]></help>
<pathlist config:type=”list”>
<path>networking,interfaces,3,ipaddr</path>
</pathlist>
<file>/tmp/may_q_ip_addr</file>
<question>IP Address</question>
<stage>initial</stage>
<default>10.0.0.20</default>
<script>
<filename>my_ip.sh</filename>
<rerun_on_error config:type=”boolean”>true</rerun_on_error>
<environment config:type=”boolean”>true</environment>
<source><![CDATA[
IPADDR=$VAL
sed -i -e “s/%%IPADDR%%/$IPADDR/g”
-e “/^s*<ask-list/,/ask-list>$/d”
/tmp/profile/modified.xml
]]></source>
<debug config:type=”boolean”>false</debug>
<feedback config:type=”boolean”>true</feedback>
</script>
</ask>
</ask-list>
…..
<host>
<hosts config:type=”list”>
<hosts_entry>
<host_address>127.0.0.1</host_address>
<names config:type=”list”>
<name>localhost</name>
</names>
</hosts_entry>
<hosts_entry>
<host_address>%%IPADDR%%</host_address>
<names config:type=”list”>
<name>%%HOSTNAME%%.%%DOMAIN%% %%HOSTNAME%%</name>
</names>
</hosts_entry>
<hosts_entry>
<host_address>::1</host_address>
<names config:type=”list”>
<name>localhost ipv6-localhost ipv6-loopback</name>
</names>
</hosts_entry>
<hosts_entry>
<host_address>fe00::0</host_address>
<names config:type=”list”>
<name>ipv6-localnet</name>
</names>
</hosts_entry>
<hosts_entry>
<host_address>ff00::0</host_address>
<names config:type=”list”>
<name>ipv6-mcastprefix</name>
</names>
</hosts_entry>
<hosts_entry>
<host_address>ff02::1</host_address>
<names config:type=”list”>
<name>ipv6-allnodes</name>
</names>
</hosts_entry>
<hosts_entry>
<host_address>ff02::2</host_address>
<names config:type=”list”>
<name>ipv6-allrouters</name>
</names>
</hosts_entry>
<hosts_entry>
<host_address>ff02::3</host_address>
<names config:type=”list”>
<name>ipv6-allhosts</name>
</names>
</hosts_entry>
</hosts>
</host>