Ask the User for Values during Installation

This feature is only available since SUSE Linux 10.1 and SLES10.

You have the option to let the user decide the values of specific parts of the profile during the installation. If you use this feature, a popup will ask the user to enter a specific part of the profile during installation. If you want a full auto installation, but the user should set the password of the local account, you can do this via the ask directive in the profile.

The following elements must be between the <ask-list config:type="list"><ask> ... </ask></ask-list> tags in the <general> section.

Table 4.6. XML representation

Element

Description

Comment

question

The question you want to ask the user.

<question>Enter the LDAP server</question>

The default value is the path to the element (the path often looks strange, so we recommend to enter a question)

default

Set a pre-selection for the user. A textentry will be filled out with this value. A checkbox will be "true" or "false" and a selection will have this default "value" pre-selected.

<default>dc=suse,dc=de</default>

Optional.

help

An optional helptext that is shown on the left side of the question.

<help>Enter the LDAP server address.</help>

Optional.

title

An optional title that is shown above the questions.

<title>LDAP server</title>

Optional.

type

The type of the element you want to change. Possible values are "symbol","boolean","string" and "integer". The filesystem in the partition section is a symbol, while the "encrypted" element in the user configuration is a boolean. You can see the type of that element if you look in your profile at the config:type="...." attribute. Since openSUSE 11.2 and SLES11-SP2 you can use "static_text" as type too. A static_text is just a text that does not require any user input and can be used to show information if it's not wanted in the help text.

<type>symbol</type>

Optional. The defaul is string. If type is "symbol", you must provide the selection element too (see below).

password

If this boolean is set to "true", a password dialog pops up instead of a simple text entry. Setting this to "true" makes only sense if "type" is string.

<password config:type="boolean">true</password>

Optional. The default is "false".

path (deprecated since openSUSE 11.0 - use pathlist)

deprecated

deprecated

deprecated

pathlist (available since openSUSE 11.0 and replaces path)

A list of path elements. A path is a comma seperated list of elements that describes the path to the element you want to change. For example, the ldap server element can be found in the profile in the <ldap><ldap_server> section. So if you want to change that value, you have to set the path to "ldap,ldap_server". If you want to change the password of the first user in the profile, you have to set the path to "users,0,user_password". The "0" indicates the first user in the <users config:type="list"> list of users in the profile.

<pathlist config:type="list"
><path>networking,dns,hostname</path>
<path>...</path>

This information is optional but you should at least provide path or file.

file (available since SLES10 SP1 and SL 10.2)

You can store the answer to a question in a file, to use it in one of your scripts later. If you ask during stage=inital and you want to use the answer in stage2, then you have to copy the answer-file in a chroot script that is running as chrooted=false. Use the commnad: "cp /tmp/my_answer /mnt/tmp/". The reason is that /tmp in stage1 is just in the RAM disk and will get lost after the reboot, but the installed system is already mounted at /mnt/.

<file>/tmp/answer_hostname</file>

This information is optional, but you should at least provide path or file

password

If this boolean is set to "true", a password dialog pops up instead of a simple text entry. Setting this to "true" makes only sense if "type" is string.

<password config:type="boolean">true</password>

Optional. The default is "false".

stage

Stage configures the installation stage in which the question pops up. You can set this value to "cont" or "initial". "initial" means the popup comes up very early in the installation, shortly after the pre-script has run. "cont" means, that the dialog with the question comes after the first reboot when the system boots for the very first time. Questions you answer during the "inital" stage, will write their answer into the profile on the harddisk. You should know that if you enter cleartext passwords during "initial". Of course it does not make sense to ask for the filesystem to use during the "cont" phase. The harddisk is already partitioned at that stage and the question will have no effect.

<stage>cont</stage>

Optional. The default is "initial".

selection

The selection element contains a list of <entry> elements. Each entry represents a possible option for the user to choose. The user cannot enter a value in a textfield, but he can choose from a list of values.

<selection config:type="list">
  <entry>
    <value>
        reiser
    </value>
    <label>
        Reiser Filesystem
    </label>
  </entry>
  <entry>
    <value>
        ext3
    </value>
    <label>
        Extended3 Filesystem
    </label>
  </entry>
