Custom ISO With Post Installation Scripts

Home » CentOS » Custom ISO With Post Installation Scripts
CentOS 6 Comments

Dear All

I have been working on a custom ISO with kickstart and a couple of post installation scripts and would like to have the script run before the login prompt.

The custom ISO works; however, the scripts fails because some of the services, e.g. mariadb does not start before the server installation has been completed and rebooted; therefore, I have been putting the scripts in /etc/profile.d/ and after logging in the scripts will execute and upon completion of the script will be deleted from
/etc/profile.d/.

DuckDuckGo suggested that I copy the script to /etc/rc.d/rc.local and make it executable; however, I have tried that a few times and the script simply does not execute.

Below is an excerpt from the ks.cfg.

export SRCDIR=”/run/install/repo”
export DSTDIR=”/mnt/sysimage”

# copy scripts to the destintion of the server cp -v $SRCDIR/postinstall/script1.sh
$DSTDIR/etc/rc.d/rc.local/script1.sh

# Make scripts executable chmod +x $DSTDIR/etc/rc.d/rc.local.sh

Since this is a ISO for a community project, don’t think that tools such as Ansible, Chef, Puppet, etc. will work here.

Also, it is a one time execution; therefore, I did not consider using systemd because the goal would be to have visibility while the script is running just as I see after I login; however, just need the script to be executed after the OS was installed and restarted and before the login prompt.

All suggestions are welcome.

Thanks in advance.

6 thoughts on - Custom ISO With Post Installation Scripts

  • are you sure about this line? rc.local must be a file, not a directory.

    best regards Ulf

  • Thanks Ulf

    That was a typo on the email

    cp -v $SRCDIR/postinstall/snipeit.sh $DSTDIR/etc/rc.d/rc.local

    # Make scripts executable chmod +x $DSTDIR/etc/rc.d/rc.local

  • If your distro is using systemd then rc.local will not get executed by default. Enable rc-local.service : “systemctl enable rc-local.service”.

    Regards, Prasad

  • Thanks, Prasad

    I tried that and unfortunately, that service did not start after the server was rebooted; therefore the script was not called by systemd-rc-local-generator.

    Will continue to investigate and report back

  • Hmm…

    I am doing this with a KS for C7 and my /etc/rc.d/rc.local script get executed just fine on boot up without doing anything other than putting it in /etc/rc.d/

    # ls -al /etc/rc.d/
    total 72
    drwxr-xr-x 10 root root 4096 May 18 07:37 . drwxr-xr-x 121 root root 12288 Jun 8 08:19 .. drwxr-xr-x 2 root root 4096 May 18 15:06 init.d drwxr-xr-x 2 root root 4096 May 18 14:56 rc0.d drwxr-xr-x 2 root root 4096 May 18 14:56 rc1.d drwxr-xr-x 2 root root 4096 May 24 10:21 rc2.d drwxr-xr-x 2 root root 4096 May 24 10:21 rc3.d drwxr-xr-x 2 root root 4096 May 24 10:21 rc4.d drwxr-xr-x 2 root root 4096 May 24 10:21 rc5.d drwxr-xr-x 2 root root 4096 May 18 14:56 rc6.d
    -rwxr-xr-x 1 root wheel 20080 May 18 09:14 rc.local

  • A little investigation shows that the problem was with the script that is supposed to execute, I used a simple script and it worked, actually the problem was #!/bin/bash was on the second line and not the first, bit embarrassing but glad that it is working.

    Thanks, guys.