[SOLVED] Customized startup scripts.

This forum is dedicated to advanced help and support :

Ask here your questions about advanced usage of Mageia. For example you may post here all your questions about network and automated installs, complex server configurations, kernel tuning, creating your own Mageia mirrors, and all tasks likely to be touchy even for skilled users.

[SOLVED] Customized startup scripts.

Postby linuxdad » Dec 23rd, '13, 18:55

I would like to be able to control Mulitple Daemons on the server at the same time (thus insuring that they all are communicating together).

Previously this was accomplished by modifying a startup script in /etc/init.d/{process name}, what is the recommended process for the systemctl tools?

Thank you.
Last edited by linuxdad on Dec 24th, '13, 18:23, edited 1 time in total.
Albert E. Whale, CEH CHS CISA CISSP
President - Chief Security Officer
IT Security, Inc. - http://www.IT-Security-inc.com
Pittsburgh, PA
Email: Albert.Whale@IT-Security-inc.com
linuxdad
 
Posts: 123
Joined: Nov 17th, '13, 21:14

Re: Customized startup scripts.

Postby doktor5000 » Dec 23rd, '13, 19:21

Can you please provide a more specific use-case?
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18071
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Customized startup scripts.

Postby linuxdad » Dec 23rd, '13, 20:03

Certainly, specific Use case below.

Program B, relies on Program A, C and Z to be running before it can operate properly. Disturbing any of these systems requires a complete reset to Program Z, then Program A, Program C and then Program B. This was all accomplished by customized the Startup sequencing (the Start/Stop numbers), as well as the contents of the startup and shutdown scripts.


Another Example:

Program Swatch (System Watcher), relies on the Syslogd process to record logfile information in the /var/log/swatch file. If the syslogd is restarted (every Sunday of course), then swatch does not have the correct position in the logfile.

In this case swatch is dependant on syslog, and needs to be restarted every time syslogd is refreshed or recycled.

Do these help?
Albert E. Whale, CEH CHS CISA CISSP
President - Chief Security Officer
IT Security, Inc. - http://www.IT-Security-inc.com
Pittsburgh, PA
Email: Albert.Whale@IT-Security-inc.com
linuxdad
 
Posts: 123
Joined: Nov 17th, '13, 21:14

Re: Customized startup scripts.

Postby doktor5000 » Dec 23rd, '13, 20:37

linuxdad wrote:Certainly, specific Use case below.

Program B, relies on Program A, C and Z to be running before it can operate properly. Disturbing any of these systems requires a complete reset to Program Z, then Program A, Program C and then Program B. This was all accomplished by customized the Startup sequencing (the Start/Stop numbers), as well as the contents of the startup and shutdown scripts.
Yoo probably have to adapt the systemd units and provide the dependency information for your use case. For the ordered restart, not sure if that can be achieved, you may have to google around for that or ask on the systemd mailing lists. There are ways to specify similar stuff, e.g. the Requires, Wants, Before, After, PartOf, OnFailure, PropagatesReloadTo=, ReloadPropagatedFrom= and the verious Condition* stanzas. Cf
Code: Select all
man systemd.unit


linuxdad wrote:Another Example:

Program Swatch (System Watcher), relies on the Syslogd process to record logfile information in the /var/log/swatch file. If the syslogd is restarted (every Sunday of course), then swatch does not have the correct position in the logfile.

In this case swatch is dependant on syslog, and needs to be restarted every time syslogd is refreshed or recycled.

Do these help?

One alternative could be to switch to native journal-triggerd. This is available in cauldron and can be easily rebuilt for Mageia 3
See also http://jjacky.com/2013-10-06-run-trigge ... -messages/
Another would be to fiddle with systemd-notify for the rsyslogd service to notify systemd, which then should restart swatch.
But also best ask on systemd mailing list for better alternatives.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18071
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Customized startup scripts.

Postby linuxdad » Dec 23rd, '13, 21:46

I appreciate your response, and also the referral.

Merry Christmas.
Albert E. Whale, CEH CHS CISA CISSP
President - Chief Security Officer
IT Security, Inc. - http://www.IT-Security-inc.com
Pittsburgh, PA
Email: Albert.Whale@IT-Security-inc.com
linuxdad
 
Posts: 123
Joined: Nov 17th, '13, 21:14

Re: Customized startup scripts.

Postby jiml8 » Dec 23rd, '13, 21:55

