diff options
Diffstat (limited to 'fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig')
-rwxr-xr-x | fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig | 109 |
1 files changed, 101 insertions, 8 deletions
diff --git a/fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig b/fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig index 6c18a6df2..1bc349314 100755 --- a/fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig +++ b/fuel/build/f_isoroot/f_bootstrap/bootstrap_admin_node.sh.orig @@ -5,7 +5,7 @@ function countdown() { local i sleep 1 for ((i=$1-1; i>=1; i--)); do - printf '\b\b%02d' "$i" + printf '\b\b\b\b%04d' "$i" sleep 1 done } @@ -16,13 +16,18 @@ function fail() { } # LANG variable is a workaround for puppet-3.4.2 bug. See LP#1312758 for details export LANG=en_US.UTF8 +export ADMIN_INTERFACE=eth0 + showmenu="no" -if [ -f /root/.showfuelmenu ]; then - . /root/.showfuelmenu +if [ -f /etc/fuel/bootstrap_admin_node.conf ]; then + . /etc/fuel/bootstrap_admin_node.conf + echo "Applying admin interface '$ADMIN_INTERFACE'" fi -echo -n "Applying default Fuel settings..." -fuelmenu --save-only --iface=eth0 +echo "Applying default Fuel settings..." +set -x +fuelmenu --save-only --iface=$ADMIN_INTERFACE +set +x echo "Done!" if [[ "$showmenu" == "yes" || "$showmenu" == "YES" ]]; then @@ -30,7 +35,7 @@ if [[ "$showmenu" == "yes" || "$showmenu" == "YES" ]]; then else #Give user 15 seconds to enter fuelmenu or else continue echo - echo -n "Press a key to enter Fuel Setup (or press ESC to skip)... 15" + echo -n "Press a key to enter Fuel Setup (or press ESC to skip)... 15" countdown 15 & pid=$! if ! read -s -n 1 -t 15 key; then echo -e "\nSkipping Fuel Setup..." @@ -46,11 +51,89 @@ if [[ "$showmenu" == "yes" || "$showmenu" == "YES" ]]; then fi fi +if [ "$wait_for_external_config" == "yes" ]; then + wait_timeout=3000 + pidfile=/var/lock/wait_for_external_config + echo -n "Waiting for external configuration (or press ESC to skip)... +$wait_timeout" + countdown $wait_timeout & countdown_pid=$! + exec -a wait_for_external_config sleep $wait_timeout & wait_pid=$! + echo $wait_pid > $pidfile + while ps -p $countdown_pid &> /dev/null && ps -p $wait_pid &>/dev/null; do + read -s -n 1 -t 2 key + case "$key" in + $'\e') echo -e "\b\b\b\b abort on user input" + break + ;; + *) ;; + esac + done + { kill $countdown_pid $wait_pid & wait $!; } + rm -f $pidfile +fi + #Reread /etc/sysconfig/network to inform puppet of changes . /etc/sysconfig/network hostname "$HOSTNAME" +# XXX: ssh keys which should be included into the bootstrap image are +# generated during containers deployment. However cobbler checkfs for +# a kernel and initramfs when creating a profile, which poses chicken +# and egg problem. Fortunately cobbler is pretty happy with empty files +# so it's easy to break the loop. +make_ubuntu_bootstrap_stub () { + local bootstrap_dir='/var/www/nailgun/bootstrap/ubuntu' + mkdir -p $bootstrap_dir + for item in linux initramfs.img; do + touch "$bootstrap_dir/$item" + done +} + +get_bootstrap_flavor () { + local ASTUTE_YAML='/etc/fuel/astute.yaml' + python <<-EOF + from fuelmenu.fuelmenu import Settings + conf = Settings().read("$ASTUTE_YAML").get('BOOTSTRAP', {}) + print(conf.get('flavor', 'centos')) + EOF +} + +# Actually build the bootstrap image +build_ubuntu_bootstrap () { + local ret=1 + local max_attempts=3 + local config='/etc/fuel-bootstrap-image.conf' + local log='/var/log/fuel-bootstrap-image-build.log' + if ! grep -qE '^BOOTSTRAP_SSH_KEYS' "$config"; then + # FIXME: config file generated by fuelmenu has no trailing newline + echo >> "$config" + cat >> "$config" <<-EOF + BOOTSTRAP_SSH_KEYS=/root/.ssh/id_rsa.pub + EOF + fi + for n in `seq 1 $max_attempts`; do + echo "Bulding bootstrap image, attempt $n" >&2 + if fuel-bootstrap-image >>"$log" 2>&1; then + ret=0 + fuel-bootstrap-image-set "ubuntu" + break + fi + done + if [ $ret -ne 0 ]; then + warning="WARNING: failed to build the bootstrap image, see $log for details. +Perhaps your Internet connection is broken. Please fix the problem and run +\`fuel-bootstrap-image-set ubuntu\`" + fuel notify --topic warning --send "$warning" + fi + return $ret +} + + +# Create empty files to make cobbler happy +# (even if we don't use Ubuntu based bootstrap) +make_ubuntu_bootstrap_stub + service docker start if [ -f /root/.build_images ]; then @@ -96,16 +179,21 @@ puppet apply --detailed-exitcodes -d -v /etc/puppet/modules/nailgun/examples/hos if [ $? -ge 4 ];then fail fi + rmdir /var/log/remote && ln -s /var/log/docker-logs/remote /var/log/remote dockerctl check || fail bash /etc/rc.local +if [ "`get_bootstrap_flavor`" = "ubuntu" ]; then + build_ubuntu_bootstrap || true +fi + # Enable updates repository cat > /etc/yum.repos.d/mos${FUEL_RELEASE}-updates.repo << EOF [mos${FUEL_RELEASE}-updates] name=mos${FUEL_RELEASE}-updates -baseurl=http://mirror.fuel-infra.org/mos/centos-6/mos${FUEL_RELEASE}/updates/ +baseurl=http://mirror.fuel-infra.org/mos-repos/centos/mos${FUEL_RELEASE}-centos6-fuel/updates/x86_64/ gpgcheck=0 skip_if_unavailable=1 EOF @@ -114,7 +202,7 @@ EOF cat > /etc/yum.repos.d/mos${FUEL_RELEASE}-security.repo << EOF [mos${FUEL_RELEASE}-security] name=mos${FUEL_RELEASE}-security -baseurl=http://mirror.fuel-infra.org/mos/centos-6/mos${FUEL_RELEASE}/security/ +baseurl=http://mirror.fuel-infra.org/mos-repos/centos/mos${FUEL_RELEASE}-centos6-fuel/security/x86_64/ gpgcheck=0 skip_if_unavailable=1 EOF @@ -150,4 +238,9 @@ echo "*************************************************" echo "Sending notification to Fuel UI..." fuel notify --topic "${level}" --send "${message}" +# TODO(kozhukalov) If building of bootstrap image fails +# and if this image was supposed to be a default bootstrap image +# we need to warn a user about this and give her +# advice how to treat this. + echo "Fuel node deployment complete!" |