Sophie

Sophie

distrib > Fedora > 16 > i386 > by-pkgid > d3dc5610bb3aa42f82734268acffc3b0 > files > 11

ovirt-node-2.0.0-1.fc16.noarch.rpm

#!/bin/bash
#
# ovirt-firstboot Puts the node into configuration mode.
#
# chkconfig: 2345 99 01
# description: ovirt-firstboot node configuration script
#
# Copyright (C) 2008 Red Hat, Inc.
# Written by Darryl L. Pierce <dpierce@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA  02110-1301, USA.  A copy of the GNU General Public License is
# also available at http://www.gnu.org/copyleft/gpl.html.

## Source functions library
. /etc/init.d/functions
. /usr/libexec/ovirt-functions

prog=ovirt-firstboot
VAR_SUBSYS_OVIRT_FIRSTBOOT=/var/lock/subsys/$prog

trap '__st=$?; stop_log; exit $__st' 0
trap 'exit $?' 1 2 13 15

autoinstall_failed(){
    log "Automatic installation failed. Please review console messages."
    log "Press Enter to drop to emergency shell."
    read < /dev/console
    bash < /dev/console
}

check_version(){
    if [ -e "/dev/HostVG/Root" ]; then
    log "                                          "
    log "   Major version upgrades are not allowed."
    log "   Please uninstall existing version and reinstall."
    log "   Press Enter to drop to emergency shell."
    read < /dev/console
    bash < /dev/console
    fi
}

start_ovirt_firstboot ()
{

    if ! is_firstboot && ! is_auto_install && ! is_upgrade && ! is_install; then
        return
    fi

    touch $VAR_SUBSYS_OVIRT_FIRSTBOOT
    /sbin/restorecon -e /var/lib/stateless/writable -e /data -e /config -e /proc -e /sys -rv / >> $OVIRT_TMP_LOGFILE 2>&1

    # Hide kernel messages on the console
    dmesg -n 1

    is_auto_install
    auto_install=$?
    if [ "$auto_install" = "0" ]; then
        /usr/libexec/ovirt-config-storage AUTO && \
        /usr/libexec/ovirt-config-hostname AUTO && \
        /usr/libexec/ovirt-config-networking AUTO && \
        /usr/libexec/ovirt-config-logging AUTO && \
        /usr/libexec/ovirt-config-password AUTO && \
        /usr/libexec/ovirt-config-snmp AUTO && \
        /usr/libexec/ovirt-config-rhn AUTO && \
        /usr/libexec/ovirt-config-kdump AUTO
        rc=$?
        # Handle Log file
        if [ -f $OVIRT_TMP_LOGFILE ]; then
            cat $OVIRT_TMP_LOGFILE >> $OVIRT_LOGFILE
            rm -f $OVIRT_TMP_LOGFILE
        fi
        if [ $rc -ne 0 ]; then
            autoinstall_failed
        fi
    elif [ "$auto_install" = "2" ]; then
        echo "Device specified in storage_init does not exist"
        autoinstall_failed
    fi

    if is_upgrade; then
        mount_live
        check_version
        /usr/libexec/ovirt-config-boot /live "$OVIRT_BOOTPARAMS" no
        if [ $? -ne 0 ]; then
            autoinstall_failed
        fi
        disable_firstboot
        ovirt_store_firstboot_config || autoinstall_failed
        reboot
        if [ $? -ne 0 ]; then
            autoinstall_failed
        fi
        return 1
    fi

    if is_firstboot || is_install ; then
        plymouth --hide-splash

        /usr/libexec/ovirt-config-installer -x < /dev/console

        plymouth --show-splash
    fi
    disable_firstboot

    ovirt_store_firstboot_config >> $OVIRT_LOGFILE 2>&1

    rm -f $VAR_SUBSYS_OVIRT_FIRSTBOOT
}

stop_ovirt_firstboot () {
    echo -n "Stopping ovirt-firstboot: "
    success
}

reload_ovirt_firstboot () {
    stop_ovirt_firstboot
    start_ovirt_firstboot
}

case "$1" in
    start)
        if is_managed; then
            exit 0
        fi

        printf "Starting ovirt-firstboot: "

        start_ovirt_firstboot

        test $? == 0 && success || failure
        echo
        ;;
    status)
        status $prog
        ;;
    reload)
        reload_ovirt_firstboot
        ;;
    stop)
        stop_ovirt_firstboot
        ;;
    *)
        echo "Usage: ovirt-firstboot {start}"
        exit 2
esac