Koozali.org: home of the SME Server

Mailarchiva Service Not Surviving Reboot. Need Assistance Please.

Offline mdrone

  • *
  • 27
  • +0/-0
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

Offline ReetP

  • *
  • 3,856
  • +5/-0
Re: Mailarchiva Service Not Surviving Reboot. Need Assistance Please.
« Reply #1 on: August 15, 2024, 12:26:54 PM »
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

Quote
Warning:
   : probably obsolete.

Code last released in 2009.....  :shock:

Quote
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

Code: [Select]
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:

Code: [Select]
/usr/lib/systemd/system
If you used an application that already had a unit file called say:

Code: [Select]
/usr/lib/systemd/system/foo.service
You would use an override file like:

Code: [Select]
/usr/lib/systemd/system/foo.service.d/50koozali.conf
Containing:

Code: [Select]
[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:

Code: [Select]
mkdir -p /usr/lib/systemd/system/mailarchiva.service.d

nano /usr/lib/systemd/system/mailarchiva.service.d/50koozali.conf

Paste this and save:

Code: [Select]
[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.

...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline mdrone

  • *
  • 27
  • +0/-0
Re: Mailarchiva Service Not Surviving Reboot. Need Assistance Please.
« Reply #2 on: August 15, 2024, 05:12:24 PM »
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)

Offline ReetP

  • *
  • 3,856
  • +5/-0
Re: Mailarchiva Service Not Surviving Reboot. Need Assistance Please.
« Reply #3 on: August 15, 2024, 06:33:30 PM »
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.

Quote
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.

Quote
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.

Quote
Thanks again. I'm indebted.

You are indeed indebted so to repay that you can learn to use the wiki ;-)

Quote
(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!
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Jean-Philippe Pialasse

  • *
  • 2,842
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Mailarchiva Service Not Surviving Reboot. Need Assistance Please.
« Reply #4 on: August 16, 2024, 12:03:57 AM »
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

Code: [Select]
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:

Code: [Select]
/usr/lib/systemd/system
If you used an application that already had a unit file called say:

Code: [Select]
/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
Code: [Select]
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
« Last Edit: August 17, 2024, 01:20:25 AM by Jean-Philippe Pialasse »

Offline ReetP

  • *
  • 3,856
  • +5/-0
Re: Mailarchiva Service Not Surviving Reboot. Need Assistance Please.
« Reply #5 on: August 16, 2024, 12:11:29 AM »
Quote
/etc/systemd/system

Damn - I thought you avoided that place ;-)

Quote
/etc/systemd/system/mailarchiva.service.d

So you can do the same there? Bother.

I hate systemd :-(
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline mdrone

  • *
  • 27
  • +0/-0
Re: Mailarchiva Service Not Surviving Reboot. Need Assistance Please.
« Reply #6 on: August 16, 2024, 04:56:08 PM »
Quote
to survive reboot you will need
Code: [Select]
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 . . .

Code: [Select]
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.

Code: [Select]
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.
« Last Edit: August 16, 2024, 05:17:52 PM by mdrone »

Offline Jean-Philippe Pialasse

  • *
  • 2,842
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Mailarchiva Service Not Surviving Reboot. Need Assistance Please.
« Reply #7 on: August 17, 2024, 01:29:08 AM »
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

Offline mdrone

  • *
  • 27
  • +0/-0
Re: Mailarchiva Service Not Surviving Reboot. Need Assistance Please.
« Reply #8 on: August 17, 2024, 05:56:27 PM »
Quote
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?

Code: [Select]
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

Editorial comments & critiques welcomed.

Offline Jean-Philippe Pialasse

  • *
  • 2,842
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Mailarchiva Service Not Surviving Reboot. Need Assistance Please.
« Reply #9 on: August 18, 2024, 03:37:33 PM »
db accounts delete mailarchiva

Offline mdrone

  • *
  • 27
  • +0/-0
Re: Mailarchiva Service Not Surviving Reboot. Need Assistance Please.
« Reply #10 on: August 18, 2024, 05:26:32 PM »
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*
« Last Edit: August 18, 2024, 05:57:16 PM by mdrone »

Offline Jean-Philippe Pialasse

  • *
  • 2,842
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Mailarchiva Service Not Surviving Reboot. Need Assistance Please.
« Reply #11 on: August 18, 2024, 08:39:28 PM »
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
« Last Edit: August 18, 2024, 08:41:02 PM by Jean-Philippe Pialasse »

Offline mdrone

  • *
  • 27
  • +0/-0
Re: Mailarchiva Service Not Surviving Reboot. Need Assistance Please.
« Reply #12 on: August 18, 2024, 10:18:11 PM »
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

Perhaps there's something in their guide that sheds some light on getting it to work.

Offline Jean-Philippe Pialasse

  • *
  • 2,842
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Mailarchiva Service Not Surviving Reboot. Need Assistance Please.
« Reply #13 on: August 19, 2024, 05:05:09 AM »
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.




Offline ReetP

  • *
  • 3,856
  • +5/-0
Re: Mailarchiva Service Not Surviving Reboot. Need Assistance Please.
« Reply #14 on: August 19, 2024, 08:17:18 PM »

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

Editorial comments & critiques welcomed.

Sorry been slacking.

Looks an excellent start - I think we can dump a load of the old stuff.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation