Custom rc.d script won't start on boot?

in FreeBSD


You have a very small rc.d script that you intend to both run as service xyz action and have autostart on boot. It works when you call it manually, but won't start on boot.

The script pseudocode looks like this:

#!/bin/sh
# PROVIDE: xyz
# REQUIRE: NETWORKING
# KEYWORD: shutdown

case "$1" in
    start)
        echo "Starting xyz"
        ;;
    stop)
        echo "Stopping xyz"
        ;;
esac

Short answer: make sure you define faststart next to start:

    start|faststart)
        echo "Starting xyz"
        ;;

Where to debug: /etc/rc in rcorder loops

My script is structured like that because I want to reuse the same code across both FreeBSD and Debian (long story). For FreeBSD, it is recommended to only define the functions you need and have rc revert to default implementation for everything else. See this FreeBSD forum post for more info https://forums.freebsd.org/threads/start-virtual-machine-at-reboot.88036/#post-598484 (as well as the documentation linked to in that thread).

#freebsd