[Ovirt-devel] [PATCH] Remove managed node setup from ks %post and place into ovirt-managed-node RPM

Perry Myers pmyers at redhat.com
Mon Jun 30 16:53:34 UTC 2008


The only things left in %post are related to image minimization techniques,
white/blacklisting and munging /etc/passwd

Signed-off-by: Perry Myers <pmyers at redhat.com>
---
 ovirt-host-creator/common-post.ks                  |  358 +-------------------
 ovirt-managed-node/ovirt-managed-node.spec         |   79 ++++-
 ovirt-managed-node/src/scripts/collectd            |    1 +
 ovirt-managed-node/src/scripts/collectd.conf.in    |   23 ++
 ovirt-managed-node/src/scripts/dhclient-exit-hooks |    5 +
 ovirt-managed-node/src/scripts/kvm-ifup            |    5 +
 ovirt-managed-node/src/scripts/ovirt               |   51 +++
 ovirt-managed-node/src/{ => scripts}/ovirt-awake   |    0 
 ovirt-managed-node/src/scripts/ovirt-early         |  104 ++++++
 ovirt-managed-node/src/scripts/ovirt-functions     |   17 +
 ovirt-managed-node/src/scripts/ovirt-post          |   37 ++
 ovirt-managed-node/src/scripts/ovirt-setup         |   76 ++++
 12 files changed, 385 insertions(+), 371 deletions(-)
 create mode 100644 ovirt-managed-node/src/scripts/collectd
 create mode 100644 ovirt-managed-node/src/scripts/collectd.conf.in
 create mode 100755 ovirt-managed-node/src/scripts/dhclient-exit-hooks
 create mode 100755 ovirt-managed-node/src/scripts/kvm-ifup
 create mode 100755 ovirt-managed-node/src/scripts/ovirt
 rename ovirt-managed-node/src/{ => scripts}/ovirt-awake (100%)
 create mode 100755 ovirt-managed-node/src/scripts/ovirt-early
 create mode 100644 ovirt-managed-node/src/scripts/ovirt-functions
 create mode 100755 ovirt-managed-node/src/scripts/ovirt-post
 create mode 100755 ovirt-managed-node/src/scripts/ovirt-setup

diff --git a/ovirt-host-creator/common-post.ks b/ovirt-host-creator/common-post.ks
index c3bf35a..5709cac 100644
--- a/ovirt-host-creator/common-post.ks
+++ b/ovirt-host-creator/common-post.ks
@@ -1,363 +1,9 @@
+# -*-Shell-script-*-
+
 echo "Starting Kickstart Common Post"
 PATH=/sbin:/usr/sbin:/bin:/usr/bin
 export PATH
 