Scripts placed in /etc/init.d still work.
jiml8
 
Posts: 1254
Joined: Jul 7th, '13, 18:09

Re: Customized startup scripts.

Postby linuxdad » Dec 23rd, '13, 22:15

That would make my life a lot easier if that is the case. I will have to check it out.
Albert E. Whale, CEH CHS CISA CISSP
President - Chief Security Officer
IT Security, Inc. - http://www.IT-Security-inc.com
Pittsburgh, PA
Email: Albert.Whale@IT-Security-inc.com
linuxdad
 
Posts: 123
Joined: Nov 17th, '13, 21:14

Re: Customized startup scripts.

Postby doktor5000 » Dec 23rd, '13, 22:30

Well, systemd is backwards compatible, why did you assume that isn't the case?
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18071
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Customized startup scripts.

Postby linuxdad » Dec 24th, '13, 03:00

Hmm, i AM CoNfusEd now.

If I start Sendmail, I start it as:

service sendmail restart

However, this transfers control to the systemctl resources:
Code: Select all
[root@ns ~]# service sendmail restart
Restarting sendmail (via systemctl):                            [  OK  ]


What I really want is here:
Code: Select all
[root@ns ~]# ls -la /etc/init.d/sendmail
-rwx------ 1 root root 3217 Dec  8 11:24 /etc/init.d/sendmail*


I either need to be able to restart sendmail with my service option, or update the systemctl scripts to use this startup script version.

Any suggestions?
Last edited by isadora on Dec 24th, '13, 08:37, edited 1 time in total.
Reason: Command-output placed between [CODE]-tags, to keep the forum readable. ;)
Albert E. Whale, CEH CHS CISA CISSP
President - Chief Security Officer
IT Security, Inc. - http://www.IT-Security-inc.com
Pittsburgh, PA
Email: Albert.Whale@IT-Security-inc.com
linuxdad
 
Posts: 123
Joined: Nov 17th, '13, 21:14

Re: Customized startup scripts.

Postby doktor5000 » Dec 24th, '13, 11:31

Well, then you want to adapt the systemd units:

[doktor5000@Mageia3 ~]$ systemctl status sendmail
sendmail.service - Sendmail Mail Transport Agent
Loaded: loaded (/usr/lib/systemd/system/sendmail.service; enabled)
Active: inactive (dead)
CGroup: name=systemd:/system/sendmail.service

[doktor5000@Mageia3 ~]$ cat /usr/lib/systemd/system/sendmail.service
[Unit]
Description=Sendmail Mail Transport Agent
After=syslog.target network.target
Conflicts=postfix.service exim.service
Wants=sm-client.service

[Service]
Type=forking
PIDFile=/var/run/sendmail.pid
Environment=QUEUE=1h
Environment=DAEMONOPTIONS=
EnvironmentFile=-/etc/sysconfig/sendmail
ExecStartPre=-/usr/bin/newaliases
ExecStartPre=-/usr/bin/make -C /etc/mail -s
ExecStart=/bin/sh -c 'exec /usr/sbin/sendmail.sendmail $DAEMONOPTIONS -bd $(if [ -n "$QUEUE" ]; then echo -q$QUEUE; fi)'


[Install]
WantedBy=multi-user.target
Also=sm-client.service

[doktor5000@Mageia3 ~]$ systemctl status sm-client
sm-client.service - Sendmail Mail Transport Client
Loaded: loaded (/usr/lib/systemd/system/sm-client.service; enabled)
Active: inactive (dead)
CGroup: name=systemd:/system/sm-client.service

[doktor5000@Mageia3 ~]$ cat /usr/lib/systemd/system/sm-client.service
[Unit]
Description=Sendmail Mail Transport Client
After=syslog.target network.target sendmail.service
Conflicts=postfix.service exim.service
BindTo=sendmail.service

[Service]
Type=forking
PIDFile=/var/run/sm-client.pid
Environment=QUEUE=1h
EnvironmentFile=-/etc/sysconfig/sendmail
ExecStartPre=/bin/touch /var/run/sm-client.pid
ExecStartPre=/bin/chown mail:mail /var/run/sm-client.pid
ExecStartPre=-/usr/bin/make -C /etc/mail -s
ExecStart=/bin/sh -c 'exec /usr/sbin/sendmail.sendmail -L sm-msp-queue -Ac $(if [ -n "$QUEUE" ]; then echo -q$QUEUE; fi)'


