comparison docker/base/scripts/add_host @ 118:12cb931dbea0

docker (base): fixed bad escaping in add_host script, resulting in domain not put in /etc/hosts
author Goffi <goffi@goffi.org>
date Tue, 08 Mar 2016 17:54:11 +0100
parents b69056368901
children
comparison
equal deleted inserted replaced
117:834bedf42332 118:12cb931dbea0
11 if host == "localhost" or host == alias: 11 if host == "localhost" or host == alias:
12 sys.exit(0) 12 sys.exit(0)
13 13
14 print "Adding host {} as an alias of {}".format(host, alias) 14 print "Adding host {} as an alias of {}".format(host, alias)
15 with open("/etc/hosts", "r+") as f: 15 with open("/etc/hosts", "r+") as f:
16 buf = re.sub(r"\\b{}\\b".format(alias), "{}\\t{}".format(alias, host), f.read(), 1) 16 buf = re.sub(r"\b{}\b".format(alias), "{}\t{}".format(alias, host), f.read(), 1)
17 f.seek(0) 17 f.seek(0)
18 f.write(buf) 18 f.write(buf)