Milhouse
Guru
- Joined
- Jun 1, 2011
- Messages
- 564
Do you not need a clause before to check whether it is running in the background like so?
Need? No. Good to have? Depends.
With sasidle, there is no harm running it as background daemon at boot, and then a second version interactively so there was no reason to prevent this situation from arising. Not sure if the same is true of ethidle, but if running a second interactive version causes a problem then sure, add additional checks to prevent it (assuming it's likely to happen at all, once you've stopped testing).
Also how do you start stop the daemon after it has booted?
If you look at the original sasidle post, there are two scripts - the service control script (item #2, that is run from /etc/local/rc.d/sasidled once the system is booted - write it to /conf/base/etc/local/rc.d/sasidled for non-volatile storage) and the daemon itself (item #3, which you already have as ethidle.sh - this can be anywhere you like, just reference it from the service control script). Add the additional config entries to rc.conf, then use your service control script to stop/start/restart the daemon (if enabled, it will auto-start during boot). Eg to stop the daemon, execute "/etc/local/rc.d/ethidled stop".
You'll need to change the dependencies in the service script so that it starts once the network is up, and once snmpd is started - the first four comment lines are not comments, but instructions to FreeNAS to ensure boot scripts are started in the right sequence). You probably require the following as ethidled has different dependencies to sasidled:
Code:
# PROVIDE: ethidled # REQUIRE: NETWORKING DAEMON snmpd # BEFORE: LOGIN # KEYWORD: shutdown