ovirt-node 2.2.0 release
[ovirt-node.git] / scripts / ovirt-firstboot
blobf8b94fbf820c53877534bcaacc7b362e2acd0706
1 #!/bin/bash
3 # ovirt-firstboot Puts the node into configuration mode.
5 # chkconfig: 2345 99 01
6 # description: ovirt-firstboot node configuration script
8 # Copyright (C) 2008 Red Hat, Inc.
9 # Written by Darryl L. Pierce <dpierce@redhat.com>
11 # This program is free software; you can redistribute it and/or modify
12 # it under the terms of the GNU General Public License as published by
13 # the Free Software Foundation; version 2 of the License.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23 # MA 02110-1301, USA. A copy of the GNU General Public License is
24 # also available at http://www.gnu.org/copyleft/gpl.html.
26 ## Source functions library
27 . /etc/init.d/functions
28 . /usr/libexec/ovirt-functions
30 prog=ovirt-firstboot
31 VAR_SUBSYS_OVIRT_FIRSTBOOT=/var/lock/subsys/$prog
33 trap '__st=$?; stop_log; exit $__st' 0
34 trap 'exit $?' 1 2 13 15
36 check_version(){
37 if [ -e "/dev/HostVG/Root" ]; then
38 log " "
39 log " Major version upgrades are not allowed."
40 log " Please uninstall existing version and reinstall."
41 log " Press Enter to drop to emergency shell."
42 read < /dev/console
43 bash < /dev/console
47 start_ovirt_firstboot ()
50 if ! is_firstboot && ! is_auto_install && ! is_upgrade && ! is_install; then
51 return
54 touch $VAR_SUBSYS_OVIRT_FIRSTBOOT
55 /sbin/restorecon -e /var/lib/stateless/writable -e /data -e /config -e /proc -e /sys -rv / >> $OVIRT_TMP_LOGFILE 2>&1
57 # Hide kernel messages on the console
58 dmesg -n 1
60 is_auto_install
61 auto_install=$?
62 if [ "$auto_install" = "0" ]; then
63 /usr/libexec/ovirt-auto-install
64 rc=$?
65 # Handle Log file
66 if [ -f $OVIRT_TMP_LOGFILE ]; then
67 cat $OVIRT_TMP_LOGFILE >> $OVIRT_LOGFILE
68 rm -f $OVIRT_TMP_LOGFILE
70 if [ $rc -ne 0 ]; then
71 autoinstall_failed
73 elif [ "$auto_install" = "2" ]; then
74 echo "Device specified in storage_init does not exist"
75 autoinstall_failed
78 if is_upgrade; then
79 plymouth --hide-splash
80 mount_live
81 check_version
82 # auto install covers this already
83 if ! is_auto_install; then
84 /usr/libexec/ovirt-config-boot /live "$OVIRT_BOOTPARAMS" no
86 if [ $? -ne 0 ]; then
87 autoinstall_failed
89 disable_firstboot
90 ovirt_store_firstboot_config || autoinstall_failed
91 reboot
92 if [ $? -ne 0 ]; then
93 autoinstall_failed
95 return 1
98 if is_firstboot || is_install ; then
99 plymouth --hide-splash
101 export LVM_SUPPRESS_FD_WARNINGS=0
102 /usr/libexec/ovirt-config-installer -x < /dev/console
104 plymouth --show-splash
106 disable_firstboot
108 ovirt_store_firstboot_config >> $OVIRT_LOGFILE 2>&1
110 rm -f $VAR_SUBSYS_OVIRT_FIRSTBOOT
113 stop_ovirt_firstboot () {
114 echo -n "Stopping ovirt-firstboot: "
115 success
118 reload_ovirt_firstboot () {
119 stop_ovirt_firstboot
120 start_ovirt_firstboot
123 case "$1" in
124 start)
125 if is_managed; then
126 exit 0
129 printf "Starting ovirt-firstboot: "
131 start_ovirt_firstboot
133 test $? == 0 && success || failure
134 echo
136 status)
137 status $prog
139 reload)
140 reload_ovirt_firstboot
142 stop)
143 stop_ovirt_firstboot
146 echo "Usage: ovirt-firstboot {start}"
147 exit 2
148 esac