-echo "Setting up Networking"
-cat > /etc/sysconfig/iptables << \EOF
-*filter
-:INPUT ACCEPT [0:0]
-:FORWARD ACCEPT [0:0]
-:OUTPUT ACCEPT [0:0]
--A FORWARD -m physdev --physdev-is-bridged -j ACCEPT
-COMMIT
-EOF
-
-echo "Writing ovirt-functions script"
-# common functions
-cat > /etc/init.d/ovirt-functions << \EOF
-# -*-Shell-script-*-
-
-find_srv() {
-        local dnsreply
-        dnsreply=$(dig +short -t srv _$1._$2.$(dnsdomainname))
-        if [ $? -eq 0 ]; then
-            set _ $dnsreply; shift
-            SRV_HOST=$4; SRV_PORT=$3
-        else
-            SRV_HOST=; SRV_PORT=
-        fi
-}
-
-die()
-{
-  echo "$@" 1>&2; failure; echo 1>&2; exit 1
-}
-
-EOF
-
-echo "Writing ovirt-early init script"
-# next the dynamic bridge setup service
-cat > /etc/init.d/ovirt-early << \EOF
-#!/bin/bash
-#
-# ovirt-early Start early ovirt services
-#
-# chkconfig: 3 01 99
-# description: ovirt-early services
-#
-
-# Source functions library
-. /etc/init.d/functions
-. /etc/init.d/ovirt-functions
-
-configure_from_network() {
-    DEVICE=$1
-    if [ -n "$DEVICE" ]; then
-        printf .
-        # setup temporary interface to retrieve configuration
-        echo "network --device $DEVICE --bootproto dhcp" | nash
-        if [ $? -eq 0 ]; then
-            printf .
-            # from network-scripts/ifup-post
-            IPADDR=$(LC_ALL=C ip -o -4 addr ls dev ${DEVICE} | awk '{ print $4 ; exit }')
-            eval $(ipcalc --silent --hostname ${IPADDR} ; echo "status=$?")
-            if [ "$status" = "0" ]; then
-                hostname $HOSTNAME
-                # retrieve remote config
-                find_srv ovirt tcp
-                printf .
-                if [ -n "$SRV_HOST" -a -n "$SRV_PORT" ]; then
-                    wget --quiet -O - "http://$SRV_HOST:$SRV_PORT/ovirt/cfgdb/$(hostname)" \
-                        | augtool > /dev/null 2>&1
-                    if [ $? -eq 0 ]; then
-                        printf "remote config applied."
-                        return
-                    fi
-                fi
-            fi
-        fi
-    fi
-    # default oVirt network configuration:
-    # bridge each ethernet device in the system
-    ETHDEVS=$(cd /sys/class/net && ls -d eth*)
-    for eth in $ETHDEVS; do
-        BRIDGE=ovirtbr`echo $eth | cut -b4-`
-        printf '%s\n' "DEVICE=$eth" ONBOOT=yes "BRIDGE=$BRIDGE" \
-          > /etc/sysconfig/network-scripts/ifcfg-$eth
-        printf '%s\n' "DEVICE=$BRIDGE" BOOTPROTO=dhcp \
-            ONBOOT=yes TYPE=Bridge PEERNTP=yes \
-          > /etc/sysconfig/network-scripts/ifcfg-$BRIDGE
-    done
-    printf "default config applied."
-}
-
-start() {
-        # find boot interface from cmdline
-        # IPAPPEND 2 in pxelinux.cfg appends e.g. BOOTIF=01-00-16-3e-12-34-57
-        BOOTIF=
-        for i in $(cat /proc/cmdline); do
-            case $i in
-                BOOTIF=??-??-??-??-??-??-??)
-                    i=${i/#BOOTIF=??-/}
-                    BOOTMAC=${i//-/:}
-                    BOOTIF=$(grep -l $BOOTMAC /sys/class/net/eth*/address|rev|cut -d/ -f2|rev)
-                    ;;
-            esac
-        done
-        configure_from_network $BOOTIF
-
-        # find all of the partitions on the system
-
-        # get the system pagesize
-        PAGESIZE=`getconf PAGESIZE`
-
-        # look first at raw partitions
-        BLOCKDEVS=`ls /dev/sd? /dev/hd? 2>/dev/null`
-
-        # now LVM partitions
-        LVMDEVS="$DEVICES `lvscan | awk '{print $2}' | tr -d \"'\"`"
-
-	SWAPDEVS="$LVMDEVS"
-        for dev in $BLOCKDEVS; do
-            SWAPDEVS="$SWAPDEVS `fdisk -l $dev 2>/dev/null | tr '*' ' ' \
-	                         | awk '$5 ~ /82/ {print $1}'`"
-        done
-
-	# now check if any of these partitions are swap, and activate if so
-        for device in $SWAPDEVS; do
-            sig=`dd if=$device bs=1 count=10 skip=$(( $PAGESIZE - 10 )) \
-	         2>/dev/null`
-            if [ "$sig" = "SWAPSPACE2" ]; then
-                swapon $device
-            fi
-        done
-
-}
-
-case "$1" in
-  start)
-        start
-        ;;
-  *)
-        echo "Usage: ovirt-early {start}"
-        exit 2
-esac
-EOF
-
-chmod +x /etc/init.d/ovirt-early
-chkconfig ovirt-early on
-
-# just to get a boot warning to shut up
-touch /etc/resolv.conf
-
-cat > /etc/dhclient-exit-hooks << \EOF
-if [ -n "$new_ntp_servers" ]; then
-    for ntp_server in $new_ntp_servers; do
-        echo "$ntp_server" >> /etc/ntp/step-tickers
-    done
-fi
-EOF
-chmod +x /etc/dhclient-exit-hooks
-
-echo "Writing ovirt init script"
-# ovirt startup script to do krb init
-cat > /etc/init.d/ovirt << \EOF
-#!/bin/bash
-#
-# ovirt Start ovirt services
-#
-# chkconfig: 3 11 99
-# description: ovirt services
-#
-
-# Source functions library
-. /etc/init.d/functions
-. /etc/init.d/ovirt-functions
-
-start() {
-    echo -n $"Starting ovirt: "
-
-    find_srv ipa tcp
-    krb5_conf=/etc/krb5.conf
-    if [ ! -s $krb5_conf ]; then
-        rm -f $krb5_conf
-        # FIXME this is IPA specific
-        wget -q http://$SRV_HOST:$SRV_PORT/ipa/config/krb5.ini -O $krb5_conf \
-          || die "Failed to get $krb5_conf"
-    fi
-    IPA_HOST=$SRV_HOST
-    IPA_PORT=$SRV_PORT
-
-    find_srv identify tcp
-    krb5_tab=/etc/libvirt/krb5.tab
-    ovirt-awake start $krb5_tab $SRV_HOST $SRV_PORT
-
-    find_srv collectd tcp
-    collectd_conf=/etc/collectd.conf
-    if [ -f $collectd_conf.in -a $SRV_HOST -a $SRV_PORT ]; then
-        sed -e "s/@COLLECTD_SERVER@/$SRV_HOST/" \
-            -e "s/@COLLECTD_PORT@/$SRV_PORT/" $collectd_conf.in \
-            > $collectd_conf \
-          || die "Failed to write $collectd_conf"
-    fi
-
-    success
-    echo
-}
-
-case "$1" in
-  start)
-    start
-    ;;
-  *)
-    echo "Usage: ovirt {start}"
-    exit 2
-esac
-EOF
-
-chmod +x /etc/init.d/ovirt
-chkconfig ovirt on
-
-echo "Writing ovirt-post init script"
-# ovirt startup script to finish init, started after libvirt
-cat > /etc/init.d/ovirt-post << \EOF
-#!/bin/bash
-#
-# ovirt Start ovirt services
-#
-# chkconfig: 3 98 02
-# description: ovirt-post services
-#
-
-# Source functions library
-. /etc/init.d/functions
-. /etc/init.d/ovirt-functions
-
-start() {
-    echo -n $"Starting ovirt-post: "
-
-    find_srv identify tcp
-    UUID=`hal-get-property --udi \
-        /org/freedesktop/Hal/devices/computer --key system.hardware.uuid`
-
-    if [ -z $UUID ]; then
-        ovirt-identify-node -s $SRV_HOST -p $SRV_PORT
-    else
-        ovirt-identify-node -s $SRV_HOST -p $SRV_PORT -u $UUID
-    fi
-
-    success
-    echo
-}
-
-case "$1" in
-  start)
-    start
-    ;;
-  *)
-    echo "Usage: ovirt-post {start}"
-    exit 2
-esac
-EOF
-
-chmod +x /etc/init.d/ovirt-post
-chkconfig ovirt-post on
-
-mkdir -p /etc/chkconfig.d
-echo "# chkconfig: 345 98 02" > /etc/chkconfig.d/collectd
-chkconfig collectd on
-
-echo "Setting up libvirt interfaces"
-# make libvirtd listen on the external interfaces
-sed -i -e 's/^#\(LIBVIRTD_ARGS="--listen"\).*/\1/' /etc/sysconfig/libvirtd
-
-echo "Setting up bridged networking"
-cat > /etc/kvm-ifup << \EOF
-#!/bin/sh
-
-switch=$(ip route list | awk '/^default / { print $NF }')
-ifconfig $1 0.0.0.0 up
-brctl addif ${switch} $1
-EOF
-
-chmod +x /etc/kvm-ifup
-
-echo "Setting up libvirt VNC and networking"
-# set up qemu daemon to allow outside VNC connections
-sed -i -e 's/^[[:space:]]*#[[:space:]]*\(vnc_listen = "0.0.0.0"\).*/\1/' \
-  /etc/libvirt/qemu.conf
-
-# set up libvirtd to listen on TCP (for kerberos)
-sed -i -e 's/^[[:space:]]*#[[:space:]]*\(listen_tcp\)\>.*/\1 = 1/' \
-       -e 's/^[[:space:]]*#[[:space:]]*\(listen_tls\)\>.*/\1 = 0/' \
-  /etc/libvirt/libvirtd.conf
-
-# make sure we don't autostart virbr0 on libvirtd startup
-rm -f /etc/libvirt/qemu/networks/autostart/default.xml
-
-# with the new libvirt (0.4.0), make sure we we setup gssapi in the mech_list
-if [ `egrep -c '^mech_list: gssapi' /etc/sasl2/libvirt.conf` -eq 0 ]; then
-   sed -i -e 's/^\([[:space:]]*mech_list.*\)/#\1/' /etc/sasl2/libvirt.conf
-   echo "mech_list: gssapi" >> /etc/sasl2/libvirt.conf
-fi
-
-echo "Setting up login screen"
-# pretty login screen..
-
-g=$(printf '\33[1m\33[32m')    # similar to g=$(tput bold; tput setaf 2)
-n=$(printf '\33[m')            # similar to n=$(tput sgr0)
-cat <<EOF > /etc/issue
-
-           888     888 ${g}d8b$n         888
-           888     888 ${g}Y8P$n         888
-           888     888             888
-   .d88b.  Y88b   d88P 888 888d888 888888
-  d88''88b  Y88b d88P  888 888P'   888
-  888  888   Y88o88P   888 888     888
-  Y88..88P    Y888P    888 888     Y88b.
-   'Y88P'      Y8P     888 888      'Y888
-
-  Managed node
-
-  Virtualization just got the ${g}Green Light$n
-
-EOF
-
-cp /etc/issue /etc/issue.net
-
-echo "Setting up collectd configuration"
-# setup collectd configuration
-cat > /etc/collectd.conf.in << \EOF
-LoadPlugin logfile
-LoadPlugin network
-LoadPlugin libvirt
-LoadPlugin memory
-LoadPlugin cpu
-LoadPlugin load
-LoadPlugin interface
-LoadPlugin disk
-
-<Plugin libvirt>
-        Connection "qemu:///system"
-        RefreshInterval "10"
-        HostnameFormat "hostname"
-</Plugin>
-
-<Plugin network>
-        Server "@COLLECTD_SERVER@" @COLLECTD_PORT@
-</Plugin>
-
-<Plugin interface>
-	Interface "eth0"
-	IgnoreSelected false
-</Plugin>
-
-EOF
-
-echo "Clearing kerberos config"
-# remove the /etc/krb5.conf file; it will be fetched on bootup
-rm -f /etc/krb5.conf
-
 echo "Creating shadow files"
 # because we aren't installing authconfig, we aren't setting up shadow
 # and gshadow properly.  Do it by hand here
