sys-unconfig not the all powerful tool I thought it was

So I was working with a customer the other day setting up a template in OVM to use as a gold image.  The last step we took was to run sys-unconfig to wipe out all traces of the networking we had set up.  I used to think this basically wipes out all aspects of a systems configuration, silly me!  On my Oracle Linux 6.4 box, sys-unconfig is a script.  I thought this tool did a lot more, but here is the entire contents of the script:

 

#!/bin/sh

. /etc/init.d/functions

if [ $# -ne 0 ]; then
    echo $"Usage: sys-unconfig" >&2
    exit 1
fi

touch /.unconfigured
rm -f /etc/udev/rules.d/*-persistent-*.rules
halt

On system boot, if /.unconfigured exists, /etc/rc.sysinit does the following:

# Configure machine if necessary.
if [ -f /.unconfigured ]; then

    if [ -x /bin/plymouth ]; then
        /bin/plymouth quit
    fi

    if [ -x /usr/bin/system-config-keyboard ]; then
        /usr/bin/system-config-keyboard
    fi
    if [ -x /usr/bin/passwd ]; then
        /usr/bin/passwd root
    fi
    if [ -x /usr/sbin/system-config-network-tui ]; then
        /usr/sbin/system-config-network-tui
    fi
    if [ -x /usr/sbin/timeconfig ]; then
        /usr/sbin/timeconfig
    fi
    if [ -x /usr/sbin/authconfig-tui ]; then
        /usr/sbin/authconfig-tui --nostart
    fi
    if [ -x /usr/sbin/ntsysv ]; then
        /usr/sbin/ntsysv --level 35
    fi

    # Reread in network configuration data.
    if [ -f /etc/sysconfig/network ]; then
        . /etc/sysconfig/network

        # Reset the hostname.
        action $"Resetting hostname ${HOSTNAME}: " hostname ${HOSTNAME}
    fi

    rm -f /.unconfigured
fi

If you don’t implicitly configure any networking the previous configuration would remain.  This could be a bad thing if you rebooted the machine and skipped the setup- it would come up with the same IP and possibly cause issues on the network.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s