mirror of
https://github.com/linuxkit/linuxkit.git
synced 2026-01-29 23:52:29 +00:00
Merge pull request #284 from nathanleclaire/azure
Add support for Azure (VHD) build to Moby
This commit is contained in:
116
alpine/packages/azure/etc/init.d/azure
Executable file
116
alpine/packages/azure/etc/init.d/azure
Executable file
@@ -0,0 +1,116 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
description="Bootstrap procedure if running on Docker Azure edition"
|
||||
|
||||
depend()
|
||||
{
|
||||
need docker
|
||||
need networking
|
||||
}
|
||||
|
||||
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"
|
||||
|
||||
docker pull nathanleclaire/walinuxagent >/dev/null
|
||||
|
||||
einfo "Running Windows Azure Linux Agent container"
|
||||
|
||||
docker run -d \
|
||||
--name waagent \
|
||||
--privileged \
|
||||
--restart unless-stopped \
|
||||
--net host \
|
||||
--ipc host \
|
||||
--pid host \
|
||||
-v /home:/home \
|
||||
-v /etc:/etc \
|
||||
-v /lib/modules:/lib/modules \
|
||||
-v /lib/firmware:/lib/firmware \
|
||||
-v /var/log:/var/log \
|
||||
-v /var/lib/waagent:/var/lib/waagent \
|
||||
nathanleclaire/walinuxagent
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
break
|
||||
fi
|
||||
|
||||
# Wait for... network to come up? DNS servers to be reachable?
|
||||
# Not certain, but Azure continually fails to achieve this pull so
|
||||
# far because it can't dial the DNS lookup properly.
|
||||
#
|
||||
# TODO: Debug.
|
||||
sleep 5
|
||||
done
|
||||
|
||||
# Wait for custom data to arrive
|
||||
while [ ! -f /var/lib/waagent/CustomData ]
|
||||
do
|
||||
sleep 5
|
||||
done
|
||||
|
||||
source /var/lib/waagent/CustomData
|
||||
|
||||
if [ "${ROLE}" == "MANAGER" ]
|
||||
then
|
||||
docker swarm init \
|
||||
--auto-accept manager \
|
||||
--auto-accept worker
|
||||
|
||||
# TODO: Make this cleaner.
|
||||
# User gets added by waagent.
|
||||
# Need to unlock it to login via SSH.
|
||||
passwd -u docker
|
||||
|
||||
checkpath --directory --mode 0700 /home/docker/.ssh
|
||||
|
||||
einfo "Pulling taco shell"
|
||||
|
||||
docker pull nathanleclaire/taco-shell >/dev/null
|
||||
|
||||
einfo "Running taco shell"
|
||||
|
||||
# Container for inbound shell access.
|
||||
#
|
||||
# TODO: Move this into another service?
|
||||
docker run -d \
|
||||
--name taco-shell \
|
||||
--net host \
|
||||
--restart always \
|
||||
-p 22:22 \
|
||||
-v /usr/bin/docker:/usr/docker/bin/docker:ro \
|
||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||
-v /home/docker/.ssh:/home/docker/.ssh:ro \
|
||||
-v /etc/passwd:/etc/passwd:ro \
|
||||
-v /etc/shadow:/etc/shadow:ro \
|
||||
-v /var/log:/var/log:ro \
|
||||
-v /etc/ssh/ssh_host_rsa_key:/etc/ssh/ssh_host_rsa_key:ro \
|
||||
-v /etc/ssh/ssh_host_rsa_key.pub:/etc/ssh/ssh_host_rsa_key.pub:ro \
|
||||
nathanleclaire/taco-shell
|
||||
else
|
||||
docker swarm join "${MANAGER_IP}:2377"
|
||||
fi
|
||||
|
||||
eend 0
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
[ "$(mobyplatform)" != "azure" ] && exit 0
|
||||
docker rm -f waagent || true
|
||||
docker rm -f taco-shell || true
|
||||
passwd -l docker
|
||||
}
|
||||
Reference in New Issue
Block a user