Skip to content

Commit

Permalink
Merge branch 'hotfix-0.1.3' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandGouny committed Nov 6, 2015
2 parents bedb142 + 0ddeae9 commit 858463c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.1.3
- add hostname env variable to /etc/hosts
to make the image more friendly with kubernetes again :)

## 0.1.2
- Load env.yaml file from /container/environment directory
to make the image more friendly with kubernetes secrets :)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME = osixia/light-baseimage
VERSION = 0.1.2
VERSION = 0.1.3

.PHONY: all build test tag_latest release build-tool

Expand Down
15 changes: 14 additions & 1 deletion image/tool/my_init
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/python -u
import os, os.path, sys, stat, signal, errno, argparse, time, re, yaml, ast
import os, os.path, sys, stat, signal, errno, argparse, time, re, yaml, ast, socket

KILL_PROCESS_TIMEOUT = 5
KILL_ALL_PROCESSES_TIMEOUT = 5
Expand Down Expand Up @@ -63,6 +63,18 @@ def xstr(s):
return ''
return str(s)

def set_env_hostname_to_etc_hosts():

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):

for value in python_dict:
Expand Down Expand Up @@ -318,6 +330,7 @@ def wait_for_runit_services():
def main(args):
import_envvars(False, False)
export_envvars()
set_env_hostname_to_etc_hosts()

if not args.skip_startup_files:
run_startup_files()
Expand Down

0 comments on commit 858463c

Please sign in to comment.