Custom User Scripts

By adding scripts to the auto-installation process you can customize the installation according to your needs and take control in different stages of the installation.

In the auto-installation process, five types of scripts can be executed and they will be described here in order of "appearance" during the installation.

All scripts have to be in the <scritps> section.

Pre-Install Scripts

Executed before YaST does any real change to the system (before partitioning and package installation but after the hardware detection).

You can use a pre-script to modify your profile and let AutoYaST reread it. Find your profile in "/tmp/profile/autoinst.xml". Adjust the file and store the modified version in "/tmp/profile/modified.xml". AutoYaST will read the modified file after the pre-script finishes.

With SUSE Linux 10.0 and all later versions, it is possible to change the partitioning with fdisk in your pre-script. With pre-10.0 versions of SUSE Linux (like SLES9), this was not possible.

[Note]Pre-Install Scripts with Confirmation

Pre-scripts are executed at an early stage of the installation. This means if you have requested to confirm the installation, the pre-scripts will be executed before the confirmation screen shows up (profile/install/general/mode/confirm).

The following elements must be between the <scripts><pre-scripts config:type="list"><script> ... </script></pre-scripts>...</scripts> tags.

Table 4.1. Pre-script XML Representation

Element

Description

Comment

location

Define a location from where the script gets fetched. Locations can be the same as for the profile (http, ftp, nfs, etc.).

<location
>http://10.10.0.1/myPreScript.sh</location>

Either <location> or <source> must be defined.

source

The script itself (source code), encapsulated in a CDATA tag. If you do not want to put the whole shell script into the XML profile, refer to the location parameter.

<source>
<![CDATA[ 
echo "Testing the pre script" > /tmp/pre-script_out.txt 
]]>
</source>

Either <location> or <source> must be defined.

interpreter

Specify the interpreter that must be used for the script. Supported options are shell and perl.

<interpreter>perl</interpreter>

Optional (default is "shell").

filename

The filename of the script. It will be stored in a temporary directory under /tmp/...

<filename>myPreScript5.sh</filename>

Optional. Default is the type of the script (pre-scripts in this case). If you have more than one script, you should set the filename to a reasonable value.

feedback

If this boolean is "true", stdout and stderr of the script will be shown in a popup, which the user has to confirm via the OK button. If stdout and stderr are empty, no popup is shown and therefore no confirmation is needed.

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

Optional, default is "false". This option was introduced with SL 10.1/SLES10.

feedback_type

This can be "message", "warning" or "error". Set the timeout for these popups in the <report> section.

<feedback_type>warning</feedback_type>

Optional, if missing, an always blocking popup is used. This option was introduced with openSUSE 11.2 (not SLES11).

debug

If this is "true", every single line of a shell script is logged. Perl scripts are run with warnings turned on.

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

Optional, default is "true". This option was introduced with SL 10.1/SLES10.

notification

This text will be shown in a popup for the time the script is running in the background.

<notification>Please wait while script is running...</notification>

Optional, if not configured, no notification popup will be shown. This option was introduced with openSUSE 11.3/SLES11 SP2 (not SLES10).

rerun

A script is only run once. Even if you use ayast_setup to run a XML file multiple times, the script is only run once. Change this default behavior by setting this boolean to "true".

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

Optional, default is "false" (scripts only run once).


Postpartitioning Scripts

[Note]Note

Available since openSUSE 11.2 only (not SLES11).

Executed after YaST has done the partitioning and written the fstab. The empty system is mounted to /mnt already.

The following elements must be between the <scripts><postpartitioning-scripts config:type="list"><script> ... </script></postpartitioning-scripts>...</scripts> tags

Table 4.2. Postpartitioning Script XML Representation

Element

Description

Comment

location

Define a location from where the script gets fetched. Locations can be the same as for the profile (http, ftp, nfs, etc.).

<location
>http://10.10.0.1/myScript.sh</location>

Either <location> or <source> must be defined.