diff --git a/ovirt-managed-node/ovirt-managed-node.spec b/ovirt-managed-node/ovirt-managed-node.spec
index ee2f153..bd807b1 100644
--- a/ovirt-managed-node/ovirt-managed-node.spec
+++ b/ovirt-managed-node/ovirt-managed-node.spec
@@ -1,4 +1,4 @@
-Summary:        The managed node demons for oVirt.
+Summary:        The managed node daemons/scripts for oVirt
 Name:           ovirt-managed-node
 Source1:        version
 Version:        %(echo `awk '{ print $1 }' %{SOURCE1}`)
@@ -7,38 +7,87 @@ Source0:        %{name}-%{version}.tar.gz
 License:        GPL
 Group:          Applications/System
 
-BuildRoot:      %{_tmppath}/%{name}-%{version}-root
+BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-buildroot
 URL:            http://www.ovirt.org/
+Requires(post):  /sbin/chkconfig
+Requires(preun): /sbin/chkconfig
 BuildRequires:  libvirt-devel
 Requires:       libvirt
-ExclusiveArch:  %{ix86} x86_64 ia64
+ExclusiveArch:  %{ix86} x86_64
 
+%define app_root %{_datadir}/%{name}
 
 %description
 Provides a series of daemons and support utilities to allow an
 oVirt managed node to interact with the oVirt server.
 
