The following script just emits a message each time the system boots up:
#!/bin/sh. /etc/rc.subr
name="dummy"
start_cmd="${name}_start"
stop_cmd=":"
dummy_start()
{ echo "Nothing started." } load_rc_config $name
run_rc_command "$1"
Things to note are:
An interpreted script should begin with the magic “shebang” line. That line specifies the interpreter program for the script. Due to the shebang line, the script can be invoked exactly like a binary program provided that it has the execute bit set. (See chmod(1).) For example, a system admin can run our script manually, from the command line:
Note:In order to be properly managed by the
Tip:If you would like to learn the details of why
| |
In An Note:Some useful functions related to networking
are provided by another include file,
| |
The mandatory variable
Now it is the right time to choose a unique name for our script once and for all. We will use it in a number of places while developing the script. For a start, let us give the same name to the script file, too. Note:The current style of | |
The main idea behind rc.subr(8) is that an
Note:To make the code in | |
We should keep in mind that rc.subr(8) provides default methods for the standard arguments. Consequently, we must override a standard method with a no-op sh(1) expression if we want it to do nothing. | |
The body of a sophisticated method can be implemented as a function. It is a good idea to make the function name meaningful. Important:It is strongly recommended to add the prefix
| |
This call to rc.subr(8) loads rc.conf(5) variables. Our script makes no use of them yet, but it still is recommended to load rc.conf(5) because there can be rc.conf(5) variables controlling rc.subr(8) itself. | |
Usually this is the last command in an
|
All FreeBSD documents are available for download at https://download.freebsd.org/ftp/doc/
Questions that are not answered by the
documentation may be
sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.