Added post init script for dhclient. #1

This commit is contained in:
Sebastien Rannou 2014-12-18 19:19:08 +01:00
parent 6a04a73c4f
commit 3f7eef085d
1 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
interface=$1
action=$2
if [ "$interface" = "eth0" -a "$action" = "up" ]
then
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
hostnamectl set-hostname $metadata_host_name
fi
fi