[lxc-devel] [PATCH] lxc-fedora template - systemd console gettys

Michael H. Warfield mhw at WittsEnd.com
Mon May 20 19:07:50 UTC 2013


On Mon, 2013-05-20 at 13:43 -0500, Serge Hallyn wrote:
> Quoting Michael H. Warfield (mhw at WittsEnd.com):
> > Hey all...
> > 
> > Patch to the lxc-fedora template to setup gettys on the ttys that are
> > enabled in the configuration.  The area of the code already had some
> > modifications to that service that didn't seem to do anything and would
> > get wiped out by an update.  I commented that out but subsumed the
> > change it was attempting into my command in case it does something on
> > another rev somewhere.
> > 
> > This is very similar to the logic in the OpenSuse template but doesn't
> > seem to appear in other templates, such as arch, which have to deal with
> > systemd.  This isn't unique to Fedora.  The templates for Fedora,
> > ArchLinux, and OpenSuse are the only three that seem to have any
> > reference to systemd at all.
> > 
> > Attached below the jump.
> > 
> > Regards,
> > Mike
> > -- 
> > Michael H. Warfield (AI4NB) | (770) 985-6132 |  mhw at WittsEnd.com
> >    /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
> >    NIC whois: MHW9          | An optimist believes we live in the best of all
> >  PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!
> > -- 
> > 
> > Signed-off-by: Michael H. Warfield <mhw at WittsEnd.com>

> Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

> > 
> > --- 
> > diff --git a/templates/lxc-fedora.in b/templates/lxc-fedora.in
> > index 710039c..481f718 100644
> > --- a/templates/lxc-fedora.in
> > +++ b/templates/lxc-fedora.in
> > @@ -143,7 +143,24 @@ configure_fedora_systemd()
> >      chroot ${rootfs_path} ln -s /dev/null //etc/systemd/system/udev.service
> >      chroot ${rootfs_path} ln -s /lib/systemd/system/multi-user.target /etc/systemd/system/default.target
> >      #dependency on a device unit fails it specially that we disabled udev
> > -    sed -i 's/After=dev-%i.device/After=/' ${rootfs_path}/lib/systemd/system/getty\@.service
> > +    # sed -i 's/After=dev-%i.device/After=/' ${rootfs_path}/lib/systemd/system/getty\@.service
> > +    #
> > +    # Actually, the After=dev-%i.device line does not appear in the
> > +    # Fedora 17 or Fedora 18 systemd getty\@.service file.  It may be left
> > +    # over from an earlier version and it's not doing any harm.  We do need
> > +    # to disable the "ConditionalPathExists=/dev/tty0" line or no gettys are
> > +    # started on the ttys in the container.  Lets do it in an override copy of
> > +    # the service so it can still pass rpm verifies and not be automatically

> Stupid systemd question - I assume based on this that the override copy
> is /etc/somepath and the original is /lib/somepath?

Yes, that appears to be correct.  If something already exists
under /etc/systemd/ then it is used and has priority.  If it doesn't,
then /lib/systemd/ is used.

I think the same sort of paradigm applies to udev rules and some other
OS internals we've "come to know and love" down through the years.  I
can't say I disagree with the methodology in that regards.  I gleaned
some of this from a URL about system "generators" that was posted in one
of the messages over on the -users list.

Adhering to this convention then also works (should work) with systemctl
where "enable" creates those links.  If someone creates additional ttys,
they can then call "systemctl enable getty at ttyN.service and it should
create the correct symbolic link to the /etc/system/system file rather
than the /lib/systemd/system fallback (except that it's not quite
working and I'm still figuring out the command syntax for that).
Conversely, "systemctl disable getty at ttyN.service" removes the link
(tested and it does) and "mask" creates a link to /dev/null to prevent
an accidental creation from some other source.

> > +    # updated by a new systemd version.  --  mhw  /\/\|=mhw=|\/\/
> > +
> > +    sed -e 's/^ConditionPathExists=/# ConditionPathExists=/' \
> > +        -e 's/After=dev-%i.device/After=/' \
> > +	< ${rootfs_path}/lib/systemd/system/getty\@.service \
> > +	> ${rootfs_path}/etc/systemd/system/getty\@.service
> > +    # Setup getty service on the 4 ttys we are going to allow in the
> > +    # default config.  Number should match lxc.tty
> > +    ( cd ${rootfs_path}/etc/systemd/system/getty.target.wants
> > +        for i in 1 2 3 4 ; do ln -sf ../getty\@.service getty at tty${i}.service; done )
> >  }
> >  
> >  download_fedora()

Regards,
Mike
-- 
Michael H. Warfield (AI4NB) | (770) 985-6132 |  mhw at WittsEnd.com
   /\/\|=mhw=|\/\/          | (678) 463-0932 |  http://www.wittsend.com/mhw/
   NIC whois: MHW9          | An optimist believes we live in the best of all
 PGP Key: 0x674627FF        | possible worlds.  A pessimist is sure of it!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 482 bytes
Desc: This is a digitally signed message part
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20130520/8a3be0a2/attachment.pgp>


More information about the lxc-devel mailing list