Re: [systemd-devel] How to set complex environment for apache?

2012-05-24 Thread Sven Anders
Am 24.05.2012 01:56, schrieb Lennart Poettering:
 On Wed, 23.05.12 16:45, Joachim Banzhaf (joachim.banz...@googlemail.com) 
 wrote:
 
 Am 22.05.2012 22:51, schrieb Zbigniew Jędrzejewski-Szmek:
 On 05/22/2012 10:46 PM, Joachim Banzhaf wrote:
 It sets and modifies environment variables. I'll have a look and try,
 See also Environment= and EnvironmentFile= in systemd.exec(5).

 Zbyszek

 I tried now. Not sure if the result is optimal, but it might still help
 others with a similar problem.

 The DB2 provided profile script (for now) only sets and changes
 environment variables (PATH, LD_LIBRARY_PATH, CLASSPATH, DB2INSTANCE),
 with some if/else logic based on what product options are installed or not.

 I cannot use the script as is in ExecStartPre because this only allows
 binaries.
 I even tried /bin/bash script, but as expected the changed environment
 is not inherited by ExecStart

 So the only systemd options (I know of now) left are Environment and
 EnvironmentFile.
 I went with EnvironmentFile, because that is what I used before. I just
 added the variables by hand instead of by sourcing the db2profile
 script. This worked (I had to export the variables to make it backward
 compatible with SysV init though).

 If I'd use this approach with systemd and DB2 I'd have to manually
 analyze changes in the db2profile and try to mimic that with every
 fixpack or special build delivered by IBM. Too error prone, not acceptable.

 Finally I tried this, and it worked. But I am not sure about side effects:

 I changed
ExecStart=/usr/sbin/start_apache2 -D SYSTEMD -k start'
 to
ExecStart=/bin/bash -c '. /home/db2inst1/sqllib/db2profile;
 /usr/sbin/start_apache2 -D SYSTEMD -k start'

 Thanks for you support!
 
 This solution is pretty much what I'd recommend too.

Would adding an exec allow to get rid of the bash?
Will this have any advantages?

  ExecStart=/bin/bash -c '. /home/db2inst1/sqllib/db2profile; exec 
/usr/sbin/start_apache2 -D SYSTEMD -k start'

For some cases it would be nice if you could run an command to set complex 
environments.
Something like:

  EnvironmentExec=/home/db2inst1/sqllib/db2profile

But instead of just reading the file, it's executed and the environment 
variables are taken.

Another idea I had was to have the possibility to set single variables which 
can be used in
the Exec command by executing external commands. But I think this would made 
systemd too complex...


Regards
 Sven Anders

-- 
 Sven Anders and...@anduras.de () UTF-8 Ribbon Campaign
 /\ Support plain text e-mail
 ANDURAS intranet security AG
 Messestrasse 3 - 94036 Passau - Germany
 Web: www.anduras.de - Tel: +49 (0)851-4 90 50-0 - Fax: +49 (0)851-4 90 50-55

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety.
  - Benjamin Franklin
attachment: anders.vcf___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to set complex environment for apache?

2012-05-23 Thread Joachim Banzhaf
Am 22.05.2012 22:51, schrieb Zbigniew Jędrzejewski-Szmek:
 On 05/22/2012 10:46 PM, Joachim Banzhaf wrote:
 It sets and modifies environment variables. I'll have a look and try,
 See also Environment= and EnvironmentFile= in systemd.exec(5).

 Zbyszek

I tried now. Not sure if the result is optimal, but it might still help
others with a similar problem.

The DB2 provided profile script (for now) only sets and changes
environment variables (PATH, LD_LIBRARY_PATH, CLASSPATH, DB2INSTANCE),
with some if/else logic based on what product options are installed or not.

I cannot use the script as is in ExecStartPre because this only allows
binaries.
I even tried /bin/bash script, but as expected the changed environment
is not inherited by ExecStart