-
 %prep
-%setup
-
-rm -rf $RPM_BUILD_ROOT
-mkdir -p $RPM_BUILD_ROOT
 
+%setup -q
+%{__rm} -rf %{buildroot}
+mkdir %{buildroot}
 
 %build
 make
 
-mkdir -p $RPM_BUILD_ROOT/sbin
-cp ovirt-awake         $RPM_BUILD_ROOT/sbin
-cp ovirt-identify-node $RPM_BUILD_ROOT/sbin
+%install
+%{__install} -d -m0755 %{buildroot}%{_sbindir}
+%{__install} -d -m0755 %{buildroot}%{_sysconfdir}
+%{__install} -d -m0755 %{buildroot}%{_sysconfdir}/chkconfig.d
+%{__install} -d -m0755 %{buildroot}%{_initrddir}
+%{__install} -d -m0755 %{buildroot}%{app_root}
+
+%{__install} -p -m0755 scripts/ovirt-awake %{buildroot}%{_sbindir}
+%{__install} -p -m0755 ovirt-identify-node %{buildroot}%{_sbindir}
+
+%{__install} -p -m0644 scripts/ovirt-functions %{buildroot}%{_initrddir}
+%{__install} -p -m0755 scripts/ovirt-early %{buildroot}%{_initrddir}
+%{__install} -p -m0755 scripts/ovirt %{buildroot}%{_initrddir}
+%{__install} -p -m0755 scripts/ovirt-post %{buildroot}%{_initrddir}
+
+%{__install} -p -m0644 scripts/collectd %{buildroot}%{_sysconfdir}/chkconfig.d
+%{__install} -p -m0644 scripts/collectd.conf.in %{buildroot}%{_sysconfdir}
+%{__install} -p -m0755 scripts/kvm-ifup %{buildroot}%{_sysconfdir}
+%{__install} -p -m0755 scripts/dhclient-exit-hooks %{buildroot}%{_sysconfdir}
 
