mirror of
https://github.com/linuxkit/linuxkit.git
synced 2026-01-15 19:46:13 +00:00
103 lines
2.1 KiB
Plaintext
Executable File
103 lines
2.1 KiB
Plaintext
Executable File
#!/sbin/openrc-run
|
|
|
|
description="Bootstrap procedure if running on Docker Azure edition"
|
|
|
|
depend()
|
|
{
|
|
need docker
|
|
need net
|
|
}
|
|
|
|
start()
|
|
{
|
|
[ "$(mobyplatform)" != "azure" ] && exit 0
|
|
ebegin "Running Azure-specific initialization"
|
|
|
|
for i in $(seq 1 20)
|
|
do
|
|
einfo "Pulling Windows Azure Linux Agent container"
|
|
|
|
docker pull docker4x/agent-azure >/dev/null
|
|
|
|
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
|
|
|
|
einfo "Running Windows Azure Linux Agent container"
|
|
|
|
export DOCKER_FOR_IAAS_VERSION="azure-v1.13.0-rc2-beta12"
|
|
|
|
docker run -d \
|
|
--privileged \
|
|
--name agent \
|
|
--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 \
|
|
"docker4x/agent-azure:$DOCKER_FOR_IAAS_VERSION"
|
|
|
|
# Wait for docker user to be added by agent.
|
|
while [ ! -d /home/docker ]
|
|
do
|
|
sleep 5
|
|
done
|
|
|
|
# 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
|
|
|
|
# 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
|
|
|
|
cat <<EOF >/etc/docker/daemon.json
|
|
{
|
|
"log-driver": "syslog",
|
|
"log-opts": {
|
|
"syslog-address": "udp://localhost:514",
|
|
"tag": "{{.Name}}/{{.ID}}"
|
|
}
|
|
}
|
|
EOF
|
|
|
|
# Ensure correct hostname according to Azure and reload daemon config
|
|
service docker restart
|
|
|
|
. /var/lib/waagent/CustomData
|
|
|
|
eend 0
|
|
}
|
|
|
|
stop()
|
|
{
|
|
[ "$(mobyplatform)" != "azure" ] && exit 0
|
|
docker rm -f agent || true
|
|
passwd -l docker
|
|
}
|