</selection>

Optional for type=string, not possible for type=boolean and mandatory for type=symbol.

dialog (available since SL 10.3 and SLES10 SP2)

you can ask more than one question per dialog. To do so, specifiy the dialog-id with an integer. All questions with the same dialog-id belong to the same dialog. The dialogs are sorted by the id too.

<dialog config:type="integer">3</dialog>

Optional.

element (available since SL 10.3 and SLES10 SP2)

you can have more than one question per dialog. To make that possible you have to specifiy the element-id with an integer. The questions in a dialog are sorted by id.

<element config:type="integer">1</element>

Optional (see dialog>.

frametitle (available since SL 10.3 and SLES10 SP2)

you can have more than one question per dialog. Each question on a dialog has a frame that can have a frame title, a small caption for each question. You can put multiple elements into one frame. They have to have the same frame title.

<frametitle>User data</frametitle>

Optional. Default is no frame title.

script (available since SL 10.3, not in SLES10 SP1)

Since 10.3, you can run scripts after a question has been answered (see the table below for detailed instructions about scripts).

<script>...</script>

optional (default is no script)

ok_label (available since openSUSE 11.2 and SLES11 SP2

You can change the label on the "Ok" button. The last element that specifies the label for a dialog wins.

<ok_label>Finish</ok_label>

Optional.

back_label (available since openSUSE 11.2 and SLES11 SP2

You can change the label on the "Back" button. The last element that specifies the label for a dialog wins.

<back_label>change values</back_label>

Optional.

timeout (available since openSUSE 11.2 and SLES11-SP2

You can specify an integer here that is used as timeout in seconds. If the user does not answer the question before the timeout, the default value is taken as answer. When the user touches or changes any widget in the dialog, the timeout is turned off and the dialog has to be confirmed via the ok-button.

<timeout config:type="integer">30</timeout>

Optional. A missing value is interpreted as 0, which means that there is no timeout.

default_value_script (available since openSUSE 11.2 and SLES11-SP2)

You can run scripts to set the default value for a question (see the table below for detailed instructions about default value scripts). This feature is useful if you can "calculate" a useful default value, especially in combination with the "timeout" option.

<default_value_script>...</default_value_script>

Optional. Default is no script.


The following elements must be between the <ask-list config:type="list"><ask><default_value_script>...</default_value_script>...</ask></ask-list> tags in the <general> section. This is available since 11.2 and SLES11-SP2.

Table 4.7. XML representation

Element

Description

Comment

source

The source code of the script. Whatever you echo to STDOUT will be used as default value for the ask-dialog. If your script has an exit code other than 0, the normal default element is used. Take care you use echo -n to suppress the \n and that you echo reasonable values and not "okay" for a boolean

<source>...</source>

This value is required, otherwise nothing would be executed.

interpreter

The interpreter to use.

<interpreter>perl</interpreter>

The default is shell. You can also set "/bin/myinterpreter" as value.


The following elements must be between the <ask-list config:type="list"><ask><script>...</script>...</ask></ask-list> tags in the <general> section. Available since 10.3 (not SLES10 SP1).

Table 4.8. XML representation

Element

Description

Comment

filename

The filename of the script.

<filename>my_ask_script.sh</filename>

The default is ask_script.sh

source

The source code of the script. Together with "rerun_on_error" activated, you check the value that was entered for sanity (since 11.0 only). Your script can create a file "/tmp/next_dialog" with a dialog id specifying the next dialog AutoYaST will raise. A value of -1 terminates the ask sequence. If that file is not created, AutoYaST will run the dialogs in the normal order (since 11.0 only).

<source>...</source>

This value is required, otherwise nothing would be executed.

environment

A boolean that passes the "value" of the answer to the question as an environment variable to the script. The variable is named "VAL".

<environment config:type="boolean">true</environment>

Optional. Default is "false".

feedback

A boolean that turns on feedback for the script execution. STDOUT will be displayed in a popup window that must be confirmed after the script execution.

<feedback config:type="boolean">true</feedback>

Optional, default is "false".

debug

A boolean that turns on debugging for the script execution.

<debug config:type="boolean">true</debug>

Optional, default is "true". This value needs "feedback" to be turned on too.

rerun_on_error

A boolean that keeps the dialog open until the script has an exit code of 0 (zero). So you can parse and check the answers the user gave in the script and display an error with the "feedback" option.

<rerun_on_error config:type="boolean">true</rerun_on_error>

Optional, default is "false". This value should be used together with the feedback option.


Below you can see an example of the usage of the "ask" feature.

<general>
  <ask-list config:type="list">
      <ask>
          <!-- deprecated since openSUSE 11.0; use pathlist instead
          <path>ldap,ldap_server</path>
          -->
          <pathlist config:type="list">
              <path>ldap,ldap_server</path>
          </pathlist>
          <stage>cont</stage>
          <help>choose your server depending on your department</help>
          <selection config:type="list">
              <entry>
                      <value>ldap1.mydom.de</value>
                      <label>LDAP for development</label>
              </entry>
              <entry>
                      <value>ldap2.mydom.de</value>
                      <label>LDAP for sales</label>
              </entry>
          </selection>
          <default>ldap2.mydom.de</default>
          <default_value_script>
              <source> <![CDATA[
echo -n "ldap1.mydom.de"
]]>
              </source>
          </default_value_script>
      </ask>
      <ask>
          <!-- deprecated since openSUSE 11.0; use pathlist instead
          <path>networking,dns,hostname</path>
          -->
          <pathlist config:type="list">
              <path>networking,dns,hostname</path>
          </pathlist>
          <question>Enter Hostname</question>
          <stage>initial</stage>
          <default>enter your hostname here</default>
      </ask>
      <ask>
          <!-- deprecated since openSUSE 11.0; use pathlist instead
          <path>partitioning,0,partitions,0,filesystem</path>
          -->
          <pathlist config:type="list">
              <path>partitioning,0,partitions,0,filesystem</path>
          </pathlist>
          <question>Filesystem</question>
          <type>symbol</type>
          <selection config:type="list">
              <entry>
                      <value config:type="symbol">reiser</value>
                      <label>default Filesystem (recommended)</label>
              </entry>
              <entry>
                      <value config:type="symbol">ext3</value>
                      <label>Fallback Filesystem</label>
              </entry>
          </selection>

      </ask>
  </ask-list>
  ...
</general>

The following example is a nice way to choose between AutoYaST profiles. AutoYaST will read the modified.xml file again after the ask-dialogs are done. This way you can fetch a complete new profile.

<ask>
        <selection config:type="list">
            <entry>
                    <value>part1.xml</value>
                    <label>Simple partitioning</label>
            </entry>
            <entry>
                    <value>part2.xml</value>
                    <label>encrypted /tmp</label>
            </entry>
            <entry>
                    <value>part3.xml</value>
                    <label>LVM</label>
            </entry>
        </selection>
        <title>XML Profile</title>
        <question>Choose a profile</question>
        <stage>initial</stage>
        <default>part1.xml</default>
        <script>
            <filename>fetch.sh</filename>
            <environment config:type="boolean">true</environment>
            <source><![CDATA[
wget http://10.10.0.162/$VAL -O /tmp/profile/modified.xml 2>/dev/null
]]>
            </source>
            <debug config:type="boolean">false</debug>
            <feedback config:type="boolean">false</feedback>
        </script>
      </ask>

you can verify the answer of a question with a script like this:

<ask>
          <script>
            <filename>my.sh</filename>
            <rerun_on_error config:type="boolean">true</rerun_on_error>
            <environment config:type="boolean">true</environment>
            <source><![CDATA[
if [ "$VAL" = "myhost" ]; then
    echo "Illegal Hostname!";
    exit 1;
fi
exit 0
]]>
            </source>
            <debug config:type="boolean">false</debug>
            <feedback config:type="boolean">true</feedback>
          </script>
          <dialog config:type="integer">0</dialog>
          <element config:type="integer">0</element>
          <!-- deprecated since openSUSE 11.0; use pathlist instead
          <path>networking,dns,hostname</path>
          -->
          <pathlist config:type="list">
              <path>networking,dns,hostname</path>
          </pathlist>
          <question>Enter Hostname</question>
          <default>enter your hostname here</default>
      </ask>