scaleway-image-archlinux/patches/usr/lib/dhcpcd/dhcpcd-hooks/29-ocs-metadata

19 lines
603 B
Plaintext
Raw Normal View History

2015-04-07 10:17:01 +02:00
# Fetch Scaleway metadata
2014-12-29 19:38:47 +01:00
2015-04-07 10:17:01 +02:00
fetch_scw_metadata()
2014-12-29 19:38:47 +01:00
{
metadata_host_name=$(/usr/local/bin/oc-metadata --cached HOSTNAME)
if [ "x$metadata_host_name" != "x" ]; then
echo $metadata_host_name > /etc/hostname
sed "/^127.0.1.1[ \t].*$/ s/.*$/127.0.1.1\t$metadata_host_name/" -i /etc/hosts
sed "/^127.0.0.1[ \t]localhost/ s/localhost.*$/localhost $metadata_host_name/" -i /etc/hosts
export new_host_name="${metadata_host_name}"
hostname $metadata_host_name
echo dhclient-exit-hooks.d/hostname: Dynamic Hostname = ${metadata_host_name}
fi
}
if $if_up; then
2015-04-07 10:17:01 +02:00
fetch_scw_metadata
2014-12-29 19:38:47 +01:00
fi