Discussion:
[rancid] launchd and rancid
Josh Rogers
2009-07-25 15:14:53 UTC
Permalink
I'm trying to get launchd to start rancid daily, but have had a lot of
trouble (assuredly because of my inexperience with launchd). Launchd
is launching the process, and log files are being written as www (the
correct user), but when I look at the log file, this is at the top of
it:

Trying to get all of the configs.
can't read "env(HOME)": no such variable


I believe this is because the environment isn't set up properly. If I
run rancid-run from the command line (bash) "sudo -u www rancid-run"
it runs fine.

I'd really appreciate some direction on how to fix this.

-Josh
alex
2009-07-25 18:45:51 UTC
Permalink
Post by Josh Rogers
Trying to get all of the configs.
can't read "env(HOME)": no such variable
I believe this is because the environment isn't set up properly. If I
run rancid-run from the command line (bash) "sudo -u www rancid-run"
it runs fine.
I've got no idea what launchd is, but put "sudo -u www rancid-run" in a bash
script and call that from launchd?

alexd
Daniel Medina
2009-07-25 19:24:37 UTC
Permalink
Post by Josh Rogers
I'm trying to get launchd to start rancid daily, but have had a lot of
trouble (assuredly because of my inexperience with launchd). Launchd
is launching the process, and log files are being written as www (the
correct user), but when I look at the log file, this is at the top of
Trying to get all of the configs.
can't read "env(HOME)": no such variable
I believe this is because the environment isn't set up properly. If I
run rancid-run from the command line (bash) "sudo -u www rancid-run"
it runs fine.
What does

$ launchctl export

say? HOME is one of the variables that's usually set for you, EX:

PATH="/usr/bin:/bin:/usr/sbin:/sbin"; export PATH;
TMPDIR="/var/folders/0p/0pdl6kW0HyGu7FSWcApHrU+++TI/-Tmp-/"; export TMPDIR;
SHELL="/bin/bash"; export SHELL;
HOME="/Users/medina"; export HOME;
USER="medina"; export USER;
LOGNAME="medina"; export LOGNAME;

Optionally, you could make a shell springboard, EX:

#!/bin/bash
# debug env(HOME) setting problem

HOME=/Users/homedir
export HOME
/usr/bin/printenv > /tmp/printenv.log
/Path/to/rancid-run

and then run that shell script from launchd.
--
Daniel Medina
Josh Rogers
2009-07-26 02:10:38 UTC
Permalink
So, when I run launchctl export as any user, I see the $HOME var set
correctly, but as root it ONLY includes $PATH.

This should be no big deal since I'm running the plist as www.

Here is the plist (I'm new to launchd, so this may be completely wrong).
its currently disabled because its not running correctly, but other than
that, can you see anything wrong with it that would cause my problem?



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "
http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<true/>
<key>Label</key>
<string>Rancid</string>
<key>Nice</key>
<integer>1</integer>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>/opt/local/libexec/rancid/rancid-run</string>
<string>-m</string>
<string>***@domain.com</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>6</integer>
<key>Minute</key>
<integer>26</integer>
</dict>
<key>StartInterval</key>
<integer>43200</integer>
<key>UserName</key>
<string>www</string>
</dict>
</plist>
Post by Daniel Medina
Post by Josh Rogers
I'm trying to get launchd to start rancid daily, but have had a lot of
trouble (assuredly because of my inexperience with launchd). Launchd
is launching the process, and log files are being written as www (the
correct user), but when I look at the log file, this is at the top of
Trying to get all of the configs.
can't read "env(HOME)": no such variable
I believe this is because the environment isn't set up properly. If I
run rancid-run from the command line (bash) "sudo -u www rancid-run"
it runs fine.
What does
$ launchctl export
PATH="/usr/bin:/bin:/usr/sbin:/sbin"; export PATH;
TMPDIR="/var/folders/0p/0pdl6kW0HyGu7FSWcApHrU+++TI/-Tmp-/"; export TMPDIR;
SHELL="/bin/bash"; export SHELL;
HOME="/Users/medina"; export HOME;
USER="medina"; export USER;
LOGNAME="medina"; export LOGNAME;
#!/bin/bash
# debug env(HOME) setting problem
HOME=/Users/homedir
export HOME
/usr/bin/printenv > /tmp/printenv.log
/Path/to/rancid-run
and then run that shell script from launchd.
--
Daniel Medina
Josh Rogers
2009-07-26 21:31:17 UTC
Permalink
Using your springboard script did the trick. Thanks so much for the help,
I've been struggling w/this for a bit now.

-Josh

Ogden Nash <http://www.brainyquote.com/quotes/authors/o/ogden_nash.html> -
"The trouble with a kitten is that when it grows up, it's always a cat."
Post by Josh Rogers
So, when I run launchctl export as any user, I see the $HOME var set
correctly, but as root it ONLY includes $PATH.
This should be no big deal since I'm running the plist as www.
Here is the plist (I'm new to launchd, so this may be completely wrong).
its currently disabled because its not running correctly, but other than
that, can you see anything wrong with it that would cause my problem?
I would strongly suggest wrapping up what you have in a shell springboard,
$ cat rancid-springboard.sh
#!/bin/bash
HOME=/Path/to/homedir
export HOME
# Test what we have in our env
printenv > /tmp/rancid-springboard.log
and then replace ProgramArguments in your plist. This way you have a bit
more control over the env outside of whatever launchd is doing.
Let me know how it goes...
Post by Josh Rogers
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "
http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<true/>
<key>Label</key>
<string>Rancid</string>
<key>Nice</key>
<integer>1</integer>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/bin/sh</string>
<string>-c</string>
<string>/opt/local/libexec/rancid/rancid-run</string>
<string>-m</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>6</integer>
<key>Minute</key>
<integer>26</integer>
</dict>
<key>StartInterval</key>
<integer>43200</integer>
<key>UserName</key>
<string>www</string>
</dict>
</plist>
--
Daniel Medina
Josh Rogers
2009-07-25 14:01:17 UTC
Permalink
I'm trying to get launchd to start rancid daily, but have had a lot of
trouble (assuredly because of my inexperience with launchd).  Launchd
is launching the process, and log files are being written as www (the
correct user), but when I look at the log file, this is at the top of
it:

Trying to get all of the configs.
can't read "env(HOME)": no such variable


I believe this is because the environment isn't set up properly. If I
run rancid-run from the command line (bash) "sudo -u www rancid-run"
it runs fine.

I'd really appreciate some direction on how to fix this.

-Josh

Loading...