diff --git a/alpine/packages/automount/etc/init.d/automount b/alpine/packages/automount/etc/init.d/automount index 0e1c58be8..6426e907c 100755 --- a/alpine/packages/automount/etc/init.d/automount +++ b/alpine/packages/automount/etc/init.d/automount @@ -10,7 +10,24 @@ start() { ebegin "Configuring host block device" - DEV="$(find /dev -maxdepth 1 -type b ! -name 'loop*' | grep -v '[0-9]$' | sed 's@.*/dev/@@' | head -1 )" + # We are being specific with Azure for now. Otherwise the subshell + # below will reference /dev/sdb, which is Azure's "local resource disk" + # (see + # https://blogs.msdn.microsoft.com/mast/2013/12/06/understanding-the-temporary-drive-on-windows-azure-virtual-machines/). + # + # Since attempting to format swap on that disk will cause Azure VHD + # validation to fail, we default to using /dev/sda. requirements + # including not allowing swap partitions. + # + # IMPORTANT: If this, or the root device (/dev/sda1) changes in the + # syslinux / bootloader config for Azure, they will need to be updated + # in parallel. + if [ "$(mobyplatform)" = "azure" ] + then + DEV="sda" + else + DEV="$(find /dev -maxdepth 1 -type b ! -name 'loop*' | grep -v '[0-9]$' | sed 's@.*/dev/@@' | head -1 )" + fi [ -z "${DEV}" ] && exit 1 diff --git a/alpine/packages/azure/etc/init.d/azure b/alpine/packages/azure/etc/init.d/azure index 6a9ed489b..39edea7e1 100755 --- a/alpine/packages/azure/etc/init.d/azure +++ b/alpine/packages/azure/etc/init.d/azure @@ -13,13 +13,6 @@ start() [ "$(mobyplatform)" != "azure" ] && exit 0 ebegin "Running Azure-specific initialization" - einfo "Setting hostname" - - # TODO: This is probably quite fragile (splitting the returned JSON by - # quotes instead of properly parsing). Would bundling 'jq' in Moby be - # too much overhead? - hostname $(wget -qO- http://169.254.169.254/metadata/v1/instanceinfo | awk -F '"' '{ print $4; }') - for i in $(seq 1 20) do einfo "Pulling Windows Azure Linux Agent container" @@ -47,12 +40,15 @@ start() --ipc host \ --pid host \ --net host \ + --uts host \ --restart unless-stopped \ -v /usr/bin/docker:/usr/local/bin/docker:ro \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /var/log:/var/log \ + -v /mnt:/mnt \ -v /home:/home \ -v /etc:/etc \ + -v /etc/hostname:/etc/hostname \ -v /lib/modules:/lib/modules \ -v /lib/firmware:/lib/firmware \ -v /var/lib/waagent:/var/lib/waagent \ @@ -70,12 +66,18 @@ start() passwd -u docker checkpath --directory --mode 0700 /home/docker/.ssh - # Wait for custom data to arrive - while [ ! -f /var/lib/waagent/CustomData ] + # Wait for WALinux agent provisioning to finish before invoking the + # passed custom data. This assures us that hostname etc. is set + # correctly before running, say, swarm commmands. + while [ ! -f /var/lib/waagent/provisioned ] do sleep 5 done + # Hack to fix swarm hostname issue. See + # https://github.com/docker/docker/issues/27173 + service docker restart + . /var/lib/waagent/CustomData eend 0