Koozali.org: home of the SME Server

Contribs.org Forums => General Discussion => Topic started by: mansonthomas on December 31, 2007, 12:16:14 AM

Title: A question about template system
Post by: mansonthomas on December 31, 2007, 12:16:14 AM
Hi,

I'm trying to modifying the /etc/modprobe.conf file using the template system.
I'm activating ipv6 on my server.

So here is what i did :


Code: [Select]
mkdir -p /etc/e-smith/templates-custometc/modprobe.conf
cp  /etc/e-smith/templates/etc/modprobe.conf/10net-fp-aliases /etc/e-smith/templates-custom/etc/modprobe.conf/
vi /etc/e-smith/templates-custom/etc/modprobe.conf/10net-fp-aliases


And then I remplace

Code: [Select]
            # alias IPV6 off
            "alias net-pf-10 off",

By
Code: [Select]
            # alias IPV6 ON
            "alias net-pf-10 ipv6",


finally I run the command : expand-template /etc/modprobe.conf


But when I look to the /etc/modprobe.conf
I can see that the 10net-fp-aliases file is executed 2 times...

whereas, according to what I see before, the templates-custom version should have replaced the templates version
and so only one of the two file is executed...

And it seems that for this file, the file itself is the data source... so each time I add a line, it stacks...

So what is the proper way to modify this file ?
I want to put ipv6, but the template system forces it off...
(ie if I remplace off by ipv6, the template system will add a line alias net-pf-10 off at the end of the file)

All i can see is to modify /etc/e-smith/templates/etc/modprobe.conf which sounds dirty to me...


Regards,
Thomas.
here is the resulting file :

[root@home templates-custom]# cat           /etc/modprobe.conf
#------------------------------------------------------------
# BE CAREFUL WHEN MODIFYING THIS FILE! It is updated automatically
# by the SME server software. Various aliases are added and/or
# deleted by the template processing of the file and white space
# is removed, but otherwise changes to the file are preserved.
# For more information, see http://www.e-smith.org/custom/ and
# the template fragments in /etc/e-smith/templates/etc/modprobe.conf/.
#
# copyright (C) 2002-2005 Mitel Networks Corporation
#------------------------------------------------------------
alias scsi_hostadapter ata_piix
alias snd-card-0 snd-intel8x0
options snd-card-0 index=0
install snd-intel8x0 /sbin/modprobe --ignore-install snd-intel8x0 && /usr/sbin/alsactl restore >/dev/null 2>&1 || :
remove snd-intel8x0 { /usr/sbin/alsactl store >/dev/null 2>&1 || : ; }; /sbin/modprobe -r --ignore-remove snd-intel8x0
alias usb-controller ehci-hcd
alias usb-controller1 uhci-hcd
alias block-major-3 off
alias bond0 bonding
alias char-major-43 hisax
alias net-pf-4 off
alias net-pf-47 ip_gre
alias net-pf-24 pppoe
alias parport_lowlevel parport_pc
alias ppp ppp_generic
alias char-major-108 ppp
alias /dev/ppp ppp
alias tty-ldisc-3 ppp_async
alias tty-ldisc-14 ppp_synctty
alias ppp-compress-18 ppp_mppe
alias ppp-compress-21 bsd_comp
alias ppp-compress-24 ppp_deflate
alias ppp-compress-26 ppp_deflate
alias tap0 off
alias tap1 off
alias tap2 off
alias tap3 off
alias tap4 off
alias tap5 off
alias tap6 off
alias tap7 off
alias tap8 off
alias tap9 off
alias tap10 off
alias tap11 off
alias tap12 off
alias tap13 off
alias tap14 off
alias tap15 off
alias char-major-180 usbcore
alias net-pf-10 ipv6
alias net-pf-10 ipv6#test
alias eth0 e1000
alias eth1 8139too
options bond0 miimon=200 mode=active-backup
options hisax  protocol=2
alias net-pf-10 off
Title: Re: A question about template system
Post by: guest22 on December 31, 2007, 12:23:44 AM
http://forums.contribs.org/index.php?topic=36709.0
Title: Re: A question about template system
Post by: mansonthomas on December 31, 2007, 12:46:29 AM
It doesn't answer the question...

In the case of the topic, it's not a module that is forbidden by the template system


Code: [Select]
{
    foreach my $line
        (
            # alias IPX off
            "alias net-pf-4 off",
            # alias IPV6 off
            "alias net-pf-10 off",
            "alias net-pf-47 ip_gre",
        )
    {
        unless (exists $lines{$line})
        {
            push @lines, $line;
        }
    }
    foreach my $line
        (
            "alias net-pf-15 ipsec",
            "alias net-pf-50 ipsec",
        )
    {
        @lines = grep { !/^$line$/ } @lines;
    }

    "";
}
Title: Re: A question about template system
Post by: mansonthomas on December 31, 2007, 12:59:35 AM
moreover it has absolutely nothing to do with the locals, I don't understand why we're told to go towards this direction...

and also it's written in the dev docs around page 28:

Quote
If a fragment of the same name exists in both templates and templates-custom, the one from
templates-custom is used, and the one from the standard templates tree is ignored.

and here :


Quote
In rare cases the standard template specifies a behaviour which conflicts with your application. In these
cases, you should do all of the following:

* Create a templates-custom directory to match the existing one in the templates hierachy.


