Koozali.org: home of the SME Server
Contribs.org Forums => General Discussion => Topic started by: mdrone on August 14, 2024, 04:57:06 PM
-
Here's the scenario . . .
I recently installed Mailarchiva on an SME Server 10.1 machine.
It was installed per the Step 2 instructions at:
https://help.mailarchiva.com/enterprise-linux-install
The Mailarchiva installation process copies its mailarchiva.service file to /etc/systemd/system/ and then issues the following commands:
chmod u+x /etc/systemd/system/mailarchiva.service
systemctl daemon-reload
systemctl enable mailarchiva
It then instructs the user . . .
to start service, type sudo systemctl start mailarchiva
to stop service, type sudo systemctl stop mailarchiva
Following the advice provided at:
https://wiki.koozali.org/MailArchiva
https://forums.koozali.org/index.php?topic=46754.0
I issued the following commands . . .
config set mailarchiva service TCPPort 8090 access public status enabled
ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S99mailarchiva
signal-event remoteaccess-update
(I elected to make my Mailarchiva implementation public rather than private)
Everything works fine EXCEPT when rebooting the server.
With a standard reboot (shutdown -r now), the Mailarchiva configuration remains unfettered:
config show mailarchiva
mailarchiva=service
TCPPort=8090
access=public
status=enabled
Likewise, when the system requires a "signal-event post-upgrade; signal-event reboot" reboot, the configuration displays:
config show mailarchiva
mailarchiva=service
TCPPort=8090
access=public
status=enabled
In both reboot scenarios, however, the mailarchive.service does not start. Issuing the "systemctl status mailarchiva" command results in the following:
systemctl status mailarchiva
● mailarchiva.service - MailArchiva
Loaded: loaded (/etc/systemd/system/mailarchiva.service; enabled; vendor preset: enabled)
Active: inactive (dead)
I have to log in and run the following command to get things up and running . . .
systemctl start mailarchiva.service
When I issue the command, I'm greeted with . . .
systemctl status mailarchiva
● mailarchiva.service - MailArchiva
Loaded: loaded (/etc/systemd/system/mailarchiva.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2024-08-14 09:39:38 CDT; 11s ago
Process: 9494 ExecStart=/bin/sh /opt/mailarchiva/server/startserver (code=exited, status=0/SUCCESS)
Main PID: 9525 (java)
Memory: 396.5M
CGroup: /system.slice/mailarchiva.service
└─9525 /opt/mailarchiva/server/../jre64/bin/java -Djava.util.loggi...
Aug 14 09:39:37 <my.server.name> systemd[1]: Starting MailArchiva...
Aug 14 09:39:38 <my.server.name> mailarchiva[9494]: Tomcat started.
Aug 14 09:39:38 <my.server.name> systemd[1]: Started MailArchiva.
. . . and all is right with the world. I'm able to login at http://my.server.name:8090
I realize that the advice (see above) was for earlier versions of SMEserver and is probably no longer valid for my current version (10.2).
I'm sure there's something simple that I'm missing to get the mailarchiva service to initiate when the server boots, but I'm at a loss to know what it is.
If someone can steer me toward a solution, I will be indebted.
A copy of the mailarchiva.service file is viewable at:
https://lists2.roe3.org/mailarchiva.service.txt
Sidenote: I installed Mailarchiva on a Nethserver7 machine and it survives the reboot process (shutdown -r now) with no problem.
Regards,
Mark Drone
Regional Office of Education #3
Southeastern Illinois
-
Remember that though SME is built on CentOS 7 it has lots of things that it does to simplify use. Do not try and just use some generic guide online - as you have discovered it won't work. The system will override your attempts at persistence so you need to understand how the underlying systems work.
The wiki is your friend.
However warnings apply:
https://wiki.koozali.org/MailArchiva
Warning:
: probably obsolete.
Code last released in 2009..... :shock:
ln -s /etc/rc.d/init.d/e-smith-service /etc/rc.d/rc7.d/S99mailarchiva
We don't use init.d when we have systemd.
Here is your clue to using systemd:
https://wiki.koozali.org/Building_Your_Contrib#Systemd
chmod u+x /etc/systemd/system/mailarchiva.service
Don't put it there please. And it doesn't need +x either. See other unit files in that directory.
Probably best in:
/usr/lib/systemd/system
If you used an application that already had a unit file called say:
/usr/lib/systemd/system/foo.service
You would use an override file like:
/usr/lib/systemd/system/foo.service.d/50koozali.conf
Containing:
[Service]
#first we reset the ExecStartPre, if we do not want the initial lines to be executed
ExecStartPre=
#our needs
ExecStartPre=-/sbin/e-smith/service-status foo
ExecStartPre=-/sbin/e-smith/expand-template /opt/foo/foo.conf
Restart=always
[Install]
#so it start on boot
WantedBy=sme-server.target
"WantedBy=sme-server.target" is an important part of starting the service at boot. You need that in your unit file.
Either add it to your existing unit file or create a drop in to override your original.
eg
Create your unit file as per your attachment here:
/usr/lib/systemd/system/mailarchiva.service
Then add your override:
mkdir -p /usr/lib/systemd/system/mailarchiva.service.d
nano /usr/lib/systemd/system/mailarchiva.service.d/50koozali.conf
Paste this and save:
[Install]
#so it start on boot
WantedBy=sme-server.target
Reboot and it should start.
Hope that helps.
Further reading
https://wiki.koozali.org/SME10_serviceControl
Also search for 50koozali.conf for other examples.
It would be great if you could update the wiki if you have some success.
-
Thanks for the clear and concise explanation and for a very simple solution to the reboot problem.
Here are the 3 steps that I used. They should be easy for anyone else to replicate . . .
cp -f /opt/mailarchiva/server/mailarchiva.service /usr/lib/systemd/system/mailarchiva.service
mkdir -p /usr/lib/systemd/system/mailarchiva.service.d/
printf "[Install]\nWantedBy=sme-server.target\n" > /usr/lib/systemd/system/mailarchiva.service.d/50koozali.conf
In order to retrofit this into the Mailarchiva distribution, one will need to download the tarball (https://stimulussoft.b-cdn.net/mailarchiva-server-linux-v9.0.26.tar.gz), extract it somewhere (a temp directory), cd into the mailarchive/server directory, and edit the 'installservice' script, replacing lines 2 through 15 with the 3 lines above.
Then one can cd ../ and execute the "install" script.
I don't think Mailarchiva upgrades (essentially just a matter of downloading and running the install script again) will have any impact once this "reboot fix" has been applied.
Thanks again. I'm indebted.
(I'm not sure if I know how to update the wiki how-to, but I'm willing to learn)
-
Thanks for the clear and concise explanation and for a very simple solution to the reboot problem.
No worries - glad I could help and you got it in one.
Using an override file is good practice so if you used a prebuilt rpm and anyone ever updated a unit file, your one will override it.
In order to retrofit this into the Mailarchiva distribution, one will need to download the tarball (https://stimulussoft.b-cdn.net/mailarchiva-server-linux-v9.0.26.tar.gz), extract it somewhere (a temp directory), cd into the mailarchive/server directory, and edit the 'installservice' script, replacing lines 2 through 15 with the 3 lines above.
Note that that is VERY old and way out of support. So be very, very, careful.
I don't think Mailarchiva upgrades (essentially just a matter of downloading and running the install script again) will have
any impact once this "reboot fix" has been applied.
Unlikely but that would be a Mailarchiva issue, not SME! And hence my comments about support above.
Thanks again. I'm indebted.
You are indeed indebted so to repay that you can learn to use the wiki ;-)
(I'm not sure if I know how to update the wiki how-to, but I'm willing to learn)
First, get a wiki account.
See here (it is a bit non-obvious unfortunately)
https://wiki.koozali.org/Help:Contents
Then you can login and amend the page - it isn't difficult!
Or get a bugzilla account and open a documentation bug.
Either way, if you want to help more then DM me with your full name and an email address for notifications and I will add you to our Koozali Rocket.Chat where we tend to hang out and you can get a bit more involved and learn!
-
Remember that though SME is built on CentOS 7 it has lots of things that it does to simplify use. Do not try and just use some generic guide online - as you have discovered it won't work. The system will override your attempts at persistence so you need to understand how the underlying systems work.
I second that
Here is your clue to using systemd:
https://wiki.koozali.org/Building_Your_Contrib#Systemd
chmod u+x /etc/systemd/system/mailarchiva.service
Don't put it there please. And it doesn't need +x either. See other unit files in that directory.
Probably best in:
/usr/lib/systemd/system
If you used an application that already had a unit file called say:
/usr/lib/systemd/system/foo.service
that part I can only say, no.
From what I read , this is not to create a contrib but to create a local manual install, so /etc/systemd/system is still the very sweet spot
/etc is the place for local modifications.
/usr/lib is for vendor
bu beware that things in etc will overide what could be latter installed in /usr/lib
to survive rebbot you will need
mkdir /etc/systemd/system/mailarchiva.service.d
printf "[Install]\nWantedBy=sme-server.target" > /etc/systemd/system/mailarchiva.service.d/50koozali.conf
config set mailarchiva service status enabled
signal-event console-save
edit fixed typo in command
-
/etc/systemd/system
Damn - I thought you avoided that place ;-)
/etc/systemd/system/mailarchiva.service.d
So you can do the same there? Bother.
I hate systemd :-(
-
to survive reboot you will need
mkdir /etc/systemd/system/mailarchiva.service.d
printf "[Install]\nWantedBy=sme-server.target" > /etc/systemd/system/mailarchiva.service.d/50koozali.conf
config setprop mailarchiva service status enabled
signal-event console-save
Thanks for the additional guidance.
When I issued the following, the server chastised me, so I did some homework and changed the command (see below) and had success.
[root@sme10 server]# config setprop mailarchiva service status enabled
/sbin/e-smith/db dbfile setprop key prop1 val1 [prop2 val2] [prop3 val3] ...
[root@sme10 server]# db configuration set mailarchiva service status enabled
For reference purposes . . .
mkdir /etc/systemd/system/mailarchiva.service.d
printf "[Install]\nWantedBy=sme-server.target" > /etc/systemd/system/mailarchiva.service.d/50koozali.conf
db configuration set mailarchiva service status enabled
signal-event console-save
The Mailarchiva service does indeed survive the reboot as you said it would.
One additional modification is needed to make it accessible via public IP.
db configuration set mailarchiva service TCPPort 8090 access public status enabled
signal-event console-save
I'm delighted and very pleased with the help I've received in this forum.
I'm getting ready to start composing an addendum for the https://wiki.koozali.org/MailArchiva wiki.
-
my bad i put setprop in place of set. fixed in my original post where i assumed the entry was to be created
for public access this is one way. you could also proxy it via httpd. this would add the ssl to access it.
db accounts set mailarchiva ProxyPass Target http://localhost:8090
expand-template /etc/httpd/conf/httpd.conf
systemctl restart httpd-e-smith
then https://mydomain.com/mailarchiva
you can also limit access see
https://wiki.koozali.org/SME_Server:Documentation:ProxyPass#ProxyPass_a_alias.2Fdirectory.2Flocation
-
you could also proxy it via httpd. this would add the ssl to access it.
db accounts set mailarchiva ProxyPass Target http://localhost:8090
expand-template /etc/httpd/conf/httpd.conf
systemctl restart httpd-e-smith
then https://mydomain.com/mailarchiva
Thanks for the suggestion. I'm eager to give this a try . . . presuming, of course, that it doesn't alter or interfere with the previous modifications made to the system. :-)
Since I'm a novice at using SME Server's "db" way of doing things, can I presume this to be the proper method to reverse the above should one wish to do so?
db accounts delprop mailarchiva ProxyPass
db accounts delprop mailarchiva Target
expand-template /etc/httpd/conf/httpd.conf
systemctl restart httpd-e-smith
BTW . . . I drafted an addendum to the Mailarchiva wiki how-to:
https://wiki.koozali.org/MailArchiva#Addendum:_Installing_MailArchiva_On_Premise_v9.0.26_on_SME_Server_10.1
(https://wiki.koozali.org/MailArchiva#Addendum:_Installing_MailArchiva_On_Premise_v9.0.26_on_SME_Server_10.1)
Editorial comments & critiques welcomed.
-
db accounts delete mailarchiva
-
db accounts delete mailarchiva
Way simple. Thanks. I'll give it a go.
Later
Well . . . I tried the ProxyPass method and got a "404 Not Found" error. It went through the motions, landing at https://myserver/index.do but that's as far as it went. The page displays:
Not Found
The requested URL /index.do was not found on this server. *Sigh*
-
proxypass is sensible to the url. you need to pay attention to the trailing / particularly on each url.
also it might be that the mailarchiva software need a configuration to be behind a proxy. i did mot check their documentation
-
proxypass is sensible to the url. you need to pay attention to the trailing / particularly on each url.
also it might be that the mailarchiva software need a configuration to be behind a proxy. i did mot check their documentation
I'm not versed in this, so can't really contribute. Here's the Mailarchiva Help section on Apache Proxy:
https://help.mailarchiva.com/apacheproxy (https://help.mailarchiva.com/apacheproxy)
Perhaps there's something in their guide that sheds some light on getting it to work.
-
from this lonk it seems they more planned the reverse proxy with a dedicated domain, not a uri pointing to it.
so you could either use their example to make a custom template, either try the second option for proxypass as shown in the link i posted above. However looking at their example and the specific needs you might have more chances with a template custom.
-
BTW . . . I drafted an addendum to the Mailarchiva wiki how-to:
https://wiki.koozali.org/MailArchiva#Addendum:_Installing_MailArchiva_On_Premise_v9.0.26_on_SME_Server_10.1
(https://wiki.koozali.org/MailArchiva#Addendum:_Installing_MailArchiva_On_Premise_v9.0.26_on_SME_Server_10.1)
Editorial comments & critiques welcomed.
Sorry been slacking.
Looks an excellent start - I think we can dump a load of the old stuff.
-
Looks an excellent start - I think we can dump a load of the old stuff.
Thanks. Appreciate that.
I didn't want to step on any toes by removing anything, but can start cleaning it up if it's OK to do so.
-
NP.
Nice to get some help!!
If it goes south it has history :-)
You can look at some other pages for guidance on things like note/warning boxes.
Please ask over on Rocket for more info.
-
I tidied up and dumped the old stuff.
Please check!
-
I tidied up and dumped the old stuff.
Please check!
Looks so much better. Thanks!
There are a few additions and cosmetic adjustments that I need to make when time allows. Your clean-up will make it easier to do so.
As always . . . greatly appreciated.
-
NP.
You can chat to us on Rocket - we don't bite!
There's lots of doc stuff that needs doing and it is easy to chat through there.