So the only systemd options (I know of now) left are Environment and
EnvironmentFile.
I went with EnvironmentFile, because that is what I used before. I just
added the variables by hand instead of by sourcing the db2profile
script. This worked (I had to export the variables to make it backward
compatible with SysV init though).

If I'd use this approach with systemd and DB2 I'd have to manually
analyze changes in the db2profile and try to mimic that with every
fixpack or special build delivered by IBM. Too error prone, not acceptable.

Finally I tried this, and it worked. But I am not sure about side effects:

I changed
   ExecStart=/usr/sbin/start_apache2 -D SYSTEMD -k start'
to
   ExecStart=/bin/bash -c '. /home/db2inst1/sqllib/db2profile;
/usr/sbin/start_apache2 -D SYSTEMD -k start'


Thanks for you support!
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to set complex environment for apache?

2012-05-23 Thread Lennart Poettering
On Wed, 23.05.12 16:45, Joachim Banzhaf (joachim.banz...@googlemail.com) wrote:

 Am 22.05.2012 22:51, schrieb Zbigniew Jędrzejewski-Szmek:
  On 05/22/2012 10:46 PM, Joachim Banzhaf wrote:
  It sets and modifies environment variables. I'll have a look and try,
  See also Environment= and EnvironmentFile= in systemd.exec(5).
 
  Zbyszek
 
 I tried now. Not sure if the result is optimal, but it might still help
 others with a similar problem.
 
 The DB2 provided profile script (for now) only sets and changes
 environment variables (PATH, LD_LIBRARY_PATH, CLASSPATH, DB2INSTANCE),
 with some if/else logic based on what product options are installed or not.
 
 I cannot use the script as is in ExecStartPre because this only allows
 binaries.
 I even tried /bin/bash script, but as expected the changed environment
 is not inherited by ExecStart
 
 So the only systemd options (I know of now) left are Environment and
 EnvironmentFile.
 I went with EnvironmentFile, because that is what I used before. I just
 added the variables by hand instead of by sourcing the db2profile
 script. This worked (I had to export the variables to make it backward
 compatible with SysV init though).
 
 If I'd use this approach with systemd and DB2 I'd have to manually
 analyze changes in the db2profile and try to mimic that with every
 fixpack or special build delivered by IBM. Too error prone, not acceptable.
 
 Finally I tried this, and it worked. But I am not sure about side effects:
 
 I changed
ExecStart=/usr/sbin/start_apache2 -D SYSTEMD -k start'
 to
ExecStart=/bin/bash -c '. /home/db2inst1/sqllib/db2profile;
 /usr/sbin/start_apache2 -D SYSTEMD -k start'
 
 
 Thanks for you support!

This solution is pretty much what I'd recommend too.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to set complex environment for apache?

2012-05-22 Thread Joachim Banzhaf
It sets and modifies environment variables. I'll have a look and try,
thanks.

sorry for smartphone brevity
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to set complex environment for apache?

2012-05-22 Thread Zbigniew Jędrzejewski-Szmek
On 05/22/2012 10:46 PM, Joachim Banzhaf wrote:
 It sets and modifies environment variables. I'll have a look and try,
See also Environment= and EnvironmentFile= in systemd.exec(5).

Zbyszek
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] How to set complex environment for apache?

2012-05-22 Thread Zbigniew Jędrzejewski-Szmek
On 05/22/2012 10:16 PM, Joachim Banzhaf wrote:
 Me again :)
 
 I use apache to serve php pages that connect to a DB2 database via the
 php_pdo interface.
 For this to work, I have to set a DB2 specific environment.
 To make that easy, there is a shell script provided that does the
 necessary adjustments (db2profile).
 
 With SysV init I sourced that script in /etc/sysctl/apache2 and all was
 fine.
 That does no longer work. I guess systemd interprets that file differently?
 Are there alternatives? I mean, other than mimicking db2profile which
 would need to be verifyed (and posibly adapted) after every software update.
What does this script do? Depending on the details, ExecStartPre might
be what
you're looking for.

Zbyszek

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/systemd-devel