+%{__install} -p -m0755 scripts/ovirt-setup %{buildroot}%{app_root}
 
 %clean
-rm -rf $RPM_BUILD_ROOT
+%{__rm} -rf %{buildroot}
+
+%post
+/sbin/chkconfig --add ovirt-early
+/sbin/chkconfig ovirt-early on
+/sbin/chkconfig --add ovirt
+/sbin/chkconfig ovirt on
+/sbin/chkconfig --add ovirt-post
+/sbin/chkconfig ovirt-post on
+
+%{app_root}/ovirt-setup
+
+%preun
+if [ "$1" = 0 ] ; then
+  /sbin/chkconfig --del ovirt-early
+  /sbin/chkconfig --del ovirt
+  /sbin/chkconfig --del ovirt-post
+fi
 
 %files
-%defattr(755,root,root)
+%defattr(-,root,root,0755)
+%{_sbindir}/ovirt-awake
+%{_sbindir}/ovirt-identify-node
+%{_initrddir}/ovirt-early
+%{_initrddir}/ovirt
+%{_initrddir}/ovirt-post
+%{_sysconfdir}/kvm-ifup
+%{_sysconfdir}/dhclient-exit-hooks
+%{app_root}/ovirt-setup
+%defattr(-,root,root,0644)
+%{_initrddir}/ovirt-functions
+%{_sysconfdir}/collectd.conf.in
+%{_sysconfdir}/chkconfig.d/collectd
 %doc README NEWS AUTHOR ChangeLog
