LC_ALL for daemons
I'm sure I've seen a thread on this, but a casual search didn't turn it up. (I'm always looking in the wrong places.) When I'm logged in as a user, I can set the appropriate environmen variables, but when a daemon is running, where is it going to get them? Joel Rees
Re: LC_ALL for daemons
On Apr 30, 2004, at 2:24 AM, Joel Rees wrote: When I'm logged in as a user, I can set the appropriate environmen variables, but when a daemon is running, where is it going to get them? Daemons are started from scripts found in /System/Library/StartupItems (for Apple-provided daemons), or /Library/StartupItems (for your own). Startup scripts usually include /etc/rc.common, so if you want to export an env variable for *all* daemons, that would be a good place to do it. Be aware that /etc/rc.common is a system file though; Apple-supplied OS updates might overwrite it, so keep a backup just in case. If you're writing a daemon, you might also want to be aware of /etc/hostconfig. This sets a series of flags that indicate what daemons should be started. At system startup, *all* of the items in the StartupItems folders are run, so they check for the corresponding flag to see if they should actually start their service. sherm--
Re: LC_ALL for daemons
On 2004.4.30, at 04:30 PM, Sherm Pendley wrote: On Apr 30, 2004, at 2:24 AM, Joel Rees wrote: When I'm logged in as a user, I can set the appropriate environmen variables, but when a daemon is running, where is it going to get them? Daemons are started from scripts found in /System/Library/StartupItems (for Apple-provided daemons), or /Library/StartupItems (for your own). Startup scripts usually include /etc/rc.common, so if you want to export an env variable for *all* daemons, that would be a good place to do it. Be aware that /etc/rc.common is a system file though; Apple-supplied OS updates might overwrite it, so keep a backup just in case. Thanks. I needed that information, because I had forgotten that Mac OS X doesn't use the rc/* convention. Don't look like there are any hooks for an rc.local. An rc script for the daemon would be handy for setting an environment variable. Hmm. There are plists in those startup items. I wonder if I can pervert those. Time to dig out my copy of in-a-nutshell and see if there are enought clues there. If you're writing a daemon, Well, I'm still vacillating between a cron job and a daemon. I'm writing my own update tool for dynamic dns for the experience. (My ISP wants $60 a month for one static IP.) It'll screen-scrape the router/modem's setup pages for some Japanese text. I'm sure I could modify somebody else's script, but I have this cowboy mentality, at least until I learn how to read Perl for meaning instead of just function. you might also want to be aware of /etc/hostconfig. Yeah, I needed to look in there, too. This sets a series of flags that indicate what daemons should be started. At system startup, *all* of the items in the StartupItems folders are run, so they check for the corresponding flag to see if they should actually start their service. Yep, that's where I can turn sendmail on, once I figure out some configuration details, and I want that so my script can report problems updating and not just log them. Well, that's for another day. Thanks, Sherm. I have to admit I get lost less with a little prompting. -- Joel Rees
Re: LC_ALL for daemons
On Apr 30, 2004, at 7:28 AM, Joel Rees wrote: Thanks. I needed that information, because I had forgotten that Mac OS X doesn't use the rc/* convention. Don't look like there are any hooks for an rc.local. An rc script for the daemon would be handy for setting an environment variable. Each StartupItem directory has a like-named script inside it. You can set and export the environment variable from that script. The scripts are called just like rc scripts, with start/stop/restart parameters. (Actually, I'm not certain if 'stop' scripts are called on Panther - they're definitely not called under Jaguar and earlier.) You can write the script in Perl if you'd like, although all of the standard scripts use /bin/sh. I usually just copy an existing script and alter it a bit. Hmm. There are plists in those startup items. I wonder if I can pervert those. Time to dig out my copy of in-a-nutshell and see if there are enought clues there. Those are used to help determine the order in which the services are started, using the Provides, Requires, and Uses arrays. For example, the Network item provides (no surprise here) the Network service. The MySQL item uses that service, and provides the (shock!) MySQL service. At system startup, items are sorted so that the ones that provide a given service are started before the ones that use or require it. Overall, I think it's a much more elegant system than the old numbered rc files scheme. That scheme always brings back unpleasant memories of having to renumber lines of BASIC. sherm--
[non-perl] osx startup login items, was Re: LC_ALL for daemons
On Fri, 30 Apr 2004, Sherm Pendley wrote: At system startup, items are sorted so that the ones that provide a given service are started before the ones that use or require it. Overall, I think it's a much more elegant system than the old numbered rc files scheme. That scheme always brings back unpleasant memories of having to renumber lines of BASIC. Yes, it is a nice system. Unfortunately, it seems like it's being deprecated. I don't quite understand yet where things are going, but some of the startup items in 10.3 have been rewritten in such a way that the service is, when possible, not launched but primed such that that they're ready to use on demand but they aren't taking up system resources when you don't need them. So, for example, the Postfix mail daemon won't be launched, but it will be set to respond to requests to send out mail on an as needed basis. You get faster boot times and a reduced average system load, while getting higher latency for some services at run time. For a fast modern machine, latency might not be a big deal, and the fast boot might be more noticeable to most people than anything else. Still, it'll be nice if you could tweak this stuff (it is, for example, still possible to write an older-style Postfix startup routine that launches fully). In any case, I don't think any of this stuff was present in Jaguar, and it only shows up occasionally in Panther. The implementation of these new startup scripts seems to look a bit more like old RC scripts, but they still seem to do the nifty dependency tree stuff that OSX has been using so far. The current startup procedure isn't hard at all to learn -- all you need is a /Library/foo directory, a /Library/foo shell script (or whatever language program), and a /Library/foo/StartupParameters.plist config file in either XML or NeXT plist format. Looking ahead though, it might be worth tinkering with the new 10.3 startup routines, too... *** But anyway, a question. If Linux users want to use ssh-agent, they can hook it in to their ~/.xinitrc file to cause it to launch at X login time and to export some environment variables to all processes started in the X session. Where is the best place to poke this on OSX? You can create a ~/.MacOSX/environment.plist file, but this will only set variables, not launch programs (as far as I know). No help there. Can you have a shell script launch as a login item? I've only been able to get graphical applications to launch this way. I've poked at SSH Agent.app, but it kept crashing... Suggestions welcome :-) -- Chris Devers
Re: [non-perl] osx startup login items, was Re: LC_ALL for daemons
On Apr 30, 2004, at 9:29 PM, Chris Devers wrote: I don't quite understand yet where things are going, but some of the startup items in 10.3 have been rewritten in such a way that the service is, when possible, not launched but primed such that that they're ready to use on demand but they aren't taking up system resources when you don't need them. I thought they were using xinetd for that - if so, that's pretty standard. If Linux users want to use ssh-agent, they can hook it in to their ~/.xinitrc file to cause it to launch at X login time and to export some environment variables to all processes started in the X session. Where is the best place to poke this on OSX? You can create a ~/.MacOSX/environment.plist file, but this will only set variables, not launch programs (as far as I know). No help there. Ah, but setting variables is what you want to do. The SSH_ASKPASS environment variable points to a program that SSH, when it's not connected to a terminal, will launch to ask for a login and password on its behalf. Have a look at Bill Bumgarner's SSHPassKey utility. It provides just such an app, and it can (if you want) also store SSH passwords on the keychain. It'll even poke the necessary variables into environment.plist for you. http://www.codefab.com/unsupported/SSHPassKey_v1.1-1-README.html sherm--