summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2014-06-12 15:43:04 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2014-06-12 15:43:04 +0000
commit0317b39de848f2f15727d1a25aa53626e8919a99 (patch)
treeabcffc80902d5060dfae045544b69b17aa311b92
parentc4eaaa7e10688e59c181ea0c6cc6aaf742107e68 (diff)
downloadillumos-joyent-release-20140612.tar.gz
OS-3099 lx brand should handle boot changes after pkg updates20140612release-20140612
-rw-r--r--manifest1
-rw-r--r--usr/src/lib/brand/lx/zone/Makefile2
-rw-r--r--usr/src/lib/brand/lx/zone/lx_boot.ksh52
-rw-r--r--usr/src/lib/brand/lx/zone/lx_boot_zone_ubuntu.ksh217
-rw-r--r--usr/src/lib/brand/lx/zone/lx_init_zone_ubuntu.ksh178
5 files changed, 257 insertions, 193 deletions
diff --git a/manifest b/manifest
index c38ac3af10..eff6d8ad4d 100644
--- a/manifest
+++ b/manifest
@@ -5041,6 +5041,7 @@ f usr/lib/brand/lx/amd64/lx_thunk.so.1 0755 root root
f usr/lib/brand/lx/etc_default_nfs 0444 root root
f usr/lib/brand/lx/etc_netconfig 0444 root root
f usr/lib/brand/lx/lx_boot 0755 root root
+f usr/lib/brand/lx/lx_boot_zone_ubuntu 0755 root root
f usr/lib/brand/lx/lx_init_zone 0755 root root
f usr/lib/brand/lx/lx_init_zone_debian 0755 root root
f usr/lib/brand/lx/lx_init_zone_redhat 0755 root root
diff --git a/usr/src/lib/brand/lx/zone/Makefile b/usr/src/lib/brand/lx/zone/Makefile
index 92695fba65..6e820bd506 100644
--- a/usr/src/lib/brand/lx/zone/Makefile
+++ b/usr/src/lib/brand/lx/zone/Makefile
@@ -27,7 +27,7 @@
PROGS = lx_install lx_distro_install lx_init_zone lx_boot
PROGS += lx_init_zone_debian lx_init_zone_redhat lx_init_zone_ubuntu
-PROGS += lx_networking
+PROGS += lx_networking lx_boot_zone_ubuntu
SUBDIRS = distros
XMLDOCS = config.xml platform.xml
TEMPLATES = SUNWlx.xml SUNWlx26.xml
diff --git a/usr/src/lib/brand/lx/zone/lx_boot.ksh b/usr/src/lib/brand/lx/zone/lx_boot.ksh
index df9c89881e..3c46e056dd 100644
--- a/usr/src/lib/brand/lx/zone/lx_boot.ksh
+++ b/usr/src/lib/brand/lx/zone/lx_boot.ksh
@@ -105,21 +105,39 @@ wrap_with_native() {
#
# Before we boot we validate and fix, if necessary, the required files within
-# the zone. These modifications can be lost if a patch is applied within the
-# zone, so we validate and fix the zone every time it boots.
+# the zone. These modifications can be lost if a patch or upgrade is applied
+# within the zone, so we validate and fix the zone every time it boots.
#
#
+# Determine the distro.
+#
+distro=""
+if [[ -f $ZONEROOT/etc/redhat-release ]]; then
+ distro="redhat"
+elif [[ -f $ZONEROOT/etc/lsb-release ]]; then
+ if egrep -s Ubuntu $ZONEROOT/etc/lsb-release; then
+ distro="ubuntu"
+ elif [[ -f $ZONEROOT/etc/debian_version ]]; then
+ distro="debian"
+ fi
+elif [[ -f $ZONEROOT/etc/debian_version ]]; then
+ distro="debian"
+fi
+
+[[ -z $distro ]] && fatal "Unsupported distribution!"
+
+#
# BINARY REPLACEMENT
#
-# This section of the boot script is responsible for replacing Solaris 10
-# binaries within the booting zone with Nevada binaries. This is a two-step
+# This section of the boot script is responsible for replacing Linux
+# binaries within the booting zone with native binaries. This is a two-step
# process: First, the directory structure of the zone is validated to ensure
-# that binary replacement will proceed safely. Second, Solaris 10 binaries
-# are replaced with Nevada binaries.
+# that binary replacement will proceed safely. Second, the Linux binaries
+# are replaced with native binaries.
#
# Here's an example. Suppose that you want to replace /usr/bin/zcat with the
-# Nevada /usr/bin/zcat binary. Then you should do the following:
+# native /usr/bin/zcat binary. Then you should do the following:
#
# 1. Go to the section below labeled "STEP ONE" and add the following
# two lines:
@@ -142,24 +160,30 @@ wrap_with_native() {
# Validate that the zone filesystem looks like we expect it to.
#
safe_dir /sbin
+safe_dir /etc
+safe_dir /etc/init
+safe_dir /etc/update-motd.d
#
# STEP TWO
#
# Replace Linux binaries with native binaries.
#
+replace_with_native /sbin/ifconfig 0555 root:bin
#
-# Replace various network-related programs with native wrappers.
+# STEP THREE
#
-replace_with_native /sbin/ifconfig 0555 root:bin
-
-# Create native wrapper for illumos-only commands
-wrap_with_native /sbin/dladm 0555 root:bin
-wrap_with_native /sbin/ipmgmtd 0555 root:bin
+# Perform distro-specific customization.
+#
+. $(dirname $0)/lx_boot_zone_${distro}
#
-# END OF STEP TWO
+# STEP FOUR
#
+# Create native wrappers for illumos-only commands
+#
+wrap_with_native /sbin/dladm 0555 root:bin
+wrap_with_native /sbin/ipmgmtd 0555 root:bin
exit 0
diff --git a/usr/src/lib/brand/lx/zone/lx_boot_zone_ubuntu.ksh b/usr/src/lib/brand/lx/zone/lx_boot_zone_ubuntu.ksh
new file mode 100644
index 0000000000..f72d6356f7
--- /dev/null
+++ b/usr/src/lib/brand/lx/zone/lx_boot_zone_ubuntu.ksh
@@ -0,0 +1,217 @@
+#!/bin/ksh -p
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source. A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2014 Joyent, Inc. All rights reserved.
+#
+
+#
+# Customisation for Ubuntu-based distributions. Assumes to have been
+# sourced from lx_boot.
+#
+
+RMSVCS="acpid.conf
+ control-alt-delete.conf
+ console-setup.conf
+ dmesg.conf
+ hwclock.conf
+ hwclock-save.conf
+ irqbalance.conf
+ module-init-tools.conf
+ mounted-dev.conf
+ mounted-debugfs.conf
+ network-interface-security.conf
+ plymouth.conf
+ plymouth-log.conf
+ plymouth-splash.conf
+ plymouth-stop.conf
+ plymouth-upstart-bridge.conf
+ setvtrgb.conf
+ tty1.conf
+ tty2.conf
+ tty3.conf
+ tty4.conf
+ tty5.conf
+ tty6.conf
+ upstart-udev-bridge.conf
+ udev.conf
+ udevmonitor.conf
+ udevtrigger.conf
+ udev-fallback-graphics.conf
+ udev-finish.conf
+ ureadahead-other.conf
+ ureadahead.conf
+ whoopsie.conf"
+
+
+#
+# Now customize upstart
+#
+
+for f in $RMSVCS
+do
+ fnm=$ZONEROOT/etc/init/$f
+ [[ ! -h $fnm && -f $fnm ]] && rm -f $fnm
+done
+
+fnm=$ZONEROOT/etc/init/console.conf
+if [[ ! -h $fnm && -f $fnm ]] then
+ sed -e 's/lxc/zones/' $fnm > /tmp/console.conf.$$
+ mv /tmp/console.conf.$$ $fnm
+fi
+
+fnm=$ZONEROOT/etc/init/container-detect.conf
+if [[ ! -h $fnm && -f $fnm ]] then
+ cat <<'DONE' > $fnm
+description "Track if upstart is running in a container"
+
+start on mounted MOUNTPOINT=/run
+
+env container
+env LIBVIRT_LXC_UUID
+
+emits container
+
+pre-start script
+ container=zones
+ echo "$container" > /run/container_type || true
+ initctl emit --no-wait container CONTAINER=$container
+ exit 0
+end script
+DONE
+fi
+
+# XXX use original dbus.conf once /run is mounted as a tmpfs mount and we
+# don't need to cleanup the pid
+
+fnm=$ZONEROOT/etc/init/dbus.conf
+if [[ ! -h $fnm && -f $fnm ]] then
+ cat <<'DONE' > $fnm
+description "D-Bus system message bus"
+
+start on local-filesystems
+stop on deconfiguring-networking
+
+expect fork
+respawn
+
+pre-start script
+ rm -f /run/dbus/pid
+
+ mkdir -p /var/run/dbus
+ chown messagebus:messagebus /var/run/dbus
+
+ exec dbus-uuidgen --ensure
+end script
+
+exec dbus-daemon --system --fork --activation=upstart
+
+post-start exec kill -USR1 1
+
+post-stop exec rm -f /var/run/dbus/pid
+DONE
+fi
+
+# XXX need to add real mounting into this svc definition
+
+fnm=$ZONEROOT/etc/init/mountall.conf
+if [[ ! -h $fnm && -f $fnm ]] then
+ cat <<'DONE' > $fnm
+description "Mount filesystems on boot"
+
+start on startup
+
+task
+
+emits virtual-filesystems
+emits local-filesystems
+emits remote-filesystems
+emits all-swaps
+emits filesystem
+emits mounted
+
+script
+ /sbin/initctl emit --no-wait virtual-filesystems
+# mount -F tmpfs swap /run || true
+ /sbin/initctl emit --no-wait mounted MOUNTPOINT=/run
+ /sbin/initctl emit --no-wait local-filesystems
+ /sbin/initctl emit --no-wait all-swaps
+ /sbin/initctl emit --no-wait filesystem
+end script
+DONE
+fi
+
+# XXX fix up IP handling and multiple net definitions
+
+iptype=`/usr/sbin/zonecfg -z $ZONENAME info ip-type | cut -f2 -d' '`
+
+if [[ "$iptype" == "exclusive" ]]; then
+ ipaddr=`/usr/sbin/zonecfg -z $ZONENAME info net | \
+ nawk -F, '/name=ip/{print substr($2, 8, length($2) - 9)}'`
+ netmask=`/usr/sbin/zonecfg -z $ZONENAME info net | \
+ nawk -F, '/name=netmask/{print substr($2,8,length($2)-9)}'`
+
+ fnm=$ZONEROOT/etc/init/networking.conf
+ if [[ ! -h $fnm && -f $fnm ]] then
+ cat <<-DONE > $fnm
+ description "configure virtual network devices"
+
+ emits static-network-up
+ emits net-device-up
+
+ start on local-filesystems
+
+ task
+
+ pre-start exec mkdir -p /run/network
+
+ script
+ /sbin/ipmgmtd || true
+ /sbin/ifconfig lo0 plumb
+ /sbin/initctl emit --no-wait net-device-up IFACE=lo LOGICAL=lo ADDRFAM=inet METHOD=loopback || true
+ /sbin/ifconfig net0 plumb || true
+ /sbin/ifconfig net0 $ipaddr netmask $netmask up || true
+ /sbin/initctl emit --no-wait net-device-up IFACE=net0
+ /sbin/initctl emit --no-wait static-network-up
+ end script
+ DONE
+ fi
+fi
+
+fnm=$ZONEROOT/etc/init/plymouth-ready.conf
+if [[ ! -h $fnm && -f $fnm ]] then
+ cat <<'DONE' > $fnm
+description "Send an event to indicate plymouth is up"
+
+task
+start on startup
+instance $UPSTART_EVENTS
+
+emits plymouth-ready
+
+script
+ initctl emit --no-wait plymouth-ready
+end script
+DONE
+fi
+
+#
+# upstart modifications are complete
+#
+
+# XXX remove this since it blocks login until we can root cause and fix, might
+# be the rtnetlink issue
+
+fnm=$ZONEROOT/etc/update-motd.d/50-landscape-sysinfo
+[[ -h $fnm ]] && rm -f $fnm
+
+# Hand control back to lx_boot
diff --git a/usr/src/lib/brand/lx/zone/lx_init_zone_ubuntu.ksh b/usr/src/lib/brand/lx/zone/lx_init_zone_ubuntu.ksh
index c1020b0c6b..e46c536ea3 100644
--- a/usr/src/lib/brand/lx/zone/lx_init_zone_ubuntu.ksh
+++ b/usr/src/lib/brand/lx/zone/lx_init_zone_ubuntu.ksh
@@ -19,185 +19,7 @@
# sourced from lx_init_zone.
#
-RMSVCS="acpid.conf
- control-alt-delete.conf
- console-setup.conf
- dmesg.conf
- hwclock.conf
- hwclock-save.conf
- irqbalance.conf
- module-init-tools.conf
- mounted-dev.conf
- mounted-debugfs.conf
- network-interface-security.conf
- plymouth.conf
- plymouth-log.conf
- plymouth-splash.conf
- plymouth-stop.conf
- plymouth-upstart-bridge.conf
- setvtrgb.conf
- tty1.conf
- tty2.conf
- tty3.conf
- tty4.conf
- tty5.conf
- tty6.conf
- upstart-udev-bridge.conf
- udev.conf
- udevmonitor.conf
- udevtrigger.conf
- udev-fallback-graphics.conf
- udev-finish.conf
- ureadahead-other.conf
- ureadahead.conf
- whoopsie.conf"
-
-
# Use the debian script to begin with
. $(dirname $0)/lx_init_zone_debian
-#
-# Now customize upstart
-#
-
-for f in $RMSVCS
-do
- rm -f etc/init/$f
-done
-
-sed -e 's/lxc/zones/' /zones/$zonename/root/etc/init/console.conf \
- >/zones/$zonename/root/etc/init/console.conf.new
-mv /zones/$zonename/root/etc/init/console.conf.new \
- /zones/$zonename/root/etc/init/console.conf
-
-cat <<'DONE' > etc/init/container-detect.conf
-description "Track if upstart is running in a container"
-
-start on mounted MOUNTPOINT=/run
-
-env container
-env LIBVIRT_LXC_UUID
-
-emits container
-
-pre-start script
- container=zones
- echo "$container" > /run/container_type || true
- initctl emit --no-wait container CONTAINER=$container
- exit 0
-end script
-DONE
-
-# XXX use original dbus.conf once /run is mounted as a tmpfs mount and we
-# don't need to cleanup the pid
-
-cat <<'DONE' > etc/init/dbus.conf
-description "D-Bus system message bus"
-
-start on local-filesystems
-stop on deconfiguring-networking
-
-expect fork
-respawn
-
-pre-start script
- rm -f /run/dbus/pid
-
- mkdir -p /var/run/dbus
- chown messagebus:messagebus /var/run/dbus
-
- exec dbus-uuidgen --ensure
-end script
-
-exec dbus-daemon --system --fork --activation=upstart
-
-post-start exec kill -USR1 1
-
-post-stop exec rm -f /var/run/dbus/pid
-DONE
-
-# XXX need to add real mounting into this svc definition
-
-cat <<'DONE' > etc/init/mountall.conf
-description "Mount filesystems on boot"
-
-start on startup
-
-task
-
-emits virtual-filesystems
-emits local-filesystems
-emits remote-filesystems
-emits all-swaps
-emits filesystem
-emits mounted
-
-script
- /sbin/initctl emit --no-wait virtual-filesystems
-# mount -F tmpfs swap /run || true
- /sbin/initctl emit --no-wait mounted MOUNTPOINT=/run
- /sbin/initctl emit --no-wait local-filesystems
- /sbin/initctl emit --no-wait all-swaps
- /sbin/initctl emit --no-wait filesystem
-end script
-DONE
-
-# XXX fix up IP handling and multiple net definitions
-
-iptype=`/usr/sbin/zonecfg -z $zonename info ip-type | cut -f2 -d' '`
-
-if [[ "$iptype" == "exclusive" ]]; then
- ipaddr=`/usr/sbin/zonecfg -z $zonename info net | \
- nawk -F, '/name=ip/{print substr($2, 8, length($2) - 9)}'`
- netmask=`/usr/sbin/zonecfg -z $zonename info net | \
- nawk -F, '/name=netmask/{print substr($2,8,length($2)-9)}'`
-
- cat <<-DONE > etc/init/networking.conf
- description "configure virtual network devices"
-
- emits static-network-up
- emits net-device-up
-
- start on local-filesystems
-
- task
-
- pre-start exec mkdir -p /run/network
-
- script
- /sbin/ipmgmtd || true
- /sbin/ifconfig lo0 plumb
- /sbin/initctl emit --no-wait net-device-up IFACE=lo LOGICAL=lo ADDRFAM=inet METHOD=loopback || true
- /sbin/ifconfig net0 plumb || true
- /sbin/ifconfig net0 $ipaddr netmask $netmask up || true
- /sbin/initctl emit --no-wait net-device-up IFACE=net0
- /sbin/initctl emit --no-wait static-network-up
- end script
- DONE
-fi
-
-cat <<'DONE' > etc/init/plymouth-ready.conf
-description "Send an event to indicate plymouth is up"
-
-task
-start on startup
-instance $UPSTART_EVENTS
-
-emits plymouth-ready
-
-script
- initctl emit --no-wait plymouth-ready
-end script
-DONE
-
-#
-# upstart modifications are complete
-#
-
-# XXX remove this since it blocks login until we can root cause and fix, might
-# be the rtnetlink issue
-
-rm -f /zones/$zonename/root/etc/update-motd.d/50-landscape-sysinfo
-
# Hand control back to lx_init_zone
-#