Explaining e-smith layer - learning by doing

I would try to explain e-smith layer by my favourite way : learning by doing

Integrate a rpm of wordpress from epel https://github.com/stephdl/nethserver-wordpress/tree/ns6

this example is quite easy, the epel maintainers write a /etc/wordpress/wp-config.php but we need to modify it.

-we could play with grep and sed for modifying variables, but it is not easy since the first change will break the regex
-we could use a template…this is what i did https://github.com/stephdl/nethserver-wordpress/tree/ns6/root/etc/e-smith/templates/etc/wordpress/wp-config.php
The database is just here to record variables like db password, db user…

in a nutshell

The template /etc/e-smith/templates/etc/wordpress/wp-config.php will overwrite /etc/wordpress/wp-config.php
the template /etc/e-smith/templates.metadata/etc/wordpress/wp-config.php will give the good owner rights on /etc/wordpress/wp-config.php because you may want that this file is used by apache for example (default is root)
Templates are tied to an event (nethserver-wordpress-update here) at the createlink level https://github.com/stephdl/nethserver-wordpress/blob/ns6/createlinks

templates2events("/etc/httpd/conf.d/wordpress.conf",  nethserver-wordpress-update);
templates2events("/etc/wordpress/wp-config.php",  nethserver-wordpress-update);

the database wordpress will record all variables that we need to use in our templates
see https://github.com/stephdl/nethserver-wordpress/tree/ns6/root/etc/e-smith/db/configuration/defaults/wordpress
you can see the db values in a terminal by :

config show wordpress

Actions are specifics you can use it for many things…it is like a script https://github.com/stephdl/nethserver-wordpress/tree/ns6/root/etc/e-smith/events/actions, they are tied to an event (nethserver-wordpress-update for example) and they are launched when you want, depending the number they get in the createlink https://github.com/stephdl/nethserver-wordpress/blob/ns6/createlinks

