Select Your Language

Infrastructure and Management

Cloud Computing

Storage

Runtimes

Integration and Automation

  • Comments
  • Executing an external script during pre installation of kicstart

    Posted on

    Hi all,

    I'm trying to configure a kicstart + PXE server for a large deployment of servers with over 100 network segments.
    What I would like to achieve is that the user will choose at the PXE menu the required OS type (i.e RHEL, Ubuntu, etc) and version (i.e. RHEL 6.3, RHEL 5.8, etc) and this will initiate a kickstart installation process, during which a pre installation script will run and ask for certain network settings.

    So far, I have PXE and kickstart configured but I cannot get the pre installation part to work according to my needs.
    Initially I entered the code to the %pre section, including moving the user between consoles (exec and chat commands) and tested it. That worked.
    Here is what I had in %pre:

    %pre

    exec /dev/tty6 > /dev/tty6 2> /dev/tty6
    chvt 6

    !/bin/sh

    echo "Please select a network segmant from the following list:"
    echo "1. VLAN 01"
    echo "2. VLAN 02"
    ****Additional Networks****

    echo -n "Network: "
    read SEGMENT
    case ${SEGMENT} in
    1)
    SUBNET="255.255.255.0"
    GATEWAY="X.X.X.X"
    DNS="X.X.X.X,X.X.X.X"
    ;;
    2)
    SUBNET="255.255.255.0"
    GATEWAY="X.X.X.X"
    DNS="X.X.X.X,X.X.X.X"
    ;;
    ****Additional Networks****
    30)
    SUBNET="255.255.255.0"
    GATEWAY="X.X.X.X"
    DNS="X.X.X.X,X.X.X.X" ;;
    ;;
    esac

    echo -n "Please provide IP Address: "
    read IP

    clear
    echo -n "Please provide a hostname for this server: "
    read HOST

    echo "network --device=eth0 --bootproto=static --ip=${IP} --netmask=${NETMASK} --gateway=${GATEWAY} --nameserver=${DNS} --hostname=${HOST} --onboot=yes --noipv6" > /tmp/network-include

    chvt 1
    exec /dev/tty1 > /dev/tty1 2> /dev/tty1

    However, since I want to support multiple OS types and versions and multiple network segments, including the ability to seamlessly add versions and networks in the future, I wanted to direct the kickstart file to run a script during pre installation phase.

    This I could not get to work.

    I tried putting the script on an NFS share, mounting the share in %pre and running it in %pre.
    The script runs but the last chvt command fails with an error message of "command not found" and fails the entire installation process.
    This is my current %pre configuration:
    %pre

    exec /dev/tty6 > /dev/tty6 2> /dev/tty6
    chvt 6

    !/bin/sh

    mount -t nfs :/location/of/script /mnt
    /mnt/script.sh

    chvt 1
    exec /dev/tty1 > /dev/tty1 2> /dev/tty1

    I could not understand why I get this message, as it appears exactly where it was when all the network configuration code was hard coded in the kickstart file.

    Any help with this issue or advices regarding different approaches to this requirement would be much appreciated.
    Thanks,
    Yair

    by

    points

    Responses

    Red Hat LinkedIn YouTube Facebook X, formerly Twitter

    Quick Links

    Help

    Site Info

    Related Sites

    © 2026 Red Hat