[lxc-devel] [PATCH 3/3] Code cleanups

Stéphane Graber stgraber at ubuntu.com
Fri Apr 4 23:22:21 UTC 2014


On Fri, Apr 04, 2014 at 07:16:25PM -0400, Leonid Isaev wrote:
> On Fri, 4 Apr 2014 19:02:34 -0400
> Stéphane Graber <stgraber at ubuntu.com> wrote:
> 
> > On Mon, Mar 31, 2014 at 05:14:34PM -0400, Leonid Isaev wrote:
> > > Cleanups:
> > > 1. Do not modify container's /etc/hosts (archlinux uses /etc/nsswitch.conf)
> > > 2. Remove duplicate lines from config
> > > 3. Print a nicer final message
> > > 4. Get rid of some grep's in favor of bash regex
> > > 
> > > Signed-off-by: Leonid Isaev <lisaev at umail.iu.edu>
> > 
> > Acked-by: Stéphane Graber <stgraber at ubuntu.com>
> 
> I think this is a wrong patch. As you said, I re-sent the 1st and 3rd parts
> which contained bash-specific expressions. So the correct 3/3 part is here
> https://lists.linuxcontainers.org/pipermail/lxc-devel/2014-April/008667.html ,
> and it is not an April fools joke :)
> 
> Thanks,
> L.

Yeah, you're right... I had lost your patches and pulled them from
mailman's .mbox, though apparently I didn't pick the right one...

I'll push an update.

> 
> > 
> > > ---
> > >  templates/lxc-archlinux.in | 33 ++++++++++++++++++++-------------
> > >  1 file changed, 20 insertions(+), 13 deletions(-)
> > > 
> > > diff --git a/templates/lxc-archlinux.in b/templates/lxc-archlinux.in
> > > index 6046c94..79d89b8 100644
> > > --- a/templates/lxc-archlinux.in
> > > +++ b/templates/lxc-archlinux.in
> > > @@ -71,9 +71,10 @@ split_string() {
> > >  
> > >  # Arch-specific preconfiguration for container
> > >  configure_arch() {
> > > -    # read locale and timezone defaults from system rc.conf if running on
> > > Arch
> > > +    # on ArchLinux, read defaults from host systemd configuration
> > >      if [ "${is_arch}" ]; then
> > > -        cp -p /etc/vconsole.conf /etc/locale.conf /etc/locale.gen
> > > "${rootfs_path}/etc/"
> > > +        cp -p /etc/vconsole.conf /etc/locale.conf /etc/locale.gen \
> > > +		"${rootfs_path}/etc/"
> > >      else
> > >          echo "LANG=${default_lang}" > "${rootfs_path}/etc/locale.conf"
> > >          echo "KEYMAP=us" > "${rootfs_path}/etc/vconsole.conf"
> > > @@ -89,22 +90,25 @@ EOF
> > >              fi
> > >          fi
> > >      fi
> > > +
> > > +    # hostname and nameservers
> > >      echo "${name}" > "${rootfs_path}/etc/hostname"
> > > -    cat > "${rootfs_path}/etc/hosts" << EOF
> > > -127.0.0.1   localhost.localdomain   localhost ${name}
> > > -::1     localhost.localdomain   localhost
> > > -EOF
> > > -    grep nameserver /etc/resolv.conf > "${rootfs_path}/etc/resolv.conf"
> > > +    while read r; do
> > > +       [[ $r =~ ^nameserver ]] && echo "$r"
> > > +    done < /etc/resolv.conf > "${rootfs_path}/etc/resolv.conf"
> > >  
> > > +    # chroot and configure system
> > >      arch-chroot "${rootfs_path}" /bin/bash -s << EOF
> > >  mkdir /run/lock
> > >  locale-gen
> > >  ln -s /usr/share/zoneinfo/${default_timezone} /etc/localtime
> > >  # disable services unavailable for container
> > > -ln -s /dev/null /etc/systemd/system/systemd-udevd.service
> > > -ln -s /dev/null /etc/systemd/system/systemd-udevd-control.socket
> > > -ln -s /dev/null /etc/systemd/system/systemd-udevd-kernel.socket
> > > -ln -s /dev/null /etc/systemd/system/proc-sys-fs-binfmt_misc.automount
> > > +for i in systemd-udevd.service \
> > > +	systemd-udevd-control.socket \
> > > +	systemd-udevd-kernel.socket \
> > > +	proc-sys-fs-binfmt_misc.automount; do
> > > +   ln -s /dev/null /etc/systemd/system/\$i
> > > +done
> > >  # set default systemd target
> > >  ln
> > > -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
> > > # initialize pacman keyring @@ -141,7 +145,6 @@ lxc.cgroup.devices.allow =
> > > c 1:5 rwm lxc.cgroup.devices.allow = c 1:7 rwm
> > >  lxc.cgroup.devices.allow = c 1:8 rwm
> > >  lxc.cgroup.devices.allow = c 1:9 rwm
> > > -lxc.cgroup.devices.allow = c 1:9 rwm
> > >  lxc.cgroup.devices.allow = c 4:1 rwm
> > >  lxc.cgroup.devices.allow = c 5:0 rwm
> > >  lxc.cgroup.devices.allow = c 5:1 rwm
> > > @@ -319,4 +322,8 @@ if [ -n "${root_passwd}" ]; then
> > >      echo "root:${root_passwd}" | chroot "${rootfs_path}" chpasswd
> > >  fi
> > >  
> > > -echo "container config is ${config_path}/config"
> > > +cat << EOF
> > > +ArchLinux container ${name} is successfully created! The configuration is
> > > +stored in ${config_path}/config. Please refer to
> > > https://wiki.archlinux.org for +information about configuring ArchLinux.
> > > +EOF
> > > -- 
> > > 1.8.5.3
> > > 
> > > -- 
> > > Leonid Isaev
> > > GnuPG key fingerprint: C0DF 20D0 C075 C3F1 E1BE  775A A7AE F6CB 164B 5A6D
> > 
> > 
> > 
> 
> 
> 
> -- 
> Leonid Isaev
> GnuPG key fingerprint: C0DF 20D0 C075 C3F1 E1BE  775A A7AE F6CB 164B 5A6D



> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20140404/287c1e9b/attachment.pgp>


More information about the lxc-devel mailing list