ovirt-node 2.2.0 release
[ovirt-node.git] / scripts / ovirt-post
blob96802015e3715773a174879377b79d8e02b8aafa
1 #!/bin/bash
3 # ovirt Start ovirt services
5 ### BEGIN INIT INFO
6 # Provides: ovirt-post
7 # Required-Start: ovirt libvirtd
8 # Default-Start: 2 3 4 5
9 # Description: Performs managed node post configuration setup.
10 ### END INIT INFO
12 # Source functions library
13 . /etc/init.d/functions
14 . /usr/libexec/ovirt-functions
16 prog=ovirt-post
17 VAR_SUBSYS_OVIRT_POST=/var/lock/subsys/$prog
19 start_ovirt_post() {
20 # wait for libvirt to finish initializing
21 local count=0
22 while true; do
23 if virsh connect qemu:///system --readonly >/dev/null 2>&1; then
24 break
25 elif [ "$count" == "100" ]; then
26 log "Libvirt did not initialize in time..."
27 return 1
28 else
29 log "Waiting for libvirt to finish initializing..."
30 count=$(expr $count + 1)
31 sleep 1
34 touch $VAR_SUBSYS_OVIRT_POST
36 done
37 BACKUP=$(mktemp)
38 ISSUE=/etc/issue
39 ISSUE_NET=/etc/issue.net
40 egrep -v "[Vv]irtualization hardware" $ISSUE > $BACKUP
41 cp -f $BACKUP $ISSUE
42 rm $BACKUP
43 hwvirt=$(virsh --readonly capabilities)
44 if [[ $hwvirt =~ kvm ]]; then
45 log "Hardware virtualization detected"
46 else
47 log "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
48 log "!!! Hardware Virtualization Is Unavailable !!!"
49 log "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
51 echo "Virtualization hardware is unavailable." >> $ISSUE
53 flags=$(cat /proc/cpuinfo | grep "^flags")
54 if [[ $flags =~ vmx ]] || [[ $flags =~ svm ]]; then
55 echo "(Virtualization hardware was detected but is disabled)" >> $ISSUE
56 else
57 echo "(No virtualization hardware was detected on this system)" >> $ISSUE
60 if is_local_storage_configured; then
61 echo "" >> $ISSUE
62 echo "Please login as 'admin' to configure the node" >> $ISSUE
64 cp -f $ISSUE $ISSUE_NET
66 if is_standalone; then
67 return 0
70 # persist selected configuration files
71 ovirt_store_config \
72 /etc/krb5.conf \
73 /etc/node.d \
74 /etc/sysconfig/node-config
75 /etc/libvirt/krb5.tab \
76 /etc/ssh/ssh_host*_key*
78 . /usr/libexec/ovirt-functions
80 # successfull boot from /dev/HostVG/Root
81 if grep -q -w root=live:LABEL=Root /proc/cmdline; then
82 # set first boot entry as permanent default
83 ln -snf /dev/.initramfs/live/grub /boot/grub
84 mount -o rw,remount LABEL=Root /dev/.initramfs/live > /tmp/grub-savedefault.log 2>&1
85 echo "savedefault --default=0" | grub >> /tmp/grub-savedefault.log 2>&1
86 mount -o ro,remount LABEL=Root /dev/.initramfs/live >> /tmp/grub-savedefault.log 2>&1
89 # perform any post startup operations
90 case $OVIRT_RUNTIME_MODE in
91 esac
93 rm -f $VAR_SUBSYS_OVIRT_POST
96 stop_ovirt_post () {
97 echo -n "Stopping ovirt-post: "
98 success
101 reload_ovirt_post () {
102 stop_ovirt_post
103 start_ovirt_post
106 case "$1" in
107 start)
108 [ -f "$VAR_SUBSYS_OVIRT_POST" ] && exit 0
109 echo -n "Starting ovirt-post: "
112 log "Starting ovirt-post"
113 start_ovirt_post
114 log "Completed ovirt-post"
115 } >> $OVIRT_LOGFILE 2>&1
117 test $? == 0 && success || failure
118 echo
120 status)
121 status $prog
123 reload)
124 reload_ovirt_post
126 stop)
127 stop_ovirt_post
130 echo "Usage: ovirt-post {start}"
131 exit 2
132 esac