[systemd-devel] PgSQL, MySQL systemd services - how to rewrite complex init scripts?

Gustavo Sverzut Barbieri barbieri at profusion.mobi
Sat Apr 9 08:15:27 PDT 2011

2011/4/9 Michał Piotrowski <mkkp4x4 at gmail.com>:
> Hi,
> I want to rewrite postgresql and mysqld init scripts for my system
> (later, of course, I want to share them with others) and I wonder if
> there are any recomendations how to rewrite complex scripts.
> Postgresql script has perform_initdb(), initdb() and upgrade()
> functions. IMO these functions should be in separated script. The
> problem is that there are some database format version checks. IMO
> these checks are very important, so maybe it would be a good way to
> move them to separated script and run them with ExecStartPre? But what
> happens when this script exits because database format is old and
> needs an update? How to handle such situation?
> Mysql script also has some data dir creation code - I think it can
> also be moved to separated script.

As mentioned with handful similar cases: this should be handled as
part of the daemon itself, not initscript.  That's the final solution
we should aim as it's the only sane place to do it.

If you wish to remedy this situation temporarily, then just put it in
a ExecStartPre as you mentioned. But don't take it as a "final
solution" please. This script should handle the update itself, and
just exit with failure if there is a blocking feature that would
forbid the ExecStart to run.

Gustavo Sverzut Barbieri
http://profusion.mobi embedded systems
MSN: barbieri at gmail.com
Skype: gsbarbieri
Mobile: +55 (19) 9225-2202

More information about the systemd-devel mailing list