diff --git a/Dockerfile b/Dockerfile index 8e66342b2..039923272 100644 --- a/Dockerfile +++ b/Dockerfile @@ -62,7 +62,8 @@ ENV TCZ_DEPS iptables \ xz liblzma \ git expat2 libiconv libidn libgpg-error libgcrypt libssh2 \ nfs-utils tcp_wrappers portmap rpcbind libtirpc \ - curl ntpclient + curl ntpclient \ + procps glib2 libtirpc libffi fuse # Make the ROOTFS RUN mkdir -p $ROOTFS @@ -150,6 +151,53 @@ RUN mkdir -p /vboxguest && \ mkdir -p $ROOTFS/sbin && \ cp x86/lib/VBoxGuestAdditions/mount.vboxsf $ROOTFS/sbin/ +# Build VMware Tools +ENV OVT_VERSION 9.4.6-1770165 + +# Download and prepare ovt source +RUN mkdir -p /vmtoolsd/open-vm-tools \ + && curl -L http://downloads.sourceforge.net/open-vm-tools/open-vm-tools-$OVT_VERSION.tar.gz \ + | tar -xzC /vmtoolsd/open-vm-tools --strip-components 1 + +# Apply patches to make open-vm-tools compile with a recent 3.18.x kernel and +# a network script that knows how to plumb/unplumb nics on a busybox system, +# this will be removed once a new ovt version is released. +RUN cd /vmtoolsd && \ + curl -L -o open-vm-tools-3.x.x-patches.patch https://gist.github.com/frapposelli/5506651fa6f3d25d5760/raw/475f8fb2193549c10a477d506de40639b04fa2a7/open-vm-tools-3.x.x-patches.patch &&\ + patch -p1 < open-vm-tools-3.x.x-patches.patch && rm open-vm-tools-3.x.x-patches.patch + +RUN dpkg --add-architecture i386 && apt-get update && apt-get install -y libfuse2 libtool autoconf \ + libglib2.0-dev libdumbnet-dev:i386 \ + libdumbnet1:i386 libfuse2:i386 libfuse-dev \ + libglib2.0-0:i386 libtirpc-dev libtirpc1:i386 + +# Horrible Hack +RUN ln -s /lib/i386-linux-gnu/libglib-2.0.so.0.3200.4 /lib/i386-linux-gnu/libglib-2.0.so &&\ + ln -s /lib/i386-linux-gnu/libtirpc.so.1.0.10 /lib/i386-linux-gnu/libtirpc.so &&\ + ln -s /usr/lib/i386-linux-gnu/libgthread-2.0.so.0 /usr/lib/i386-linux-gnu/libgthread-2.0.so &&\ + ln -s /usr/lib/i386-linux-gnu/libgmodule-2.0.so.0 /usr/lib/i386-linux-gnu/libgmodule-2.0.so &&\ + ln -s /usr/lib/i386-linux-gnu/libgobject-2.0.so.0 /usr/lib/i386-linux-gnu/libgobject-2.0.so &&\ + ln -s /lib/i386-linux-gnu/libfuse.so.2 /lib/i386-linux-gnu/libfuse.so + +# Compile open-vm-tools +RUN cd /vmtoolsd/open-vm-tools && autoreconf -i &&\ + CC="gcc -m32" CXX="g++ -m32" ./configure --host=i486-pc-linux-gnu --build=i486-pc-linux-gnu \ + --without-kernel-modules --without-pam --without-procps --without-x --without-icu &&\ + make CC="gcc -m32" CXX="g++ -m32" LIBS="-ltirpc" CFLAGS="-Wno-implicit-function-declaration" &&\ + make DESTDIR=$ROOTFS install + +# Download and compile libdnet as open-vm-tools rely on it. +ENV LIBDNET libdnet-1.11 + +RUN mkdir -p /vmtoolsd/${LIBDNET} &&\ + curl -L http://sourceforge.net/projects/libdnet/files/libdnet/${LIBDNET}/${LIBDNET}.tar.gz \ + | tar -xzC /vmtoolsd/${LIBDNET} --strip-components 1 &&\ + cd /vmtoolsd/${LIBDNET} && ./configure --build=i486-pc-linux-gnu &&\ + make CC="gcc -m32" CXX="g++ -m32" &&\ + make install && make DESTDIR=$ROOTFS install + +RUN cd $ROOTFS && cd usr/local/lib && ln -s libdnet.1 libdumbnet.so.1 + # Make sure that all the modules we might have added are recognized (especially VBox guest additions) RUN depmod -a -b $ROOTFS $KERNEL_VERSION-tinycore64 diff --git a/kernel_config b/kernel_config index 1fe9f7f2e..bcc5d4da5 100644 --- a/kernel_config +++ b/kernel_config @@ -1532,7 +1532,7 @@ CONFIG_TIFM_7XX1=m # CONFIG_SENSORS_APDS990X is not set # CONFIG_HMC6352 is not set # CONFIG_DS1682 is not set -# CONFIG_VMWARE_BALLOON is not set +CONFIG_VMWARE_BALLOON=m # CONFIG_BMP085_I2C is not set # CONFIG_USB_SWITCH_FSA9480 is not set # CONFIG_SRAM is not set diff --git a/rootfs/rootfs/bootscript.sh b/rootfs/rootfs/bootscript.sh index 7f99dd255..1a3a4244a 100755 --- a/rootfs/rootfs/bootscript.sh +++ b/rootfs/rootfs/bootscript.sh @@ -82,3 +82,6 @@ fi if modprobe hv_utils &> /dev/null; then /usr/sbin/hv_kvp_daemon fi + +# Launch vmware-tools +/etc/rc.d/vmtoolsd diff --git a/rootfs/rootfs/etc/rc.d/automount b/rootfs/rootfs/etc/rc.d/automount index 3cb637a07..e38fc1b3d 100755 --- a/rootfs/rootfs/etc/rc.d/automount +++ b/rootfs/rootfs/etc/rc.d/automount @@ -34,6 +34,37 @@ if [ ! -n "$BOOT2DOCKER_DATA" ]; then mkfs.ext4 -L $LABEL $BOOT2DOCKER_DATA swapon "${UNPARTITIONED_HD}2" fi + + DISK_VENDOR=$(cat /sys/class/block/$(basename $UNPARTITIONED_HD /dev/)/device/vendor /sys/class/block/$(basename $UNPARTITIONED_HD /dev/)/device/model | tr -d "\n") + # Test if disk is "VMware, VMware Virtual S" and empty. + if [ "$DISK_VENDOR" = "VMware, VMware Virtual S" ] || [ "$DISK_VENDOR" = "VMware Virtual disk " ]; then + # Check whether the disk has any known partitions on it + blkid -o device $UNPARTITIONED_HD + if [ $? == 2 ]; then + # As there are no partitions, let's make sure the disk is empty for real + dd if=$UNPARTITIONED_HD of=device_test_file bs=1k count=256 > /dev/null 2>&1 + NON_NUL=$( /home/docker/log.log + + # Add a swap partition (so Docker doesn't complain about it missing) + (echo n; echo p; echo 2; echo ; echo +1000M ; echo w) | fdisk $UNPARTITIONED_HD + (echo t; echo 82) | fdisk $UNPARTITIONED_HD + mkswap "${UNPARTITIONED_HD}2" + # Add the data partition + (echo n; echo p; echo 1; echo ; echo ; echo w) | fdisk $UNPARTITIONED_HD + BOOT2DOCKER_DATA=`echo "${UNPARTITIONED_HD}1"` + mkfs.ext4 -L $LABEL $BOOT2DOCKER_DATA + swapon "${UNPARTITIONED_HD}2" + else + echo "Disk unpartitioned but something is there... not doing anything" + fi + else + echo "Partition table found on disk, not doing anything" + fi + fi else # Pick the first ext4 as a fallback # TODO: mount all Linux partitions and look for a /var/lib/docker... diff --git a/rootfs/rootfs/etc/rc.d/vmtoolsd b/rootfs/rootfs/etc/rc.d/vmtoolsd new file mode 100644 index 000000000..c00050357 --- /dev/null +++ b/rootfs/rootfs/etc/rc.d/vmtoolsd @@ -0,0 +1,5 @@ +#!/bin/sh + +# vmtoolsd will start only if it can connect to the vmx backdoor, will +# quit immediately if not running on a VMware-based system. +/usr/local/bin/vmtoolsd --background /var/run/vmtoolsd.pid diff --git a/rootfs/rootfs/sbin/shutdown b/rootfs/rootfs/sbin/shutdown new file mode 100755 index 000000000..d9d230e46 --- /dev/null +++ b/rootfs/rootfs/sbin/shutdown @@ -0,0 +1,32 @@ +#!/bin/sh + +usage() +{ + echo 'Usage: shutdown [-rh] time + -r: reboot after shutdown. + -h: halt after shutdown. + ** the "time" argument is mandatory! (try "now") **' >&2 + exit 1 +} + +case $1 in + -r) CMD="/bin/busybox reboot" + ;; + -h) CMD="/bin/busybox poweroff" + ;; + *) usage + ;; +esac + +shift + +case $1 in + now|+0) DELAY="" + ;; + +[0-9]*) DELAY=$(($1 * 60)) + ;; + *) usage + ;; +esac + +${CMD}${DELAY:+ -d $DELAY} diff --git a/rootfs/rootfs/usr/local/bin/lsb_release b/rootfs/rootfs/usr/local/bin/lsb_release new file mode 100755 index 000000000..cd1764611 --- /dev/null +++ b/rootfs/rootfs/usr/local/bin/lsb_release @@ -0,0 +1,8 @@ +#!/bin/sh +# just to make open-vm-tools happy, nad fake output +# of lsb_release -sd +. /etc/os-release +echo $PRETTY_NAME + +exit 0 +