Auto Install for Mandrake Linux
Prev Next

postInstall and postInstallNonRooted

This option provides the installer two simple methods for performing post installation activities on the installed system. You can use one or the other or both methods. If you want to use both, then the installer will execute the 'postInstallNonRooted' first, then the 'postInstall' last.

postInstall:

'postInstall' => '\"

echo "This is a test string" > /root/test.log

\"'

For this option, the install script is executed as root on the target computer with the environment set to that of the target computer. In other words, any references to the file system are relative to the target computers / (root). In addition, DrakX executes the script that you define using the form: chroot /mnt sh -c <yourscript here> (/mnt is the directory, in the DrakX environment, under which the entire file system for the target computer is located). This requires that the value assigned to 'postInstall' begin with a double quote (") and end with a double quote ("). See man bash for additional information. The reason for using sh is because in the target computer's environment, sh is a link to the shell defined as the system default shell (by the 'superuser' option for 'shell'). So make sure that the script you provide here is syntactically correct for the default shell.

postInstallNonRooted:

'postInstallNonRooted' => "\\\"

echo \"This is a test string\" > /mnt/root/test.log

\\\""

For this option, the install script is executed within the current environment of the DrakX install program. In other words, any references to the file system are relative to DrakX's / (root). In addition, DrakX executes the script that you define using the form: bash -c <yourscript here>. This requires that the value assigned to 'postInstallNonRooted' begin with a double quote (") and end with a double quote ("). See man bash for additional information. So make sure that the script you provide here is syntactically correct for the bash shell.

The above two examples produce the exact same result; the string, This is a test string is placed in a file called test.log located in the /root directory on the target computer. For the observant, there are a some other subtle differences. The use of a perl single-quote string literal (which allows only the \' and \\ escape-sequences) and the perl double-quote string literal (which allows backslash and variable interpolation). Either form can be used with either option, although the single-quote form is the easiest to follow and likely the most often used. In the double-quote form, the double-quote (") before and after the string This is a test string had to be 'escaped', otherwise the script would have terminated prematurely and as a consequence not be executed.

Examples:

The following are a simple set of examples which demonstrate the use of these options.

Change the default auto install run level from 5 to 3:

'postInstall' => '\"

# change run level from 5 to 3

cat /etc/inittab | sed \'s/^id:5:init/id:3:init/\' > /etc/inittab1

mv -f /etc/inittab1 /etc/inittab

\"'

Copy the auto install configuration file defined with the syslinux.cfg append parameter auto_install= to the target computers /root/drakx directory (this only works for NFS and CD-ROM source medias):

'postInstallNonRooted' => "\\\"

# copy the file from the source media

cp /tmp/image/$::auto_install /mnt/root/drakx/

\\\""

A little more complicated variation:

'postInstall' => '\"

# only if the NTP package is installed

if [ -f /etc/ntp.conf ]; then

cat <<EOF1 > /etc/ntp/step-tickers

time-server.eastcott.net

EOF1

fi


# clean up bug for Netscape

cat <<EOF2 >> /etc/skel/.bash_profile


# clean up old cache files, since Netscape doesn't

[ -d ~/.netscape ] && rm -rf ~/.netscape/cache/*


EOF2

\"'

NOTE: the EOF (or what you used for <<EOF) MUST begin in column 1 and be on a line by itself.

During the installation process, you can access a simple command line which is running in the installer's environment (ALT-F2). From there you can enter test commands to simulate those that would be executed when using the postInstallNonRooted method. The root ('/') directory of the system being installed is located in the directory '/mnt'. To create a file in the systems' /root directory, eg.:

echo "Hi there./n" > /mnt/root/test.log

If you use the 'chroot' command, you can simulate the postInstall's execution, eg.:

chroot /mnt "echo \"Hi there./n\" > /root/test.log"

One final note, if you selected 'autoExitInstall' => 0, then these two options do NOT get executed until AFTER you press the ENTER key at the end of the installation process.

Related Option Entries:

Depends on what all you installed.


PrevHome Next
partitions   printer