This seems to work just fine: start_precmd="modules_precmd"
modules_precmd() { drvctl -d pchb0 return 0 } The "return 0" allows the drvctl to fail (if, perhaps, the pchb0 has already been deleted). Otherwise, an error exit prevents the main command from being executed. Thanks, everyone, for all the help. I'm happy with the results, and I've avoided a potentially controversial commit! :_) On Thu, 10 Apr 2025, Robert Elz wrote:
Date: Thu, 10 Apr 2025 14:25:45 +0200 From: Christoph Badura <b...@bsd.de> Message-ID: <20250410122545.ga26...@irregular-apocalypse.k.bsd.de> | echo '$start_precmd="$start_precmd; drvctl -d pchb0' >> /etc/rc.conf.d/modules That would want to be: echo 'start_precmd=${start_precmd:+"${start_precmd}; "}"drvctl -d pchb0"' \ >> /etc/rc.conf.d/modules or the new command could be prepended, that's a bit easier, as cmd; is legal sh code, but ;cmd is not (hence all the crud above), so: echo 'start_precmd="drvctl -d pchb0; ${start_precmd:-}"' >> /etc/rc.conf.d/modules should work, and both be the same when there is no existing start_precmd. Or the way Iain Hibbert suggested, though I doubt there's much point wrapping one single command in a function (if one wanted more than that one command, perhaps testing something, maybe the "pchb0" string could come from a variable set in rc.conf, and the command only be run if that var is set modules_prestart() { if test -n "${bus_to_delete:-}" then drvctl -d "${bus_to_delete}" fi } perhaps (but do think of a better name for the variable, and do set it in rc.conf when required). kre !DSPAM:67f7e8fe33949387519076!
+---------------------+--------------------------+----------------------+ | Paul Goyette (.sig) | PGP Key fingerprint: | E-mail addresses: | | (Retired) | 1B11 1849 721C 56C8 F63A | p...@whooppee.com | | Software Developer | 6E2E 05FD 15CE 9F2D 5102 | pgoye...@netbsd.org | | & Network Engineer | | pgoyett...@gmail.com | +---------------------+--------------------------+----------------------+