--- Ports rc.subr Dos and Don'ts --- * Use the template file and edit it to suit your needs. Then put it in your ports ${FILESDIR}, named `.sh'. Add RC_SCRIPTS= to your ports Makefile, and your are set. You should not install the file are add it to pkg-plist, this is done automatically for you. After installing you port, add _enable="YES" to /etc/rc.conf and execute the script with start, status and stop as arguments to see whether it works correctly. * Don't write auxilliary stuff in the rc.sub script. The script is for (automatically) starting/stopping daemons, not configuring the local machine (like creating users or modifying configuration files). Use a seperate script for that. * Don't use anything besides ${parameter-"default"} to set default values. Especially don't do [ -z "$%%NAME%%_enable" ] && %%NAME%%_enable="NO" %%NAME%%_enable=${%%NAME%%_enable:-"NO"} %%NAME%%_enable=${%%NAME%%_enable:="NO"} Set the default for parameters using : ${%%NAME%%_enabler="NO"} only. This is important because otherwise users are unable to set a variable to be empty by default. Even when a user accidentially sets _enable="" the error should be detected and not silently substitued by possibly unwanted defaults. Besides, having a uniform setting of defaults makes scripts easy to read. * Don't write anything after run_rc_command (effectively masking it's return value) * Don't add pipelines, redirections, or background commands to %%NAME%%_flags. * Don't try to autodetect PREFIX or assume in any way that $0 has a reasonable value * Do use debug and warn to output messages * Don't touch variables designed to be set in rc.conf except setting their default values once. Especially don't mess with `%%NAME%%_flags' by doing %%NAME%%_flags="${%%NAME%%_flags} whatever". Use command_args or modify rc_flags in start_precmd if you have to. * Don't try to start your daemon early. You should at least `REQUIRE: LOGIN'. The functionality to support this will be developed before 5.3 is release, but it might cause problems when your port have never been tested, but suddenly starts early in the boot process. It is better to wait until the base system is ready and modify your port *then*, when you need it.