On 2023-08-27, Dillon Wreek <[email protected]> wrote:
> Hello, I will start from the beginning in hope that someone can make some
> sense of this.
> I have a very simple ruby script that lives in sbin. It sends a get request
> every x minutes to ifconfig to check if the pub ip of the machine changed
> and sends another get request to no-ip to notify any changes.
> the script lives in /usr/local/sbin/ and the script that I wrote under
> rc.d/ looks like this:
>
> /etc/rc.d/dynaruby
> ```
> #!/bin/ksh daemon="/usr/local/sbin/dynaruby" name="dynaruby" .
"name" is not something which is used by rc.d
> /etc/rc.d/rc.subr rc_start() { echo "Starting $name with key:
> $DYNARUBY_KEY" >> /var/log/dynaruby.log /usr/local/sbin/dynaruby } rc_cmd
> $1 ```
Here you are overriding rc_start with a command which does not set the
login class.
You should probably just remove the rc_start section and use the defaults.
Make sure that pexp is set correctly to match the command name (as seen
in ps) for the daemon process.
> Following the man page of rc.d and login.conf, I created an entry like this
> under /etc/login.conf.d/dynaruby:
> dynaruby:setenv=DYNARUBY_KEY=BupCxeBEflVyNK05ypuz25bXuoRc9Rg61qKnOBohyH0=,Xwsirr99KDqkz3Ncytn2AA==:tc=default:
Like I said when you asked on reddit - this is incorrect syntax, you
need to escape the , which is part of DYNARUBY_KEY.
I don't think the escaping is actually documented (at least I didn't find
it), but in setenv you need to use \, if you want a literal comma (otherwise
it is a separator between variable names).
> Then, I set dynaruby_flags and pkg_scripts in /etc/rc.conf.local like this:
> dynaruby_flags="" dynaruby_enable=yes pkg_scripts=dynaruby
> This is everything right? Shouldn't it just work? However when I do "rcctl
> start dynaruby" I just get "dynaruby(failed)" (failed because the ruby
> script can't find the env variable and it exits with 1).
> In /var/log/dynaruby.log, "$DYNARUBY_KEY" is empty, the variable is not
> being passed.
> I tried having the same entry just in login.conf but with the same results.
> I also did the db, did "cap_mkdb", then wiped the whole laptop with a fresh
> install and did the configuration you see above. Still the same results.
you only need cap_mkdb if you've already run cap_mkdb. I would recommend
removing login.conf.db and forget about cap_mkdb.
> I will pay someone to take 15 minutes of their time to walk through this
> with me in a call while watching the terminal together. I'm really
> desperate and I've been hung up on this for over a month.
> I'm seriously considering just ditching rc.d and have a "launcher" ksh
> script that just exports the env variable to the ruby script, then having
> it called by cron on startup and reboot.
nobody's forcing you to use rc.d.
you could start it via cron, alternatively you can just run it from rc.local.
but it certainly should be possible to do this via rc.d.
--
Please keep replies on the mailing list.