ovirt-node 2.2.0 release
[ovirt-node.git] / scripts / ovirt-early
blob6c22054717c67d4ee3ae3e282a9307c7a81cfdb8
1 #!/bin/bash
3 # ovirt-early Start early ovirt services
5 # chkconfig: 23 01 99
7 ### BEGIN INIT INFO
8 # Provides: ovirt-early
9 # Default-Start: 2 3 4 5
10 # Dewscription: Managed node early configuration service
11 ### END INIT INFO
13 # Source functions library
14 . /etc/init.d/functions
15 . /usr/libexec/ovirt-functions
16 . /usr/libexec/ovirt-boot-functions
18 prog=ovirt-early
19 VAR_SUBSYS_OVIRT_EARLY=/var/lock/subsys/$prog
21 BONDING_MODCONF_FILE=/etc/modprobe.d/bonding
22 AUGTOOL_CONFIG=/var/tmp/augtool-config
23 EARLY_DIR=/etc/ovirt-early.d
25 get_mac_addresses() {
26 local DEVICE=$1
28 macs=""
29 devices=$(ls -b /sys/class/net/)
30 for device in $devices; do
31 if [ "$device" != "$DEVICE" ]; then
32 mac=$(cat /sys/class/net/$device/address 2>/dev/null)
33 if [ -n "$mac" -a "$mac" != "00:00:00:00:00:00" ]; then
34 macs="${macs}${mac}=${device},"
37 done
40 configure_ovirt_management_nic() {
41 DEVICE=$1
43 if [ -n "$DEVICE" ]; then
44 log "Configuring network"
45 if ! network_up ; then
46 log "Using interface $DEVICE"
47 # setup temporary interface to retrieve configuration
48 /sbin/dhclient -1 $1 \
49 && [ -f /var/run/dhclient.pid ] \
50 && kill $(cat /var/run/dhclient.pid)
52 if [ $? -eq 0 ]; then
53 # from network-scripts/ifup-post
54 IPADDR=$(LC_ALL=C ip -o -4 addr ls dev ${DEVICE} | awk '{ print $4 ; exit }')
55 log "Interface brought up with $IPADDR"
56 eval $(ipcalc --silent --hostname ${IPADDR} ; echo "status=$?")
57 if [ "$status" = "0" ]; then
58 hostname $HOSTNAME
59 log "Hostname resolved to $HOSTNAME"
60 # retrieve remote config
61 find_srv ovirt tcp
62 if [ -n "$SRV_HOST" -a -n "$SRV_PORT" ]; then
63 log "oVirt Server found at: $SRV_HOST:$SRV_PORT"
64 cfgdb=$(mktemp)
65 get_mac_addresses $DEVICE
66 log "MACs to use: $macs"
67 wget -O $cfgdb --no-check-certificate \
68 "http://$SRV_HOST:$SRV_PORT/ovirt/managed_node/config?host=$(hostname)&macs=$macs"
69 if [ $? -eq 0 ]; then
70 log "Remote configuration bundle retrieved to $cfgdb"
71 /usr/libexec/ovirt-process-config $cfgdb $BONDING_MODCONF_FILE $AUGTOOL_CONFIG
72 if [ $? -eq 0 ]; then
73 log "Remote configuration retrieved and applied"
74 rm $cfgdb
75 else
76 log "Failure to retrieve or apply remote configuration"
78 else
79 log "Failed to retrieve configuration bundle"
84 else
85 # for non-PXE boot when BOOTIF parameter is not specified
86 # otherwise default network config is invalid
87 DEVICE=eth0
89 # default oVirt network configuration:
90 # bridge each ethernet device in the system
91 BRIDGE=br$DEVICE
92 local ifcfg=/etc/sysconfig/network-scripts/ifcfg-$BRIDGE
94 # only write a default file if one does not exist
95 if [ ! -f $ifcfg ]; then
96 log "Applying default configuration to $DEVICE and $BRIDGE"
97 printf '%s\n' "DEVICE=$DEVICE" ONBOOT=yes "BRIDGE=$BRIDGE" \
98 > /etc/sysconfig/network-scripts/ifcfg-$DEVICE
99 printf '%s\n' "DEVICE=$BRIDGE" "BOOTPROTO=dhcp" \
100 ONBOOT=yes TYPE=Bridge PEERNTP=yes DELAY=0 \
101 > /etc/sysconfig/network-scripts/ifcfg-$BRIDGE
102 log "Default config applied"
105 service network restart
109 configure_management_interface() {
110 log "Configuring the manangement interface."
111 case $OVIRT_RUNTIME_MODE in
112 "ovirt")
113 configure_ovirt_management_nic $bootif
114 if [ -n "$init" ]; then
115 /usr/libexec/ovirt-config-storage AUTO
116 # initial configuration storage, after /config creation
117 ovirt_store_config \
118 /etc/sysconfig/network-scripts/ifcfg-* \
119 $BONDING_MODCONF_FILE
120 if [ $upgrade = 1 ]; then
121 # local disk installation for managed mode
122 mount_live
123 /usr/libexec/ovirt-config-boot /live "$bootparams"
127 "managed")
128 if [ -x $MANAGEMENT_SCRIPTS_DIR/configure-management-interface ]; then
129 log "Executing $MANAGEMENT_SCRIPTS_DIR/configure-management-interface"
130 $MANAGEMENT_SCRIPTS_DIR/configure-management-interface
131 else
132 echo "No script to configure management interface found."
135 "none")
136 log "Unmanaged node: no management interface to configure."
137 esac
140 start_ovirt_early () {
141 touch $VAR_SUBSYS_OVIRT_EARLY
142 # oVirt boot parameters
143 # BOOTIF=link|eth*|<MAC> (appended by pxelinux)
144 # storage_init=[usb|scsi[:serial#]|/dev/...]
145 # storage_vol=BOOT_MB:SWAP_MB:ROOT_MB:CONFIG_MB:LOGGING_MB:DATA_MB
146 # mem_overcommit=<overcommit_ratio>
147 # upgrade
148 # standalone
149 # firstboot
150 # ovirt_runtime_mode
151 # rescue
152 # pxelinux format: ip=<client-ip>:<boot-server-ip>:<gw-ip>:<netmask>
153 # anaconda format: ip=<client-ip> netmask=<netmask> gateway=<gw-ip>
154 # or ip=dhcp|off
155 # ipv6=dhcp|auto
156 # dns=server[,server]
157 # ntp=server[,server]
158 # vlan=id
159 # ssh_pwauth=[0|1]
160 # syslog=server[:port]
161 # collectd=server[:port]
162 # hostname=fqdn
163 # TBD logrotate maxsize
164 # rhn_type=[classic|sam]
165 # rhn_url=SATELLITE_URL
166 # rhn_CA_CERT=CA_CERT_URL
167 # rhn_username=RHN-USERNAME
168 # rhn_password=RHN-PASSWORD
169 # rhn_profile=RHNPROFILE
170 # rhn_activationkey=ACTIVATIONKEY
171 # RHN registration, activation key takes precedence
172 # rhn_proxy=PROXY-HOST:PORT
173 # rhn_proxyuser=PROXY-USERNAME
174 # rhn_proxypassword=PROXY-PASSWORD
175 # snmp_password=<authpassphrase>
177 # BOOTIF=link|eth*|<MAC> (appended by pxelinux)
178 # network boot interface is assumed to be on management network where
179 # management server is reachable
180 # BOOTIF=<MAC> e.g. BOOTIF=01-00-16-3e-12-34-57
181 # PXELINUX option IPAPPEND 2 in pxelinux.cfg appends MAC address
182 # of the booting node
183 # BOOTIF=link - take first eth for which ethtool reports link
184 # BOOTIF=eth* e.g. BOOTIF=eth0 - use given interface
185 bootif=
187 # ovirt_init=HOSTVGDISK1[,HOSTVGDISK2...][;APPVGDISK1[,APPVGDISK2...]]
188 # where DISK=[ata|cciss|scsi|usb[:serial#]|/dev/...]
189 # local installation target disks
190 # Allow specification of multiple disks per VG
191 # usb|scsi - select disk type, as reported by udev ID_BUS
192 # serial# - select exact disk using serial number, as reported by
193 # udev ID_SERIAL
194 # e.g. ovirt_init=usb:Generic_STORAGE_DEVICE_0000145418-0:0
195 # /dev/... - use specified disk device
196 # (for cases when HAL doesn't handle it)
197 # w/o value - grab the first disk (/dev/?da)
198 init=
199 init_app=
201 # storage_vol=:SWAP_MB::CONFIG_MB:LOGGING_MB:DATA_MB:SWAP2_MB:DATA2_MB
202 # or
203 # storage_vol=size[,{Swap|Data|Config|Logging|Data2|Swap2}][:size...]
204 # local partition sizes in MB
205 # LVs ending in 2 go to AppVG, all the others fall into HostVG
206 vol_boot_size=
207 vol_swap_size=
208 vol_root_size=
209 vol_config_size=
210 vol_logging_size=
211 # data size can be set to 0 to disable data partition, -1 to use
212 # remaining free space after the other above partitions are defined
213 # or a specific positive number in MB
214 vol_data_size=
216 # swap2 and data2 will be placed into AppVG, 0 disables, data2
217 # can be -1 or a positive number in MB for each
218 vol_swap2_size=
219 vol_data2_size=
221 # swap_encrypt={Swap|Swap2},cypher1[:cypher2...][;{Swap|Swap2}...]
222 # request swap encryption
223 # the default cypher is set to aes-cbc-essiv:sha256
224 crypt_swap=
225 crypt_swap2=
227 # upgrade
228 # install/update oVirt Node image on the local installation target disk
229 upgrade=
231 # mem_overcommit=<overcommit_ratio>
232 # set the swap size coefficient
233 overcommit=
235 # standalone
236 # force oVirt Node standalone mode
237 standalone=1
239 # firstboot
240 # force firstboot configuration even if it has already been run
241 # in auto-install mode, overwrite the disk chosen by storage_init parameter
242 firstboot=
244 # ovirt_runtime_mode
245 # overrides the runtime mode defined in /etc/sysconfig/node-config
246 runtime_mode=
248 # rescue
249 # enter emergency shell for fixing configuration issues
250 rescue=
252 # rootpw=<encrypted_password>
253 # sets a temporary root password, change is forced on first login
254 # password is crypted, same as Kickstart option rootpw --iscrypted
255 # WARNING: use for debugging only, this is not secure!
256 rootpw=
258 # adminpw=<encrypted_password>
259 # sets a temporary password for admin, change is forced on first login
260 # password is crypted, same as Kickstart option rootpw --iscrypted
261 # WARNING: use for debugging only, this is not secure!
262 adminpw=
264 # snmp_password=<authpassphrase>
265 # enable snmpd and set password for "root" SNMPv3 USM user
266 snmp_password=
268 # pxelinux format: ip=<client-ip>:<boot-server-ip>:<gw-ip>:<netmask>
269 # anaconda format: ip=<client-ip> netmask=<netmask> gateway=<gw-ip>
270 # or ip=dhcp|off
271 # ipv6=dhcp|auto
272 # dns=server[,server]
273 # ntp=server[,server]
274 # vlan=id
275 # ssh_pwauth=[0|1]
276 # static network configuration
277 ip_address=
278 ip_gateway=
279 ip_netmask=
280 vlan=
281 netmask=
282 gateway=
283 ipv6=
284 dns=
285 ntp=
286 ssh_pwauth=
287 uninstall=
289 # hostname=fqdn
290 # hostname
291 hostname=
293 # syslog=server[:port]
294 # default syslog server
295 syslog_server=
296 syslog_port=
298 # collectd=server[:port]
299 # default collectd server
300 collectd_server=
301 collectd_port=
303 # rhn_type=[classic|sam]
304 # default is classic
305 # rhn_url=SATELLITE_URL
306 # rhn_CA_CERT=CA_CERT_URL
307 # rhn_username=RHN-USERNAME
308 # rhn_password=RHN-PASSWORD
309 # rhn_profile=RHNPROFILE
310 # rhn_activationkey=ACTIVATIONKEY
311 # RHN registration, activation key takes precedence
312 # rhn_proxy=PROXY-HOST:PORT
313 # rhn_proxyuser=PROXY-USERNAME
314 # rhn_proxypassword=PROXY-PASSWORD
315 rhn_type=classic
316 rhn_url=
317 rhn_ca_cert=
318 rhn_username=
319 rhn_password=
320 rhn_profile=
321 rhn_activationkey=
322 rhn_proxy=
323 rhn_proxyuser=
324 rhn_proxypassword=
326 # save boot parameters like console= for local disk boot menu
327 bootparams=
328 cat /etc/system-release >> $OVIRT_LOGFILE
330 for i in $(cat /proc/cmdline); do
331 case $i in
332 uninstall*)
333 uninstall='yes'
335 BOOTIF=*)
336 i=${i#BOOTIF=}
337 case "$i" in
338 eth*)
339 bootif=$i
341 link)
342 for eth in $(cd /sys/class/net; echo eth*); do
343 if ethtool $eth 2>/dev/null|grep -q "Link detected: yes"
344 then
345 bootif=$eth
346 break
348 done
350 ??-??-??-??-??-??-??)
351 i=${i#??-}
352 bootif=$(grep -il $(echo $i|sed 's/-/:/g') /sys/class/net/eth*/address|rev|cut -d/ -f2|rev)
354 esac
356 storage_init* | ovirt_init*)
357 i=${i#ovirt_init}
358 i=${i#storage_init}
359 if [ -z "$i" ]; then
360 # 'storage_init' without value: grab first disk
361 init=$(ls -1 /dev/?da /dev/cciss/c?d? 2>/dev/null |head -n1)
362 else
363 i=${i#=}
364 eval $(printf $i|awk -F\; '{ print "hostvgdisks="$1; print "appvgdisks="$2; }')
365 # Look into HostVG disks
366 if [ -n "$hostvgdisks" ]; then
367 oldIFS="$IFS"
368 IFS=,
369 init=
370 for d in $hostvgdisks; do
371 did="$(IFS="$oldIFS" parse_disk_id "$d")"
372 if [ -z "$did" ]; then
373 autoinstall_failed
375 if [ -n "$init" ]; then
376 init="$init${SEP}$did"
377 else
378 init="$did"
380 done
381 IFS="$oldIFS"
383 # Look into AppVG disks
384 if [ -n "$appvgdisks" ]; then
385 oldIFS="$IFS"
386 IFS=,
387 init_app=
388 for d in $appvgdisks; do
389 did="$(IFS="$oldIFS" parse_disk_id "$d")"
390 if [ -z "$did" ]; then
391 autoinstall_failed
393 if [ -n "$init_app" ]; then
394 init_app="$init_app${SEP}$did"
395 else
396 init_app="$did"
398 done
399 IFS="$oldIFS"
402 if [ -z "$init" ]; then
403 log "Selected disk $i is not valid."
406 storage_vol* | ovirt_vol=*)
407 i=${i#ovirt_vol=}
408 i=${i#storage_vol=}
409 eval $(printf $i|awk -F: '{ print "lv1="$1; print "lv2="$2; print "lv3="$3; print "lv4="$4; print "lv5="$5; print "lv6="$6; print "lv7="$7; print "lv8="$8; }')
410 # Reads each provided LV size and assign them
411 # NOTE: Boot and Root size are ignored by o-c-storage
412 for p in $(seq 1 8); do
413 var=lv$p
414 size=
416 if [ -n "${!var}" ]; then
417 eval $(printf '${!var}'|awk -F, '{ print "size="$1; print "lv="$2; }')
418 if [ -n "${size}" ]; then
419 case "${lv}" in
420 Boot)
421 vol_boot_size=$size
423 Swap)
424 vol_swap_size=$size
426 Root)
427 vol_root_size=$size
429 Config)
430 vol_config_size=$size
432 Logging)
433 vol_logging_size=$size
435 Data)
436 vol_data_size=$size
438 Swap2)
439 vol_swap2_size=$size
441 Data2)
442 vol_data2_size=$size
445 ## This is here to preserve old styled syntax (in order)
446 ## BOOT_MB:SWAP_MB:ROOT_MB:CONFIG_MB:LOGGING_MB:DATA_MB:SWAP2_MB:DATA2_MB
447 case "$p" in
449 vol_boot_size=$size
452 vol_swap_size=$size
455 vol_root_size=$size
458 vol_config_size=$size
461 vol_logging_size=$size
464 vol_data_size=$size
467 vol_swap2_size=$size
470 vol_data2_size=$size
472 esac
474 esac
477 done
479 upgrade* | ovirt_upgrade* | local_boot | local_boot=* | ovirt_local_boot*)
480 upgrade=1
481 if ! grep -q admin /etc/passwd; then
482 unmount_config /etc/passwd /etc/shadow
483 useradd -g admin -s /usr/libexec/ovirt-admin-shell admin
484 [ ! grep -q ^%wheel /etc/sudoers ] && echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
485 /usr/sbin/usermod -p $(grep ^root /etc/shadow | sed 's/:/ /g' | awk '{print $2}') admin
486 persist /etc/shadow /etc/passwd
489 standalone=no | standalone=0 | ovirt_standalone=no | ovirt_standalone=0)
490 standalone=0
491 bootparams="$bootparams $i"
493 standalone* | ovirt_standalone*)
494 standalone=1
495 bootparams="$bootparams $i"
497 firstboot=no | firstboot=0 | ovirt_firstboot=no | ovirt_firstboot=0 | reinstall=0 | reinstall=no)
498 firstboot=0
500 firstboot* | ovirt_firstboot* | reinstall)
501 firstboot=1
503 install*)
504 install=1
506 runtime_mode*)
507 runtime_mode=${i#runtime_mode=}
509 rescue)
510 rescue=1
512 adminpw=*)
513 adminpw=${i#adminpw=}
515 rootpw=*)
516 rootpw=${i#rootpw=}
517 if [ -z "$adminpw" ]; then
518 adminpw=$rootpw
521 snmp_password=*)
522 snmp_password=${i#snmp_password=}
525 mem_overcommit* | ovirt_overcommit*)
526 i=${i#mem_overcommit=}
527 i=${i#ovirt_overcommit=}
528 eval $(printf $i|awk -F: '{print "overcommit="$1;}')
531 ip=*)
532 i=${i#ip=}
533 if [ "$i" = "dhcp" ]; then
534 ip_address=
535 else
536 eval $(printf $i|awk -F: '{print "ip_address="$1; print "ip_gateway="$3; print "ip_netmask="$4}')
539 netmask=*)
540 netmask=${i#netmask=}
542 gateway=*)
543 gateway=${i#gateway=}
545 ipv6=*)
546 ipv6=${i#ipv6=}
548 dns=*)
549 dns=${i#dns=}
551 ntp=*)
552 ntp=${i#ntp=}
554 hostname=*)
555 hostname=${i#hostname=}
557 vlan=*)
558 vlan=${i#vlan=}
560 ssh_pwauth=1 | ssh_pwauth=true)
561 ssh_pwauth=yes
563 ssh_pwauth=0 | ssh_pwauth=false)
564 ssh_pwauth=no
566 syslog=*)
567 i=${i#syslog=}
568 eval $(printf $i|awk -F: '{print "syslog_server="$1; print "syslog_port="$2;}')
570 netconsole=*)
571 i=${i#netconsole=}
572 eval $(printf $i|awk -F: '{print "netconsole_server="$1; print "netconsole_port="$2;}')
574 collectd=*)
575 i=${i#collectd=}
576 eval $(printf $i|awk -F: '{print "collectd_server="$1; print "collectd_port="$2;}')
578 rhn_type=*)
579 rhn_type=${i#rhn_type=}
581 rhn_url=*)
582 rhn_url=${i#rhn_url=}
584 rhn_ca_cert=*)
585 rhn_ca_cert=${i#rhn_ca_cert=}
587 rhn_username=*)
588 rhn_username=${i#rhn_username=}
590 rhn_password=*)
591 rhn_password=${i#rhn_password=}
593 rhn_profile=*)
594 rhn_profile=${i#rhn_profile=}
596 rhn_activationkey=*)
597 rhn_activationkey=${i#rhn_activationkey=}
599 rhn_proxy=*)
600 rhn_proxy=${i#rhn_proxy=}
602 rhn_proxyuser=*)
603 rhn_proxyuser=${i#rhn_proxyuser=}
605 rhn_proxypassword=*)
606 rhn_proxypassword=${i#rhn_proxypassword=}
608 ovirt_early=*)
609 bootparams="$bootparams $i"
610 i=${i#ovirt_early=}
611 ovirt_early=$(echo $i|tr ",:;" " ")
613 # Don't store these parameters in /etc/default/ovirt
614 BOOT_IMAGE=* | initrd=* | check | linux | liveimg | \
615 root=* | rootfstype=* | rootflags=* | ro | single | install)
617 crashkernel=*)
618 bootparams="$bootparams $i"
620 kdump_nfs=*)
621 kdump_nfs=${i#kdump_nfs=}
623 iscsi_name=*)
624 iscsi_name=${i#iscsi_name=}
626 swap_encrypt=* | ovirt_swap_encrypt=* )
627 i=${i#ovirt_swap_encrypt=}
628 i=${i#swap_encrypt=}
629 eval $(printf $i|awk -F\; '{ print "swap1="$1; print "swap2="$2; }')
630 for p in 1 2; do
631 var=swap$p
632 swapdev=
633 swapcyph=
634 local default_cypher="aes-cbc-essiv:sha256"
635 if [ -n "${!var}" ]; then
636 eval $(printf ${!var} |awk -F, '{ print "swapdev="$1; print "swapcyph="$2; }')
637 if [ "${swapdev}" = "Swap" ]; then
638 if [ -n "${swapcyph}" ]; then
639 crypt_swap=${swapcyph}
640 else
641 crypt_swap=${default_cypher}
643 elif [ "${swapdev}" = "Swap2" ]; then
644 if [ -n "${swapcyph}" ]; then
645 crypt_swap2=${swapcyph}
646 else
647 crypt_swap2=${default_cypher}
651 done
654 # check the params to be ignored before adding to bootparams
655 varname=${i%=*}
656 if ! grep -qw $varname /etc/ovirt-commandline.d/* 2>/dev/null; then
657 bootparams="$bootparams $i"
660 esac
661 done
663 for hook in $ovirt_early; do
664 pre="$EARLY_DIR/pre-$hook"
665 if [ -e "$pre" ]; then
666 . "$pre"
668 done
670 if [ -z "$ip_netmask" ]; then
671 ip_netmask=$netmask
673 if [ -z "$ip_gateway" ]; then
674 ip_gateway=$gateway
676 # Handle uninstall arg
677 # need to wipe mbr if passed
678 if [ "$uninstall" = "yes" ]; then
679 oldIFS=$IFS
680 log "Found uninstall arg, wiping mbr from init disks"
681 IFS=$SEP
682 for init_disk in $init $init_app $(get_boot_device); do
683 echo "Wiping $init_disk"
684 wipe_mbr "$init_disk"
685 done
686 IFS=$oldIFS
687 log "Uninstall complete, rebooting"
688 /sbin/reboot
692 # save boot parameters as defaults for ovirt-config-*
694 params="bootif init init_app vol_boot_size vol_swap_size vol_root_size vol_config_size vol_logging_size vol_data_size vol_swap2_size vol_data2_size crypt_swap crypt_swap2 upgrade standalone overcommit ip_address ip_netmask ip_gateway ipv6 dns ntp vlan ssh_pwauth syslog_server syslog_port collectd_server collectd_port bootparams hostname firstboot rhn_type rhn_url rhn_ca_cert rhn_username rhn_password rhn_profile rhn_activationkey rhn_proxy rhn_proxyuser rhn_proxypassword runtime_mode kdump_nfs iscsi_name snmp_password install netconsole_server netconsole_port"
695 # mount /config unless firstboot is forced
696 if [ "$firstboot" != "1" ]; then
697 mount_config
699 log "Updating $OVIRT_DEFAULTS"
700 tmpaug=$(mktemp)
701 for p in $params; do
702 PARAM=$(uc $p)
703 value=$(ptr $p)
704 if [ -n "$value" -o $p = 'init' -o $p = 'bootif' -o $p = 'upgrade' -o $p = 'install' ]; then
705 log "Updating OVIRT_$PARAM to '$value'"
706 echo "set /files$OVIRT_DEFAULTS/OVIRT_$PARAM '\"$value\"'" \
707 >> $tmpaug
709 done
710 augtool $tmpaug
711 . $OVIRT_DEFAULTS
712 if [ "$firstboot" != "1" -a -f /etc/ovirt-crypttab ]; then
713 mount_crypt_swap
715 if [ -f /etc/sysconfig/network ]; then
716 . /etc/sysconfig/network
717 if [ -n "$HOSTNAME" ]; then
718 hostname $HOSTNAME
722 if [ -n "$adminpw" ]; then
723 log "Setting temporary admin password: $adminpw"
724 unmount_config /etc/passwd /etc/shadow
725 /usr/sbin/usermod -p "$adminpw" admin
726 chage -d 0 admin
728 if [ -n "$rootpw" ]; then
729 log "Setting temporary root password: $rootpw"
730 unmount_config /etc/passwd /etc/shadow
731 /usr/sbin/usermod -p "$rootpw" root
732 chage -d 0 root
734 # check if root or admin password is expired, this might be upon reboot
735 # in case of automated installed with rootpw or adminpw parameter!
736 if LC_ALL=C chage -l root | grep -q "password must be changed" \
737 || LC_ALL=c chage -l admin | grep -q "password must be changed"; then
738 unmount_config /etc/passwd /etc/shadow
739 # PAM will force password change at first login
740 # so make sure we persist it after a successful login
741 cat >> /etc/profile << EOF
742 # added by ovirt-early
743 sudo persist /etc/passwd /etc/shadow
744 if LC_ALL=C sudo chage -l root | grep -q "password must be changed" \
745 || LC_ALL=C sudo chage -l admin | grep -q "password must be changed"; then
746 sudo /usr/libexec/ovirt-functions unmount_config /etc/passwd /etc/shadow
751 if [ "$rescue" = 1 ]; then
752 log "Rescue mode requested, starting emergency shell"
753 stop_log
754 plymouth --hide-splash
755 bash < /dev/console > /dev/console 2> /dev/console
756 plymouth --show-splash
757 start_log
760 # link to the kernel image for kdump
761 chcon -t boot_t /boot-kdump
762 if is_booted_from_local_disk; then
763 mount_boot
764 if [ -f /dev/.initramfs/live/backup-vmlinuz ]; then
765 # try backup image
766 cp -p /dev/.initramfs/live/backup-vmlinuz0 /boot-kdump/vmlinuz-$(uname -r)
767 else
768 cp -p /dev/.initramfs/live/vmlinuz0 /boot-kdump/vmlinuz-$(uname -r)
770 else
771 # try source image
772 mount_live
773 if [ -e /live/*linux/vmlinuz0 ]; then
774 cp -p /live/*linux/vmlinuz0 /boot-kdump/vmlinuz-$(uname -r)
778 if [ "$standalone" = 1 ]; then
779 log "Skip runtime mode configuration."
780 else
781 configure_management_interface
784 rm -f $VAR_SUBSYS_OVIRT_EARLY
786 for hook in $ovirt_early; do
787 post="$EARLY_DIR/post-$hook"
788 if [ -e "$post" ]; then
789 . "$post"
791 done
793 return 0
796 stop_ovirt_early () {
797 echo -n "Stopping ovirt-early: "
798 success
801 reload_ovirt_early () {
802 stop_ovirt_early
803 start_ovirt_early
806 case "$1" in
807 start)
808 [ -f "$VAR_SUBSYS_NODE_CONFIG" ] && exit 0
809 echo -n "Starting ovirt-early: "
811 log "Starting ovirt-early"
812 start_ovirt_early
813 # TEMP fix broken libvirtd.conf
814 sed -c -i '/^log_filters=/d' /etc/libvirt/libvirtd.conf
815 log "Completed ovirt-early"
816 RETVAL=$?
817 } >> $OVIRT_LOGFILE 2>&1
818 test $RETVAL == 0 && success || failure
820 status)
821 status $prog
823 reload)
824 reload_ovirt_early
826 stop)
827 stop_ovirt_early
830 echo "Usage: ovirt-early {start}"
831 RETVAL=2
832 esac
834 exit $RETVAL