[Install]
WantedBy=multi-user.target
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18071
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Customized startup scripts.

Postby linuxdad » Dec 24th, '13, 15:45

Exactly what I needed, and your example also answered another question I had about multiple Pre Startup commands.

Merry Christmas!
Albert E. Whale, CEH CHS CISA CISSP
President - Chief Security Officer
IT Security, Inc. - http://www.IT-Security-inc.com
Pittsburgh, PA
Email: Albert.Whale@IT-Security-inc.com
linuxdad
 
Posts: 123
Joined: Nov 17th, '13, 21:14

Re: Customized startup scripts.

Postby isadora » Dec 24th, '13, 16:24

Linuxdad, please mark the topic accordingly, thanks ahead. ;)
..........bird from paradise..........

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
—Antoine de Saint-Exupéry
User avatar
isadora
 
Posts: 2767
Joined: Mar 25th, '11, 16:03
Location: Netherlands

Re: [SOLVED] Customized startup scripts.

Postby linuxdad » Dec 26th, '13, 17:35

Ok, I am updating my sendmail.service configuration file (don't try this on your server).

Here it is:

Code: Select all
[Unit]
Description=Sendmail Mail Transport Agent
After=syslog.target network.target mimedefang.service
Conflicts=postfix.service exim.service
Wants=sm-client.service

[Service]
Type=forking
PIDFile=/var/run/sendmail.pid
Environment=QUEUE=15m
Environment=DAEMONOPTIONS=
EnvironmentFile=-/etc/sysconfig/sendmail
ExecStartPre=-/usr/bin/chmod 1755 /tmpfs
ExecStartPre= /etc/init.d/mimedefang start
ExecStartPre=-/usr/bin/newaliases
ExecStartPre=-/usr/bin/make -C /etc/mail -s
ExecStart=/bin/sh -c 'exec /usr/sbin/sendmail.sendmail $DAEMONOPTIONS -bd $(if [ -n "$QUEUE" ]; then echo -q$QUEUE; fi)'

[Install]
WantedBy=multi-user.target
Also=sm-client.service


As I understand, the Unit description and After clause indicates that syslog, network, and mimedefang all need to be running before Sendmail starts up.

I have updated the ExecStartPre commands to add the information I have on my existing server.

Where is the clause that says mimedefang is supposed to be restarted when sendmail is restarted? How do I do that?

I have RTFM the link here https://wiki.archlinux.org/index.php/systemd#Writing_custom_.service_files but I cannot find the answer on the site.

Any suggestions?
Albert E. Whale, CEH CHS CISA CISSP
President - Chief Security Officer
IT Security, Inc. - http://www.IT-Security-inc.com
Pittsburgh, PA
Email: Albert.Whale@IT-Security-inc.com
linuxdad
 
Posts: 123
Joined: Nov 17th, '13, 21:14

Re: [SOLVED] Customized startup scripts.

Postby doktor5000 » Dec 26th, '13, 20:32

linuxdad wrote:Where is the clause that says mimedefang is supposed to be restarted when sendmail is restarted? How do I do that?

I have RTFM the link here https://wiki.archlinux.org/index.php/systemd#Writing_custom_.service_files but I cannot find the answer on the site.

Any suggestions?

As mentioned previously, best and definitive information can probably be obtained by asking on systemd mailing lists.
http://www.freedesktop.org/wiki/Software/systemd/

FWIW, you only read some arbitrary wiki page. Did you read the upstream documentation, and maybe also the series of blog posts of Lennart Poettering, the systemd author? You can find links to those at the above linked page under "The systemd for Administrators Blog Series"
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 18071
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: [SOLVED] Customized startup scripts.

Postby linuxdad » Dec 26th, '13, 22:11

Thank you Doctor. I realize that mine is a specific need, just trying to pull as much information in as little time possible. (I was golden with the previous init scripts).

Thank you again, and Happy Holidays.
Albert E. Whale, CEH CHS CISA CISSP
President - Chief Security Officer
IT Security, Inc. - http://www.IT-Security-inc.com
Pittsburgh, PA
Email: Albert.Whale@IT-Security-inc.com
linuxdad
 
Posts: 123
Joined: Nov 17th, '13, 21:14


Return to Advanced support

Who is online

Users browsing this forum: No registered users and 1 guest