Author Topic: [SOLVED] Where the Zentyal module configuration saved?  (Read 9668 times)

rockyzhangxq

  • Zen Apprentice
  • *
  • Posts: 22
  • Karma: +0/-0
    • View Profile
[SOLVED] Where the Zentyal module configuration saved?
« on: December 08, 2010, 07:27:19 pm »
Hi Guys,

I am new to Zentyal. I played with the box for a while, and would like to add my own configuration before the server initialize (e.g. add DHCP configuration there); I noticed that if I change something manually (e.g. edit /etc/dhcp3/dhcpd.conf), it will override after one login to the web UI. Is there anyway I can keep my customized configuration and show up when one log in the web UI?

I have no idea how perl script work in Zentyal; It use postgresql to save module configuration data? or some temporary directory?

Any hint/help will be appreciated.

Thanks,
Rocky
« Last Edit: December 16, 2010, 09:02:03 pm by rockyzhangxq »

Javier Amor Garcia

  • Zentyal Staff
  • Zen Hero
  • *****
  • Posts: 1225
  • Karma: +12/-0
    • View Profile
Re: Where the Zentyal module configuration saved?
« Reply #1 on: December 10, 2010, 03:00:01 pm »
Zentyal uses redis to save its configuration, when you save or restart any module, the stored configuration is used to regenerate the configuration files. This configuration files are written using templates, sio if you want to change the configuration files you must modify the tempkates.

Here you have more information:  http://trac.zentyal.org/wiki/Document/HowTo/ChangeEboxTemplates

rockyzhangxq

  • Zen Apprentice
  • *
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Where the Zentyal module configuration saved?
« Reply #2 on: December 10, 2010, 04:38:24 pm »
Thank you so much, Javier. You save me tons of hours. Will look into it right away.

rockyzhangxq

  • Zen Apprentice
  • *
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Where the Zentyal module configuration saved?
« Reply #3 on: December 10, 2010, 05:09:11 pm »
Hi Javier,