source

The script itself (source code), encapsulated in a CDATA tag. If you don't want to put the whole shell script into the XML profile, refer to the location parameter.

<source>
<![CDATA[ 
echo "Testing postpart script" > /mnt/postpart_test.txt
]]>
</source>

Either <location> or <source> must be defined.

interpreter

The interpreter that must be used for the script. Supported options are shell and perl.

<interpreter>perl</interpreter>

Optional, default is "shell".

filename

The filename of the script. It will be stored in a temporary directory under /tmp/...

<filename>myScript5.sh</filename>

Optional, default is the type of the script (postpartitioning-scripts in this case). If you have more than one script, set the filename to a reasonable value.

feedback

If this boolean is "true", stdout and stderr of the script will be shown in a popup, which the user has to confirm via the OK button. If stdout and stderr are empty, no popup is shown and therefore no confirmation is needed.

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

Optional, the default is "false". This option was introduced with SL 10.1/SLES10.

feedback_type

This can be "message", "warning" or "error". Set the timeout for these popups in the <report> section.

<feedback_type>warning</feedback_type>

Optional, if missing, an always blocking popup is used. This option was introduced with openSUSE 11.2 (not SLES11).

debug

If this is "true", every single line of a shell script is logged. Perl scripts are run with warnings turned on.

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

Optional, default is "true". This option was added with SL 10.1/SLES10.

notification

This text will be shown in a popup for the time the script is running in the background.

<notification>Please wait while script is running...</notification>

Optional, if not configured, no notification popup will be shown. This option was added with openSUSE 11.3/SLES11 SP2 (not SLES10).

rerun

A script is only run once. Even if you use ayast_setup to run a XML file multiple times, the script is only run once. Set this boolean to "true" if you want to change this default behavior.

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

Optional, default is false (scripts only run once).


Chroot Environment Scripts

Chroot scripts are executed before the machine reboots for the first time. You can execute chroot scripts before the installation chroots into the installed system and configures the boot loader or you can execute a script after the chroot into the installed system has happened (look at the "chrooted" parameter for that).

The following elements must be between the <scripts><chroot-scripts config:type="list"><script> ... </script></chroot-scripts>...</scripts> tags

Table 4.3. Chroot Script XML Representation

Element

Description

Comment

location

Define a location from where the script gets fetched. Locations can be the same as for the profile (http, ftp, nfs, etc.).

<location
>http://10.10.0.1/myChrootScript.sh</location>

Either <location> or <source> must be defined.

source

The script itself (source code), encapsulated in a CDATA tag. If you do not want to put the whole shell script into the XML profile, use the location parameter.

<source>
<![CDATA[
echo "Testing the chroot script" >
/tmp/chroot_out.txt
]]>
</source>

Either <location> or <source> must be defined.

chrooted

This value can be "true" or "false". If set to "false", the installed system remains mounted at "/mnt" and no chroot happens. The bootloader is not installed either at this stage. Set to "true" means, a chroot into /mnt is performed, where the installed system is mounted. The bootloader is installed, and if you want to change anything in the installed system, you don't have to use the "/mnt/" prefix anymore.

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

Optional, default is "false".

interpreter

The interpreter that must be used for the script. Supported options are shell and perl. If you are in a chrooted=true condition, you can also use python if installed.

<interpreter>perl</interpreter>

Optional, default is shell.

filename

The filename of the script. It will be stored in a temporary directory under /tmp/...

<filename>myPreScript5.sh</filename>

Optional, default is the type of the script (chroot-scripts in this case). If you have more than one script, you should set the filename to a reasonable value.

feedback

If this boolean is "true", stdout and stderr of the script will be shown in a popup, which the user has to confirm via the OK button. If stdout and stderr are empty, no popup is shown and therefore no confirmation is needed.

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

Optional, default is "false". This option was added with SL 10.1/SLES10.

feedback_type