* Copy the conflicting fragment, and only that fragment, to the templates-custom directory. The
fragment should have the same name in both directories. At this point you have not changed the
behaviour of the system as the templates-custom entry will be preferred, but will behave identically.
* Modify the copy in templates-custom to suit your required behaviour.
Title: Re: A question about template system
Post by: mansonthomas on December 31, 2007, 01:00:17 AM
I give a try to locale subtree without success...
Title: Re: A question about template system
Post by: mansonthomas on December 31, 2007, 01:05:19 AM
It sounds just like a bug to me...

the templates-custom files should have replaced the templates files, as written in the documentation...

If i'm wrong, please post something more than an url...

Regards,
Thomas
Title: Re: A question about template system
Post by: raem on December 31, 2007, 02:30:51 AM
mansonthomas

Your custom template changes are adding to the existing entries in /etc/modeprobe.conf

The link referred to
http://forums.contribs.org/index.php?topic=36709.0
says:
Quote
I have read editing modprobe.conf is not the right way as I will loose my setting on the next template refresh

To which Charlie answered:

Quote
No, you won't. modprobe.conf is a special template which just modifies the existing file, not recreates it totally from the templates

So do not use it in the normal way that templates and custom templates are used or referred to in the dev guide.

As I'm understanding it, just add a new entry or amend an existing entry directly in
/etc/modprobe.conf
and restart your server.

Of course you should revert your machine back to "how it was" by removing any custom template changes you have made and re-expanding the template.

Note that it says in /etc/modprobe.conf

"Various aliases are added and/or
deleted by the template processing of the file and white space
is removed, but otherwise changes to the file are preserved."

The pertinent words being
"but otherwise changes to the file are preserved"


Charlie also replied:
Quote
But if you prefer, you can create a script in the 'local' event which loads the module you want. See the developers guide for details on actions and events.

I'm not absolutely sure, but I believe Charlie is referring to
/etc/e-smith/events/local
perhaps similar to how it is done with
/etc/e-smith/events/local/templates2expand/boot/grub/grub.conf

As advised read more in the dev guide.


Although this is not the tidiest sme approach, I think you can also add a modprobe statement at start up, which effectively does the same thing as issuing the command at the command prompt, by adding the appropriate command to
/etc/rc.d/rc.local

There's an example of this here
http://wiki.contribs.org/Wondershaper

and you can search the forums on modprobe for other examples


Title: Re: A question about template system
Post by: mansonthomas on December 31, 2007, 11:59:52 AM
Quote
As I'm understanding it, just add a new entry or amend an existing entry directly in
/etc/modprobe.conf
and restart your server.

I did understand that, but the point is :

* If I delete my template-custum part
* add my entry in modprobe.conf: alias net-pf-10 ipv6
* expand-template

The result is :

 * i have my line :
Code: [Select]
    alias net-pf-10 ipv6  * but, the template system add the line
Code: [Select]
    alias net-pf-10 off
as it's not already in the modprobe.conf file, see the script below :



foreach my $line
        (
            # alias IPX off
            "alias net-pf-4 off",
            # alias IPV6 off
            "alias net-pf-10 off",
            "alias net-pf-47 ip_gre",
        )
    {
        unless (exists $lines{$line})
        {
            push @lines, $line;
        }
    }

That's why i did try to override the standart templates...
Title: Re: A question about template system
Post by: mansonthomas on December 31, 2007, 12:01:51 PM
About "local" I was digging in /etc/e-smith/locale
Title: Re: A question about template system
Post by: raem on December 31, 2007, 01:13:21 PM
mansonthomas

Just edit the main template file (code). Do not create any custom template
Title: Re: A question about template system
Post by: mansonthomas on December 31, 2007, 01:14:34 PM
Ok, so there no proper way to do this.

Thanks for your help,
Thomas.
Title: Re: A question about template system
Post by: raem on December 31, 2007, 01:40:03 PM
mansonthomas

In this particular case it appears to be the correct way to do it.
Title: Re: A question about template system
Post by: CharlieBrady on December 31, 2007, 08:17:38 PM
mansonthomas

Just edit the main template file (code). Do not create any custom template


No Ray. The custom template is required so that "alias net-pf-10 off" is *not* added to modprobe.conf.

Quote
But when I look to the /etc/modprobe.conf
I can see that the 10net-fp-aliases file is executed 2 times...

No, that was an incorrect conclusion. It was executed just once to add "alias net-pf-10 ipv6", but the exising "alias net-pf-10 off" was left untouched. You will need to either delete that in your custom template, or (easier) just delete it by editing the file.
Title: Re: A question about template system
Post by: raem on January 01, 2008, 02:23:08 AM
Charlie

Thanks for the correction/clarification.
Title: Re: A question about template system
Post by: mansonthomas on January 01, 2008, 05:37:50 AM
Charlie, indeed you're right

alias net-pf-10 off
was left in the file before I expand with custom template so it stay in the file.

This fool me...

Now it's working with a template custom ;)

Thanks.
Thomas
Title: Re: A question about template system
Post by: guest22 on January 01, 2008, 10:35:20 PM
Thomas,

any chance you can create a wiki page about how to 'handle' a custom modprobe.conf (to template or not to template etc). It would sure help others and you're the 'experienced' one now ;-)

TIA,
guest
Title: Re: A question about template system
Post by: mansonthomas on January 03, 2008, 12:24:10 AM
I'll try to do that soon ;)

Thomas