I understand Zentyal server use template to regenerate configuration every time. One thing strange to me, if in web UI i modify something the module (e.g. add a new dhcp range called "DHCP_Range" which start from 192.68.5.100 to 192.168.5.200) and save, applied, I could not see where such configuration is (e.g. string 'DHCP_Range" or "192.168.5.100"): It does not seem in the template (.mas) file. How the template know there is customized dhcp range there?

Thanks,
Rocky


Zentyal uses redis to save its configuration, when you save or restart any module, the stored configuration is used to regenerate the configuration files. This configuration files are written using templates, sio if you want to change the configuration files you must modify the tempkates.

Here you have more information:  http://trac.zentyal.org/wiki/Document/HowTo/ChangeEboxTemplates


rockyzhangxq

  • Zen Apprentice
  • *
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Where the Zentyal module configuration saved?
« Reply #4 on: December 10, 2010, 05:33:31 pm »
Just read some docs regrading redis - one in-memory database. I know that all the configuration data are stored there, and every time Zentyal module restart, it will read from redis database and write into the linux standard configuration. Modifying the redis database and entries is far more difficult.  It make sense to only modify the template files (.../stub/modulename/) to add our own configuration. Will test more.

rockyzhangxq

  • Zen Apprentice
  • *
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Where the Zentyal module configuration saved?
« Reply #5 on: December 10, 2010, 11:09:04 pm »
I just tested to modify /usr/share/ebox/stubs/dhcp/dhcpd.conf.mas to add more configuration, it works after I restarted DHCP service. But here i have another question, the DHCP configuration I added through editing dhcpd.conf.mas does not appear in WEB UI. I guess the reasons is that I only modify the generating configuration part, not the Redis database. Is there any way to show up the the web ui my customization? Does I have to understand the Redis db structure here and modify it directly?

Thanks,
Rocky

Josep

  • Zen Samurai
  • ****
  • Posts: 255
  • Karma: +6/-0
    • View Profile
Re: Where the Zentyal module configuration saved?
« Reply #6 on: December 11, 2010, 08:38:15 pm »
Web GUI templates are a different matter, and they are stored in /usr/share/ebox/templates/.
As for the REDIS DB, there is no structure to know about, it is a key-value storage.

rockyzhangxq

  • Zen Apprentice
  • *
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Where the Zentyal module configuration saved?
« Reply #7 on: December 13, 2010, 06:07:50 pm »
Josep, thanks for reply. I knew web template directory, but it is for general web interface, it will still need to read from Redis DB before showing it. Am i right?  E.g. a customer dhcp range will be stored in redis database instead of the web template.  I am looking into the redis db right now. I tried to use "redis-cli -n 15 dbsize" and got zero. Not sure where was wrong. And I am going to use some redis web admin (e.g. http://code.google.com/p/redis-admin/) to see if any luck.

Thanks,
Rocky



Web GUI templates are a different matter, and they are stored in /usr/share/ebox/templates/.
As for the REDIS DB, there is no structure to know about, it is a key-value storage.

rockyzhangxq

  • Zen Apprentice
  • *
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Where the Zentyal module configuration saved?
« Reply #8 on: December 14, 2010, 01:10:57 am »
I was able to access the redis DB by "telnet localhost 6380", and use the password in /var/lib/ebox/conf/redis.password. I just typed "keys *" to list all keys, most of the keys are not quite understandable (e.g. rules9120). I am wondering if that is an option that just copy the good/customized dump.rdb into /var/lib/ebox/dump.rdb so all my customization is there. Or any other good approach? BTW, anybody know good redis admin UI to work with Zentyal? I tried the google one i mentioned above, no luck (kind of stuck zentyal local redis need authentication, but I don't know how to pass to the web admin).

Josep

  • Zen Samurai
  • ****
  • Posts: 255
  • Karma: +6/-0
    • View Profile
Re: Where the Zentyal module configuration saved?
« Reply #9 on: December 14, 2010, 11:03:48 am »
I have been playing with redisdb myself. I haven't found a good GUI (not even one that doesn't need some hammering).
You could try replacing your dump.rdb file, but to what end?
Being able to hack a system is nice, but making that a regular behavior is pointless, after all, that's the reason why we are installing Zentyal in the first place.
As for DHCP, you have quite a number of templates:

/usr/share/ebox/stubs/dhcp/apparmor-dhcpd.profile.mas
/usr/share/ebox/stubs/dhcp/dhcpd.conf.mas
/usr/share/ebox/stubs/dhcp/includes.mas
/usr/share/ebox/stubs/dhcp/shared-network.mas
/usr/share/ebox/stubs/dhcp/staticRoutes.mas
/usr/share/ebox/stubs/dhcp/subnet.mas


And if that's not enough, you still have the Hooks system to manipulate any file in any way you want.
Anyway, good luck and let us know how the things progress.

J. A. Calvo

  • Zentyal Staff
  • Zen Hero
  • *****
  • Posts: 1986
  • Karma: +67/-3
    • View Profile
    • http://blogs.zentyal.org/jacalvo
Re: Where the Zentyal module configuration saved?
« Reply #10 on: December 14, 2010, 12:33:05 pm »
And if that's not enough, you still have the Hooks system to manipulate any file in any way you want.
Anyway, good luck and let us know how the things progress.

Thanks to a contribution from the community, the next version (going to be released this week) will allow easier modifications without hooks by copying the .mas files you want to modify to /etc/ebox/stubs.
Zentyal Server Lead Developer

rockyzhangxq

  • Zen Apprentice
  • *
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Where the Zentyal module configuration saved?
« Reply #11 on: December 14, 2010, 04:47:47 pm »
Thanks to Josep and J.A. Calvo.

To Josep,

I knew I was able to modify all the mas file for dhcp under "stubs" folder. Like I said before, this customization does not appear in we ui which might cause some issues (e.g. if end user add another similar dhcp range in web UI, it will conflict with my embedded one, and cause dhcp service stop.)  In fact i have several clients who have fixed samba shares and dhcp configuration; What I want to do is that adding some customization to Zentyal install CD so end user can just put the CD in and everything will be configured by default after bootup (I don't need to go to each server to login web UI and configure one by one).

To J. A. Calvo,

>> the next version (going to be released this week) will allow easier modifications without hooks by copying the .mas files you want to modify to /etc/ebox/stubs.

I am looking forward to this new version. Ideally should I develop some scripts (e.g. shell, PHP) the customization will be merged into Zentyal configuration.

Thanks,
Rocky

rockyzhangxq

  • Zen Apprentice
  • *
  • Posts: 22
  • Karma: +0/-0
    • View Profile
Re: Where the Zentyal module configuration saved?
« Reply #12 on: December 14, 2010, 10:03:40 pm »
I just tried refresh installed zentyal, then apply to dump.rdb. Not really work since some ldap configuration mess up although the DHCP range customization was there.  I guess copying the dump.rdb might be a good way to store current configuration, but not for refresh install and restore or as template to set up a new server. I think I'll wait for the new version released this week; Hope it will make me easy to use script to add my own customization.

Thanks,
Rocky

Josep

  • Zen Samurai
  • ****
  • Posts: 255
  • Karma: +6/-0
    • View Profile
Re: Where the Zentyal module configuration saved?
« Reply #13 on: December 15, 2010, 09:50:43 am »
...
Thanks to a contribution from the community, the next version (going to be released this week) will allow easier modifications without hooks by copying the .mas files you want to modify to /etc/ebox/stubs.

To J.A.Calvo, moving the stubs folder  from /usr/share/ebox to /etc/ebox seems a major change, and something that may break running systems. Wouldn't it be more appropriate to leave these kind of changes for new releases?
How does it replace the usage of hooks? They are still templates, right? Forgive my ignorance ...  :-\

J. A. Calvo

  • Zentyal Staff
  • Zen Hero
  • *****
  • Posts: 1986
  • Karma: +67/-3
    • View Profile
    • http://blogs.zentyal.org/jacalvo
Re: Where the Zentyal module configuration saved?
« Reply #14 on: December 15, 2010, 04:16:09 pm »
No, I think you misunderstood the new feature ;)

The "official" templates of course will still be at /usr/share/ebox/stubs. It's just that if you want to override one of them, you can copy it to /etc/ebox/stubs instead of having a hook to modify it. Moreover, if for example the customized template has a syntax error there will be a fallback to the default one and everything will keep working. All of this will be also logged in /var/log/ebox/ebox.log.

So don't worry, I can assure you this can't break anything at all :)

And of course you can keep using hooks without problem if you feel comfortable with them.
« Last Edit: December 15, 2010, 04:22:04 pm by J. A. Calvo »
Zentyal Server Lead Developer