This can be "message", "warning" or "error". Set the timeout for these popups in the <report> section.

<feedback_type>warning</feedback_type>

Optional, if missing, an always blocking popup is used. This option was introduced with openSUSE 11.2 (not SLES11).

debug

If this is true, every single line of a shell script is logged. Perl scripts are run with warnings turned on.

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

Optional, default is "true". This option was added with SL 10.1/SLES10.

notification

This text will be shown in a popup for the time the script is running in the background.

<notification>Please wait while script is running...</notification>

Optional, if not configured, no notification popup will be shown. This option was added with openSUSE 11.3/SLES11 SP2 (not SLES10).

rerun

A script is only run once. Even if you use ayast_setup to run a XML file multiple times, the script is only run once. You can change the default behavior by setting this boolean to "true".

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

Optional, default is "false" (scripts only run once).


Post-Install Scripts

These scripts are executed after AutoYaST has completed the system configuration and after it has booted the system for the first time.

It is possible to execute post scripts in an earlier phase while the installation network is still up and before AutoYaST configures the system. To run network-enabled post scripts, the boolean property network_needed has to be set to "true".

The following elements must be between the <scripts><post-scripts config:type="list"><script> ... </script></post-scripts>...</scripts> tags.

Table 4.4. Post Script XML Representation

Element

Description

Comment

location

Define a location from where the script gets fetched. Locations can be the same as for the profile (http, ftp, nfs, etc.).

<location
>http://10.10.0.1/myPostScript.sh</location>

Either <location> or <source> must be defined.

source

The script itself (source code), encapsulated in a CDATA tag. If you do not want to put the whole shell script into the XML profile, use the location parameter.

<source>
<![CDATA[ 
echo "Testing the chroot script" >
/tmp/chroot_out.txt 
]]>
</source>

Either <location> or <source> must be defined.

network_needed

This value can be "true" or "false". On "false" the script will run after the YaST modules like the user configuration and everything else are done. The network is configured but not up and running yet. With this value set to "true", the script runs before all YaST modules are configured. So there is no local user and no network is configured but the installation network is still up and running (if you did a network installation).

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

Optional, default is "false".

interpreter

The interpreter that must be used for the script. Supported options are shell, perl and python if installed.

<interpreter>perl</interpreter>

Optional, default is shell.

filename

The filename of the script. It will be stored in a temporary directory under /tmp/...

<filename>myPostScript5.sh</filename>

Optional, default is the type of the script (post-scripts in this case). If you have more than one script, set the filename to a reasonable value.

feedback

If this boolean is "true", stdout and stderr of the script will be shown in a popup, which the user has to confirm via the OK button. If stdout and stderr are empty, no popup is shown and therefore no confirmation is needed.

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

Optional, default is "false". This option was added with SL 10.1/SLES10.

feedback_type

This can be "message", "warning" or "error". Set the timeout for these popups in the <report> section.

<feedback_type>warning</feedback_type>

Optional, if missing, an always blocking popup is used. This option was added with openSUSE 11.2 (not SLES11).

debug

If this is "true", every single line of a shell script is logged. Perl scripts are run with warnings turned on.

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

Optional, default is "true". This option was added with SL 10.1/SLES10.

notification

This text will be shown in a popup for the time the script is running in the background.

<notification>Please wait while script is running...</notification>

Optional, if not configured, no notification popup will be shown. This option was introduced with openSUSE 11.3/SLES11 SP2 (not SLES10).

rerun

A script is only run once. Even if you use ayast_setup to run a XML file multiple times, the script is only run once. Change this default behavior by setting this boolean to "true".

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

Optional, default is "false" (scripts only run once).


Init Scripts

These scripts are executed when YaST has finished, during the initial boot process after the network has been initialized. These final scripts are executed using a special init.d script executed only once.

Init scripts are configured using the tag init-scripts and are run using the special purpose init.d script /etc/init.d/autoyast.

