Martin Dellwo on 12 Mar 2013 19:40:35 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Setting an environment variable for servers on Linux...


So much for one Linux standard.  The init/rc stuff is all over the map.  Recent Fedora uses systemctl stuff and I have no idea where you set env variables for that.  But irrelevant--that won't work for regular users.  I would suggest putting it in profile.d.  And if Apache doesn't pick that up, there's some sort of SETENV directive you can put directly in your Apache config...  oh, but maybe that doesn't help you if you need it for the startup process itself.

-M
On Mar 12, 2013, at 10:32 PM, Eric at Lucii.org <eric@lucii.org> wrote:

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Fred:

I'm not qualified to answer this.
Having stated my disclaimer, it's an interesting question and so I'm thinking out loud...

The following article mentions inittab: http://www.ibm.com/developerworks/library/l-linuxboot/
but inittab is missing in modern Debian/Ubuntu.  What about /etc/init/rc.conf ?  There
are a couple of export statements in there.  Since init is the first "userspace" program and
the parent to all subsequent processes it seems like a good location to start.

Ah, now Rich mentions /etc/env.d - but I don't have that in my Linux Mint 13 system.
There is /etc/init/rc.conf with a couple of "export" statements.

HTH and good luck.
Eric

On 03/12/2013 09:16 PM, Matt Murphy wrote:
Those rc#.d scripts define environments for individual processes, I think.  I don't think there's a quick way to do what you want to do.  Anyone?

MM

On Tue, Mar 12, 2013 at 4:42 PM, Fred Stluka <fred@bristle.com <mailto:fred@bristle.com>> wrote:

PLUG folks,

What's the best way to set an environment variable on Linux, so that it is found not only by shells, but also for servers processes like Apache?

I have created: /etc/profile.d/hhl.sh export HHL_ENVIRONMENT=test /etc/profile.d/hhl.csh setenv HHL_ENVIRONMENT test so now when any user logs in with any sh- or csh-based shell, the env var is defined.

However, Apache and other servers are launched at boor time via scripts and symlinks in /etc/rc.d, and they do NOT pick up the env var.

Is there a single place to define it so all processes see it?  Or should I just add the line: . /etc/profile.d/hhl.sh to each of the appropriate files in: /etc/rc.d/init.d

I googled a bit and didn't find any better answer.

Any thoughts?  Thanks! --Fred ------------------------------__------------------------------__------------ Fred Stluka -- mailto:fred@bristle.com <mailto:fred@bristle.com> -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. ------------------------------__------------------------------__------------ _______________________________________________________________________________ Philadelphia Linux Users Group         --        http://www.phillylinux.org Announcements - http://lists.phillylinux.org/__mailman/listinfo/plug-announce <http://lists.phillylinux.org/mailman/listinfo/plug-announce> General Discussion  --   http://lists.phillylinux.org/__mailman/listinfo/plug <http://lists.phillylinux.org/mailman/listinfo/plug>




___________________________________________________________________________ Philadelphia Linux Users Group         --        http://www.phillylinux.org Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug


- --
#  Eric Lucas
#     I'm confessin' I never took a lesson,
#     All my notes are a matter of guessin'
#     Hopin' they'll come out in some kinda manner
#     that'll make that yakety sound.
#       - Boots Randolph, Merle Travis, Chet Atkins, Mark Knopfler
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEARECAAYFAlE/5R4ACgkQ2sGpvXQrZ/4mVACgyz8guZqUkfA3BON32t9nPuKk
D9sAoIBg+YZ5/IrALqQ8EW/po/f4egiJ
=Eo/I
-----END PGP SIGNATURE-----
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug

--
Martin Dellwo
cell: (484) 437-3662




___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug