Sophie

Sophie

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

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

#!/bin/bash
#
# ovirt Start ovirt services
#
### BEGIN INIT INFO
# Provides: ovirt-post
# Required-Start: ovirt libvirtd
# Default-Start: 2 3 4 5
# Description: Performs managed node post configuration setup.
### END INIT INFO

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

prog=ovirt-post
VAR_SUBSYS_OVIRT_POST=/var/lock/subsys/$prog

start_ovirt_post() {
    # wait for libvirt to finish initializing
    local count=0
    while true; do
        if [ -r /var/run/libvirt/libvirt-sock-ro ]; then
            break
        elif [ "$count" == "100" ]; then
            log "Libvirt did not initialize in time..."
            return 1
        else
            log "Waiting for libvirt to finish initializing..."
            count=$(expr $count + 1)
            sleep 1
        fi

        touch $VAR_SUBSYS_OVIRT_POST

    done
    BACKUP=$(mktemp)
    ISSUE=/etc/issue
    ISSUE_NET=/etc/issue.net
    egrep -v "[Vv]irtualization hardware" $ISSUE > $BACKUP
    cp -f $BACKUP $ISSUE
    hwvirt=$(virsh --readonly capabilities)
    if [[ $hwvirt =~ kvm ]]; then
        log "Hardware virtualization detected"
    else
        log "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
        log "!!! Hardware Virtualization Is Unavailable !!!"
        log "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"

        echo "Virtualization hardware is unavailable." >> $ISSUE

        flags=$(cat /proc/cpuinfo | grep "^flags")
        if [[ $flags =~ vmx ]] || [[ $flags =~ svm ]]; then
            echo "(Virtualization hardware was detected but is disabled)" >> $ISSUE
        else
            echo "(No virtualization hardware was detected on this system)" >> $ISSUE
        fi
    fi
    if is_local_storage_configured; then
        echo "" >> $ISSUE
        echo "Please login as 'admin' to configure the node" >> $ISSUE
    fi
    cp -f $ISSUE $ISSUE_NET

    if is_standalone; then
        return 0
    fi

    # persist selected configuration files
    ovirt_store_config \
        /etc/krb5.conf \
        /etc/node.d \
        /etc/sysconfig/node-config
        /etc/libvirt/krb5.tab \
        /etc/ssh/ssh_host*_key*

    # perform any post startup operations
    case $OVIRT_RUNTIME_MODE in
    esac

    rm -f $VAR_SUBSYS_OVIRT_POST
}

stop_ovirt_post () {
    echo -n "Stopping ovirt-post: "
    success
}

reload_ovirt_post () {
    stop_ovirt_post
    start_ovirt_post
}

case "$1" in
    start)
        [ -f "$VAR_SUBSYS_OVIRT_POST" ] && exit 0
        echo -n "Starting ovirt-post: "

        {
            log "Starting ovirt-post"
            start_ovirt_post
            log "Completed ovirt-post"
        } >> $OVIRT_LOGFILE 2>&1

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