event_actions(nethserver-wordpress-update, 
             'initialize-default-databases' => '00',
             'nethserver-wordpress-conf' => '20',
             'nethserver-wordpress_permissions-conf' => '30'

X<10 before the template expand
10<X<90 after the template expand
X>90 after the adjust service (service trigger)

when you do a contrib, services need to be restarted or reloaded and it is done at the createlink level and also tied to an event https://github.com/stephdl/nethserver-wordpress/blob/ns6/createlinks

event_services(nethserver-wordpress-update, 'httpd' => 'reload');

at the end you can find all templates, actions, services of your event if you do

ll -R /etc/e-smith/events/nethserver-wordpress-update

The Event is the action that you call either at the end of your rpm installation (nethserver-…-update), or when you press save in nethgui, it will overwrite templates, launch actions, and restart services. you can call manually it by
’signal-event nethserver-wordpress-update’

If you want to modify a value like maybe the name of the folder after the url (https://yourIP/wordpress)
you will do

config setprop wordpress URL foldername
signal-event nethserver-wordpress-update

you don’t need to edit a .conf file, it is automatic, you have altered the database and simply launched the event which will overwrite files with correct values, launch actions and restart services

The nethgui is just an ‘api’ which writes variables in the database and launch the event at the end…no more…Of course the UI is the most difficult part for me, even if nethgui is able to give things easier than with formagick for the SME Server panel.

I do believe that zentyal uses a similar approach, for clearos I don’t know. It is something logical, that it can probably be enhanced but it is easy to take in hand.

12 Likes

That’s a great piece of docs with “blood and tears” :smile: and deserves a new topic, I’m sure that people like @dz00te @giacomo, @davidep, @filippo_carletti, @alep, @Stll0 @jim @fasttech @ctek @islipfd19 @adam might appreciate it.

Thank you very much @stephdl! This is a great gift for us!

I think “learning by doing” is the best way to approach a new matter, and discover gradually its complexity and dark points.

I think also administering a server is not trivial and requires knowledge. Building a system that wants to simplify the administration of a server requires more knowledges, thus more time to learn.

2 Likes

I do!

I do too.
But how to say …It’s still hash.
Perhaps @filippo_carletti already said elegantly:

Edit: Initialy I wanted to write harsh… :ghost:

1 Like

Mode troll on, I’m not a bad guy :smile:

Developers have a curious way to apprehend life, all is algorithms. What is incomprehensible for you, is clear for them. They do love to write their code, the most unreadable for you, just to demonstrate their level, and of course with less comments as possible because they are really lazy people.

mode troll off.

I have just one advice for you Jim and for all people who want to play with neth code, firstable try to read code of some modules, forget for now the documentation that you found obscure …Once you will have some examples in mind you will understand better what the documentation is talking.

The documentation should, could, must be enhanced, but if you have not the point of view of a developer, it is useless.

6 Likes

You are my hero! :rocket:

1 Like

I’m not a developer but posts like this inspires me! Amazing insights, really! Thanks Steph

You MUST be our dev_team coordinator! You could be a good mentor for anyone else.
What do think guys? @giacomo, @davidep, @filippo_carletti, @alep, @Stll0, @vcc, @mabeleira, @medworthy, @dz00te, @fasttech, @GG_jr, @Adam @jim @Ctek

5 Likes

If I’m well understand, you are fully qualified to rewrite this stuff to make it more afordable :wink:

What do you thing about doing tutorials, writing but until video tutorials too, how to install the Nethserver developer environment?
Making tutorial about the basics about the db manipulation?

jim… re-read carefully (and at least twice) the link I posted twice in the other topic… all you need is here and in NS documentation… moreover, follow stephdl advice, get the developer poit of view, be curious.

I’d read the link…SME Server:Documentation:Developers Manual - SME Server

This one where we can see:

Note:
Copyright © 2002-2006 Mitel Corporation
Last updated: $Date: 2006/05/29 09:02:22 $

and

The section describes the general structure of the configuration
database. The actual entries and properties are subject to change
between releases.

I already see in this forum video tutorial about the Nethserver installation…

But sorry… Sorry to try to shake this forum with ideas, with suggestions, with interogations, with debates.

well… a 10 years old math book is still good… start reading it… you’ll learn a lot… when you’ll have some questions, here we are…

but atm it seems that you want someone else do something to make you learn :slight_smile:
just read… be curious

(I read it in 2 days, printed on paper…)

I appreciate what you’re doing, I read your posts carefully and always try to give you my best answers.

1 Like

me too, of course

but every change request, to improve something, must come from some knowledge… I mean… if I don’t know how things work, I just can guess and propose… If I know the internals, I can also judge and understand, and propose improvements…

Keep in mind that english is not my mother tong.

@filippo_carletti
You alway reply with courtesy and pertinence

@zamboni
you seem more resistent at change proposal. :wink:
I’m curious… But I have difficulties with this e-smith layer. Am I the only one?

And one more time I don’t 100% agree :grin:
A change can be done with a new or fresh point of view or another perspective.

yes… but you can’t propose to change a mechanical part in an engine without knowing how the engine works and/or how that part is supposed to work
you can obvioously propose to change the whole engine, but before doing so, you must know everything about the engine, cause tomorrow you can’t say “ops, I miss a feature I had and I need”
and, more, re-engieeering something means bugs, many bugs, and then debug, tests, problems…

and this (the fact thar requests for changes come without knowing how things work) is demonstrated by all the requests to use a different framework to redesign the web ui, without knowing that the web part is only a plus… it shows (get) and save (post) datas… al the logic is elsewhere…

about this: here, we are talking about an enterprise grade linux distribution, i.e. something where people invest work, money, and where “my” customers put their data…
in this perspective, I don’t need a fancy UI, I need a rock solid product, that simply works in reliable, predictive and vervbose mode.
you (generally speaking) see only a new distro with a good UI, to be compared (but just by the aestethic side) to zentyal or other… in other words, you (generally speakin) are attracted more from how it appears than how it works.
you (generally speaking) can afford a distro change in your home server twice, 3 times an year…

me, as sysadm, must think about “my” data from now to 3/4 years ahead… and my customers can’t afford a flaky server.

4 Likes

I teach my work mates to use the db commands and to explain the e-smith layer concepts… they understand the thing in a quite small time…
I don’t know you, don’t know how do you approach to new things…
thne only suggestion I can give to you is:
install a VM adn destroy it, try everything, see the effects of your input… all forgettig, in the first instance, the UI…
if you don’t jump into, you never understand, even with video 3d tutorial with 7.1 surround audio

No you’re not! :smile:
I remember I had some troubles at the beginning, still I have problems when events have cross-dependencies and I have to write some difficult script for the db migration!

So, I surely understand your point, and I’d also like to use some of the new tools. I looked into some configuration management projects such as Puppet, Salt and Ansible (the one I like most), but all tools have a steep learning curve.
There is no easy way to replace the current e-smith layer, but probably it’s time to integrate some new tool!

4 Likes

No, you’re not. I had the same problem, but … I have the same problem every time I face a new big tool.
But there’s a great thing about e-smith system: you don’t have binary blobs, just easy readable scripts! And you can always “follow the path” without the needs of boring developer documentation.

3 Likes