I noticed this while writing a runscript that incorporates the following stop_pre function:- stop_pre() { if [ "$RC_CMD" = restart ] && service_started; then checkconfig fi } The problem is that the exit status value of service_started is always 1, even in the case that service is, in fact, started. This does not make sense. A stop_pre function is executed before the service is actually stopped. Therefore, I would expect service_started to to yield 0 in the case that the service is up and running. This is as tested with both start-stop-daemon and supervise-daemon, using openrc-0.42.1-r1.
You are correct about service_started returning 1 in the stop_pre context. Also, stop_pre will not run if the service failed to start or is stopped, so unless I'm missing something, you don't really need to use service_started in the stop_pre context. If you drop service_started from the example you show above you should be fine. I will keep this open, but the above should work for you. Thanks, William