The following elements must be between the <scripts><init-scripts config:type="list"><script> ... </script></init-scripts>...</scripts> tags

Table 4.5. Init script XML representation

Element

Description

Comment

location

Define a location from where the script gets fetched. Locations can be the same as for the profile (http, ftp, nfs, etc.).

<location
>http://10.10.0.1/myInitScript.sh</location>

Either <location> or <source> must be defined.

source

The script itself (source code), encapsulated in a CDATA tag. If you do not want to put the whole shell script into the XML profile, use the location parameter.

<source>
<![CDATA[ 
echo "Testing the init script" >
/tmp/init_out.txt 
]]>
</source>

Either <location> or <source> must be defined.

filename

The filename of the script. It will be stored in a temporary directory under /tmp/...

<filename>mynitScript5.sh</filename>

Optional, default is the type of the script (init-scripts in this case). If you have more than one script, set the filename to a reasonable value.

rerun

A script is only run once. Even if you use ayast_setup to run a XML file multiple times, the script is only run once. Change this default behavior by setting this boolean to "true".

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

Optional, default is "false" (scripts only run once).


When added to the control file manually, scripts have to be included in a CDATA element to avoid confusion with the file syntax and other tags defined in the control file.

Script Example

Example 4.32. Post Script Configuration

<?xml version="1.0"?>
<!DOCTYPE profile>
<profile xmlns="http://www.suse.com/1.0/yast2ns" xmlns:config="http://www.suse.com/1.0/configns">
        <scripts>
            <chroot-scripts config:type="list">
                <script>
                    <chrooted config:type="boolean">true</chrooted>
                    <filename>chroot.sh</filename>
                    <interpreter>shell</interpreter>
                    <source><![CDATA[
#!/bin/sh
echo "Testing chroot (chrooted) scripts"
ls
]]>                    
                    </source>
                </script>
                <script>
                    <filename>chroot.sh</filename>
                    <interpreter>shell</interpreter>
                    <source><![CDATA[
#!/bin/sh
echo "Testing chroot scripts"
df
cd /mnt
ls
]]>                    
                    </source>
                </script>
            </chroot-scripts>
            <post-scripts config:type="list">
                <script>
                    <filename>post.sh</filename>
                    <interpreter>shell</interpreter>
                    <source><![CDATA[
#!/bin/sh

echo "Running Post-install script"
/etc/init.d/portmap start
mount -a 192.168.1.1:/local /mnt
cp /mnt/test.sh /tmp
umount /mnt
]]>
                </source>
                </script>
                <script>
                    <filename>post.pl</filename>
                    <interpreter>perl</interpreter>
                    <source><![CDATA[
#!/usr/bin/perl
print "Running Post-install script";

]]>
                    </source>
                </script>
            </post-scripts>
            <pre-scripts config:type="list">
                <script>
                    <interpreter>shell</interpreter>
                    <location>http://192.168.1.1/profiles/scripts/prescripts.sh</location>
                </script>
                <script>
                    <filename>pre.sh</filename>
                    <interpreter>shell</interpreter>
                    <source><![CDATA[
#!/bin/sh
echo "Running pre-install script"
]]>
                    </source>
                </script>
            </pre-scripts>
            <postpartitioning-scripts config:type="list">
                <script>
                    <filename>postpart.sh</filename>
                    <interpreter>shell</interpreter>
                    <debug config:type="boolean">false</debug>
                    <feedback config:type="boolean">true</feedback>
                    <source><![CDATA[
touch /mnt/testfile
echo Hi
]]>
                    </source>
                </script>
            </postpartitioning-scripts>
        </scripts>
</profile>

After installation is finished, the scripts and the output logs can be found in the directory /var/adm/autoinstall. The scripts are located in the subdirectory scripts and the output logs in the log directory.

The log is the output when executing the shell scripts using the following command:

/bin/sh -x <script_name> 2&> /var/adm/autoinstall/logs/<script_name>.log