Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

OS-3858 lx brand: 'hostname -i' returns 127.0.1.1

commit 19c576e12b547d5994b422499d9c450efc336f39 1 parent d73d040
Jerry Jelinek jjelinek authored
Showing with 26 additions and 1 deletion.
  1. +26 −1 overlay/generic/usr/lib/brand/lx/lx_install
27 overlay/generic/usr/lib/brand/lx/lx_install
View
@@ -11,7 +11,7 @@
#
#
-# Copyright (c) 2014 Joyent, Inc. All rights reserved.
+# Copyright 2015 Joyent, Inc.
#
# Does this brand support reprovisioning?
@@ -26,6 +26,31 @@ function jcommon_attach_hook
{
# lx-brand specific stuff is done here as final step of install
+ #
+ # Make sure the localhost has a hostname alias in the zone's
+ # /etc/hosts file
+ #
+ zroot=$ZONEPATH/root
+ hname=$ZONENAME
+ hostnamef=$zroot/etc/hostname
+ if [[ ! -h $hostnamef ]]; then
+ echo $hname >$hostnamef
+ fi
+
+ hostfile=$zroot/etc/hosts
+ if [[ -f $hostfile && ! -h $hostfile ]]; then
+ # use awk to search and append to loopback in one command
+ awk -v hname="$hname" '{
+ if ($1 ~ /^127\./ && index($0, hname) == 0) {
+ printf("%s %s\n", $0, hname);
+ } else {
+ print $0
+ }
+ }' $hostfile >/tmp/tmp_${ZONENAME}_$$
+ mv /tmp/tmp_${ZONENAME}_$$ $hostfile
+ chmod 644 $hostfile
+ fi
+
rm -rf $ZONEPATH/cores
CORE_QUOTA=102400
zfs create -o quota=${CORE_QUOTA}m \
Please sign in to comment.
Something went wrong with that request. Please try again.