Skip to content

Commit

Permalink
v0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandGouny committed Oct 31, 2015
1 parent 33e18b4 commit 0ddeae9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions image/tool/my_init
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,16 @@ def xstr(s):
return str(s)

def set_env_hostname_to_etc_hosts():
if "HOSTNAME" in os.environ and socket.gethostname() and os.environ["HOSTNAME"] != socket.gethostname():
with open("/etc/hosts", "a") as myfile:
myfile.write("127.0.0.1 "+os.environ["HOSTNAME"]+"\n")

if "HOSTNAME" in os.environ:
with open('/etc/hostname', 'r') as f:
etc_hostname = f.readline().rstrip()

ip_address = socket.gethostbyname(etc_hostname)

if os.environ["HOSTNAME"] != etc_hostname:
with open("/etc/hosts", "a") as myfile:
myfile.write(ip_address+" "+os.environ["HOSTNAME"]+"\n")

def python_dict_to_bash_envvar(name, python_dict):

Expand Down

0 comments on commit 0ddeae9

Please sign in to comment.