mirror of
https://github.com/linuxkit/linuxkit.git
synced 2025-12-09 02:34:51 +00:00
Split GCP startup script in two: + One started before Docker, to set the hostname + Another to run the startup script Signed-off-by: David Gageot <david@gageot.net>
35 lines
722 B
Plaintext
Executable File
35 lines
722 B
Plaintext
Executable File
#!/sbin/openrc-run
|
|
|
|
description="Set hostname on Docker GCP edition"
|
|
|
|
depend()
|
|
{
|
|
need net
|
|
before docker
|
|
}
|
|
|
|
metadata() {
|
|
curl -sH 'Metadata-Flavor: Google' http://metadata.google.internal/computeMetadata/v1/${1}
|
|
}
|
|
|
|
start()
|
|
{
|
|
[ "$(mobyplatform)" != "gcp" ] && exit 0
|
|
|
|
ebegin "Set hostname based on what GCP tells us it should be"
|
|
|
|
IP=$(metadata instance/network-interfaces/0/ip)
|
|
HOSTNAME=$(metadata instance/hostname)
|
|
echo "${IP} ${HOSTNAME} ${HOSTNAME%%.*} # Added by Google" >> /etc/hosts
|
|
echo "169.254.169.254 metadata.google.internal # Added by Google" >> /etc/hosts
|
|
echo ${HOSTNAME%%.*} >/etc/hostname
|
|
hostname -F /etc/hostname
|
|
|
|
eend 0
|
|
}
|
|
|
|
stop()
|
|
{
|
|
[ "$(mobyplatform)" != "gcp" ] && exit 0
|
|
}
|