-/sbin/ovirt-awake
-/sbin/ovirt-identify-node
+
+%changelog
+* Mon Jun 30 2008 Perry Myers <pmyers at redhat.com> - 0.92 0.1
+- Add in sections of kickstart post, general cleanup
diff --git a/ovirt-managed-node/src/scripts/collectd b/ovirt-managed-node/src/scripts/collectd
new file mode 100644
index 0000000..3990cfe
--- /dev/null
+++ b/ovirt-managed-node/src/scripts/collectd
@@ -0,0 +1 @@
+# chkconfig: 345 98 02
diff --git a/ovirt-managed-node/src/scripts/collectd.conf.in b/ovirt-managed-node/src/scripts/collectd.conf.in
new file mode 100644
index 0000000..a68c464
--- /dev/null
+++ b/ovirt-managed-node/src/scripts/collectd.conf.in
@@ -0,0 +1,23 @@
+LoadPlugin logfile
+LoadPlugin network
+LoadPlugin libvirt
+LoadPlugin memory
+LoadPlugin cpu
+LoadPlugin load
+LoadPlugin interface
+LoadPlugin disk
+
+<Plugin libvirt>
+        Connection "qemu:///system"
+        RefreshInterval "10"
+        HostnameFormat "hostname"
+</Plugin>
+
+<Plugin network>
+        Server "@COLLECTD_SERVER@" @COLLECTD_PORT@
+</Plugin>
+
+<Plugin interface>
+        Interface "eth0"
+        IgnoreSelected false
+</Plugin>
diff --git a/ovirt-managed-node/src/scripts/dhclient-exit-hooks b/ovirt-managed-node/src/scripts/dhclient-exit-hooks
new file mode 100755
index 0000000..7dd53c0
--- /dev/null
+++ b/ovirt-managed-node/src/scripts/dhclient-exit-hooks
@@ -0,0 +1,5 @@
+if [ -n "$new_ntp_servers" ]; then
+    for ntp_server in $new_ntp_servers; do
+        echo "$ntp_server" >> /etc/ntp/step-tickers
+    done
+fi
diff --git a/ovirt-managed-node/src/scripts/kvm-ifup b/ovirt-managed-node/src/scripts/kvm-ifup
new file mode 100755
index 0000000..243e02f
--- /dev/null
+++ b/ovirt-managed-node/src/scripts/kvm-ifup
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+switch=$(ip route list | awk '/^default / { print $NF }')
+ifconfig $1 0.0.0.0 up
+brctl addif ${switch} $1
diff --git a/ovirt-managed-node/src/scripts/ovirt b/ovirt-managed-node/src/scripts/ovirt
new file mode 100755
index 0000000..92a0e40
--- /dev/null
+++ b/ovirt-managed-node/src/scripts/ovirt
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# ovirt Start ovirt services
+#
+# chkconfig: 3 11 99
+# description: ovirt services
+#
+
+# Source functions library
+. /etc/init.d/functions
+. /etc/init.d/ovirt-functions
+
+start() {
+    echo -n $"Starting ovirt: "
+
+    find_srv ipa tcp
+    krb5_conf=/etc/krb5.conf
+    if [ ! -s $krb5_conf ]; then
+        rm -f $krb5_conf
+        # FIXME this is IPA specific
+        wget -q http://$SRV_HOST:$SRV_PORT/ipa/config/krb5.ini -O $krb5_conf \
+            || die "Failed to get $krb5_conf"
+    fi
+    IPA_HOST=$SRV_HOST
+    IPA_PORT=$SRV_PORT
+
+    find_srv identify tcp
+    krb5_tab=/etc/libvirt/krb5.tab
+    ovirt-awake start $krb5_tab $SRV_HOST $SRV_PORT
+
+    find_srv collectd tcp
+    collectd_conf=/etc/collectd.conf
+    if [ -f $collectd_conf.in -a $SRV_HOST -a $SRV_PORT ]; then
+        sed -e "s/@COLLECTD_SERVER@/$SRV_HOST/" \
+            -e "s/@COLLECTD_PORT@/$SRV_PORT/" $collectd_conf.in \
+            > $collectd_conf \
+            || die "Failed to write $collectd_conf"
+    fi
+
+    success
+    echo
+}
+
+case "$1" in
+    start)
+        start
+        ;;
+    *)
+        echo "Usage: ovirt {start}"
+        exit 2
+esac
diff --git a/ovirt-managed-node/src/ovirt-awake b/ovirt-managed-node/src/scripts/ovirt-awake
similarity index 100%
rename from ovirt-managed-node/src/ovirt-awake
rename to ovirt-managed-node/src/scripts/ovirt-awake
diff --git a/ovirt-managed-node/src/scripts/ovirt-early b/ovirt-managed-node/src/scripts/ovirt-early
new file mode 100755
index 0000000..4116847
--- /dev/null
+++ b/ovirt-managed-node/src/scripts/ovirt-early
@@ -0,0 +1,104 @@
+#!/bin/bash
+#
+# ovirt-early Start early ovirt services
+#
+# chkconfig: 3 01 99
+# description: ovirt-early services
+#
+
+# Source functions library
+. /etc/init.d/functions
+. /etc/init.d/ovirt-functions
+
+configure_from_network() {
+    DEVICE=$1
+    if [ -n "$DEVICE" ]; then
+        printf .
+        # setup temporary interface to retrieve configuration
+        echo "network --device $DEVICE --bootproto dhcp" | nash
+        if [ $? -eq 0 ]; then
+            printf .
+            # from network-scripts/ifup-post
+            IPADDR=$(LC_ALL=C ip -o -4 addr ls dev ${DEVICE} | awk '{ print $4 ; exit }')
+            eval $(ipcalc --silent --hostname ${IPADDR} ; echo "status=$?")
+            if [ "$status" = "0" ]; then
+                hostname $HOSTNAME
+                # retrieve remote config
+                find_srv ovirt tcp
+                printf .
+                if [ -n "$SRV_HOST" -a -n "$SRV_PORT" ]; then
+                    wget --quiet -O - "http://$SRV_HOST:$SRV_PORT/ovirt/cfgdb/$(hostname)" \
+                        | augtool > /dev/null 2>&1
+                    if [ $? -eq 0 ]; then
+                        printf "remote config applied."
+                        return
+                    fi
+                fi
+            fi
+        fi
+    fi
+    # default oVirt network configuration:
+    # bridge each ethernet device in the system
+    ETHDEVS=$(cd /sys/class/net && ls -d eth*)
+    for eth in $ETHDEVS; do
+        BRIDGE=ovirtbr`echo $eth | cut -b4-`
+        printf '%s\n' "DEVICE=$eth" ONBOOT=yes "BRIDGE=$BRIDGE" \
+            > /etc/sysconfig/network-scripts/ifcfg-$eth
+        printf '%s\n' "DEVICE=$BRIDGE" BOOTPROTO=dhcp \
+            ONBOOT=yes TYPE=Bridge PEERNTP=yes \
+            > /etc/sysconfig/network-scripts/ifcfg-$BRIDGE
+    done
+    printf "default config applied."
+}
+
+start() {
+    # find boot interface from cmdline
+    # IPAPPEND 2 in pxelinux.cfg appends e.g. BOOTIF=01-00-16-3e-12-34-57
+    BOOTIF=
+    for i in $(cat /proc/cmdline); do
+        case $i in
+            BOOTIF=??-??-??-??-??-??-??)
+            i=${i/#BOOTIF=??-/}
+            BOOTMAC=${i//-/:}
+            BOOTIF=$(grep -l $BOOTMAC /sys/class/net/eth*/address|rev|cut -d/ -f2|rev)
+            ;;
+        esac
+    done
+
+    configure_from_network $BOOTIF
+
+    # find all of the partitions on the system
+
+    # get the system pagesize
+    PAGESIZE=`getconf PAGESIZE`
+
+    # look first at raw partitions
+    BLOCKDEVS=`ls /dev/sd? /dev/hd? 2>/dev/null`
+
+    # now LVM partitions
+    LVMDEVS="$DEVICES `lvscan | awk '{print $2}' | tr -d \"'\"`"
+
+    SWAPDEVS="$LVMDEVS"
+    for dev in $BLOCKDEVS; do
+        SWAPDEVS="$SWAPDEVS `fdisk -l $dev 2>/dev/null | tr '*' ' ' \
+                                     | awk '$5 ~ /82/ {print $1}'`"
+    done
+
+    # now check if any of these partitions are swap, and activate if so
+    for device in $SWAPDEVS; do
+        sig=`dd if=$device bs=1 count=10 skip=$(( $PAGESIZE - 10 )) \
+            2>/dev/null`
+        if [ "$sig" = "SWAPSPACE2" ]; then
+            swapon $device
+        fi
+    done
+}
+
+case "$1" in
+    start)
+        start
+        ;;
+    *)
+        echo "Usage: ovirt-early {start}"
+        exit 2
+esac
diff --git a/ovirt-managed-node/src/scripts/ovirt-functions b/ovirt-managed-node/src/scripts/ovirt-functions
new file mode 100644
index 0000000..9974533
--- /dev/null
+++ b/ovirt-managed-node/src/scripts/ovirt-functions
@@ -0,0 +1,17 @@
+# -*-Shell-script-*-
+
+find_srv() {
+    local dnsreply
+    dnsreply=$(dig +short -t srv _$1._$2.$(dnsdomainname))
+    if [ $? -eq 0 ]; then
+        set _ $dnsreply; shift
+        SRV_HOST=$4; SRV_PORT=$3
+    else
+        SRV_HOST=; SRV_PORT=
+    fi
+}
+
+die()
+{
+    echo "$@" 1>&2; failure; echo 1>&2; exit 1
+}
diff --git a/ovirt-managed-node/src/scripts/ovirt-post b/ovirt-managed-node/src/scripts/ovirt-post
new file mode 100755
index 0000000..3bb0f6d
--- /dev/null
+++ b/ovirt-managed-node/src/scripts/ovirt-post
@@ -0,0 +1,37 @@
+#!/bin/bash
+#
+# ovirt Start ovirt services
+#
+# chkconfig: 3 98 02
+# description: ovirt-post services
+#
+
+# Source functions library
+. /etc/init.d/functions
+. /etc/init.d/ovirt-functions
+
+start() {
+    echo -n $"Starting ovirt-post: "
+
+    find_srv identify tcp
+    UUID=`hal-get-property --udi \
+        /org/freedesktop/Hal/devices/computer --key system.hardware.uuid`
+
+    if [ -z $UUID ]; then
+        ovirt-identify-node -s $SRV_HOST -p $SRV_PORT
+    else
+        ovirt-identify-node -s $SRV_HOST -p $SRV_PORT -u $UUID
+    fi
+
+    success
+    echo
+}
+
+case "$1" in
+    start)
+        start
+        ;;
+    *)
+        echo "Usage: ovirt-post {start}"
+        exit 2
+esac
diff --git a/ovirt-managed-node/src/scripts/ovirt-setup b/ovirt-managed-node/src/scripts/ovirt-setup
new file mode 100755
index 0000000..17af13b
--- /dev/null
+++ b/ovirt-managed-node/src/scripts/ovirt-setup
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+# just to get a boot warning to shut up
+touch /etc/resolv.conf
+
+echo "Setting up Networking"
+cat > /etc/sysconfig/iptables <<EOF
+*filter
+:INPUT ACCEPT [0:0]
+:FORWARD ACCEPT [0:0]
+:OUTPUT ACCEPT [0:0]
+-A FORWARD -m physdev --physdev-is-bridged -j ACCEPT
+COMMIT
+EOF
+
+echo "Setting up libvirt interfaces"
+# make libvirtd listen on the external interfaces
+sed -i -e 's/^#\(LIBVIRTD_ARGS="--listen"\).*/\1/' /etc/sysconfig/libvirtd
+
+echo "Setting up libvirt VNC and networking"
+# set up qemu daemon to allow outside VNC connections
+sed -i -e 's/^[[:space:]]*#[[:space:]]*\(vnc_listen = "0.0.0.0"\).*/\1/' \
+    /etc/libvirt/qemu.conf
+
+# set up libvirtd to listen on TCP (for kerberos)
+sed -i -e 's/^[[:space:]]*#[[:space:]]*\(listen_tcp\)\>.*/\1 = 1/' \
+    -e 's/^[[:space:]]*#[[:space:]]*\(listen_tls\)\>.*/\1 = 0/' \
+    /etc/libvirt/libvirtd.conf
+
+# make sure we don't autostart virbr0 on libvirtd startup
+rm -f /etc/libvirt/qemu/networks/autostart/default.xml
+
+# with the new libvirt (0.4.0), make sure we we setup gssapi in the mech_list
+if [ `egrep -c '^mech_list: gssapi' /etc/sasl2/libvirt.conf` -eq 0 ]; then
+    sed -i -e 's/^\([[:space:]]*mech_list.*\)/#\1/' /etc/sasl2/libvirt.conf
+    echo "mech_list: gssapi" >> /etc/sasl2/libvirt.conf
+fi
+
+echo "Clearing kerberos config"
+# remove the /etc/krb5.conf file; it will be fetched on bootup
+rm -f /etc/krb5.conf
+
+echo "Turing on ovirt services"
+chkconfig ovirt-early on
+chkconfig ovirt on
+chkconfig ovirt-post on
+chkconfig collectd on
+
+echo "Setting up login screen"
+# pretty login screen..
+
+g=$(printf '\33[1m\33[32m')    # similar to g=$(tput bold; tput setaf 2)
+n=$(printf '\33[m')            # similar to n=$(tput sgr0)
+cat <<EOF > /etc/issue
+
+           888     888 ${g}d8b$n         888
+           888     888 ${g}Y8P$n         888
+           888     888             888
+   .d88b.  Y88b   d88P 888 888d888 888888
+  d88''88b  Y88b d88P  888 888P'   888
+  888  888   Y88o88P   888 888     888
+  Y88..88P    Y888P    888 888     Y88b.
+   'Y88P'      Y8P     888 888      'Y888
+
+  Managed node
+
+  Virtualization just got the ${g}Green Light$n
+
+EOF
+
+cp /etc/issue /etc/issue.net
+
+
+
+
+
-- 
1.5.5.1




More information about the ovirt-devel mailing list