Kickstart partitioning stanzas - make optional?

yersinia yersinia.spiros at gmail.com
Thu Jul 24 10:22:56 UTC 2008


Just a pratical example - i have used it with RHEL5 - , there are many
document on this
*********************************************************
****** Begin kickstart
*********************************************************
# Use CDROM installation media
install
cdrom
reboot
monitor --noprobe
#platform=x86, AMD64, o Intel EM64T
# System authorization information
auth  --useshadow  --enablemd5
# System bootloader configuration
bootloader --location=mbr --driveorder=sda
--md5pass=$1$LTpksksk$tgrE3JE2fXT/gqvVMUJwz1
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --all --initlabel
......................
......................
timezone --isUtc Europe/London
# Network     #
%include /tmp/network.cfg      *<----------------------------------------*
# Disk Layout #
%include /tmp/disk.cfg           *<----------------------------------------*

%packages --nobase
@core
dbus
dbus-python
dbus-glib
hal
httpd
openldap-servers
openldap-clients
........................
........................

%pre  --interp /usr/bin/ash
PATH=/bin:/usr/bin:/sbin:/usr/sbin:$PATH

echo_user () {
        echo >/dev/tty "$@"
}

ask () {
        echo_user
        echo_user -n "$1 [$2] ? "
        read res </dev/tty
        [ -z "$res" ] && res="$2"

        if [ ."$res" = .'!' ]
        then
                echo_user
                echo_user "Starting interactive shell, type 'exit' when
done"
                sh </dev/tty >/dev/tty 2>&1
                # re-do the prompt
                ask "$@"
        else
                echo "$res"
        fi
}

confirm () {
        res=$(ask "$1 (y/n)" "$2")
        case "$res" in
        [yYjJ]*) true ;;
        *) false ;;
        esac
}

cmdline_val () {
        Res=$(cat /proc/cmdline | sed -n 's/.*'"$1"'=\([^ ]*\).*/\1/p')
        if [ -z "$Res" ]
        then
                echo "$2"
        else
                echo "$Res"
        fi
}

die () {
        echo_user "FATAL: $*"
        exit 1
}

gen_network() {
        echo -n "network --device $IFACE --bootproto static"
        [ ! -z "$IP"   ] && echo -n " --ip $IP"
        [ ! -z "$MASK" ] && echo -n " --netmask $MASK"

STTY_SAVE=$(stty -g </dev/tty)
stty sane </dev/tty
reset </dev/tty >/dev/tty || clear >/dev/tty

echo_user "*****************************************"
echo_user "*** EXAMPLE configuration kickstart ***"
echo_user "*****************************************"
echo_user " - Hope for the better ...........       "
echo_user "   and enjoy                             "
echo_user "*****************************************"
echo_user

Interactive="y"

if [ "$Interactive" ]
then
        while true
        do
            while [ -z "${NAME}"  ]
            do
             echo_user
                cat <<EOF >/dev/tty
*******************************************************
** This is the list of valid hostname : please pick one
** The dns domain is example.com
*******************************************************
example1
example2
EOF
                NAME=$(ask "Hostname (not fqdn qualified)" "$NAME")
                case "$NAME" in
                example1)
                cat <<EOF >/tmp/network.cfg
network --device eth0 --noipv6 --bootproto static --ip x.y.z.h --netmask
255.255.255.128 --nameserver 127.0.0.1 --hostname
EOF

cat <<EOF >/tmp/disk.cfg
clearpart --all --initlabel
part /boot --fstype ext3 --size 128
part swap --size=1024
part pv.3 --size 0  --grow --ondisk=sda
volgroup rootvg pv.3
logvol / --fstype ext3 --name=lv_root --vgname=rootvg --size=4096
logvol /home --fstype ext3 --name=lv_home --vgname=rootvg --size=1024
logvol /opt --fstype ext3 --name=lv_opt --vgname=rootvg --size=512
logvol /tmp --fstype ext3 --name=lv_tmp --vgname=rootvg --size=1024
logvol /var --fstype ext3 --name=lv_var --vgname=rootvg --size=1024
logvol /var/log --fstype ext3 --name=lv_var_log --vgname=rootvg --size=1024
logvol /var/tmp --fstype ext3 --name=lv_var_tmp --vgname=rootvg --size=1024
logvol /var/www --fstype ext3 --name=lv_var_www --vgname=rootvg --size=1024
logvol /var/log/audit --fstype ext3 --name=lv_audit --vgname=rootvg
--size=1024
EOF
                ;;
.........
.........  (for example2)

                *)
                clear >/dev/tty
                NAME=""
                ;;
                esac
               done
                echo_user
                echo_user "--------------------- WARNING
-------------------------------"
                echo_user "This is your last chance to stop the
installation. Continuing"
                echo_user "will erase the destination disk and install
noninteractively."
                echo_user "Answer 'n' if you need to reedit your settings."

else
        # noninteractive
        gen_network > /tmp/network.cfg
fi
# restore file descriptors and TTY
clear >/dev/tty
stty $STTY_SAVE </dev/tty
%post
(
.....
.....
)

***********************************************
It is an incomplete example, the dynamic part was for the network config,
but i think it could  be useful anyway

Regards

2008/7/24 Mogens Kjaer <mk at crc.dk>:

> yersinia wrote:
>
>> In kickstart it is simple ask the user in %pre, generate the file stanza
>> based on user request, and %include in kickstart the generate file stanza
>>
>
> How does one ask the user in %pre?
>
> Mogens
>
> --
> Mogens Kjaer, Carlsberg A/S, Computer Department
> Gamle Carlsberg Vej 10, DK-2500 Valby, Denmark
> Phone: +45 33 27 53 25, Fax: +45 33 27 47 08
> Email: mk at crc.dk Homepage: http://www.crc.dk
>
> --
> fedora-devel-list mailing list
> fedora-devel-list at redhat.com
> https://www.redhat.com/mailman/listinfo/fedora-devel-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/fedora-devel-list/attachments/20080724/a1a3a4be/attachment.htm>


More information about the fedora-devel-list mailing list