@SirDice already covered most of it, but a few extra details which could be interesting to know.
Niatross said:
So how does a port service (ex:
www/apache22) become enabled if its disabled by default?
Do you use the "
/etc/rc.conf" configuration file to enable a port service?
Apart from adding it to
/etc/rc.conf it's also good to know that running the rc script with the
rcvar command will show you what you need to add in order to start the service:
Code:
$ ./mysql-server rcvar
eval: cannot open /var/db/mysql/smtp2.losoco.com.pid: Permission denied
# mysql
#
mysql_enable="YES"
# (default: "")
$ ./dovecot rcvar
# dovecot
#
dovecot_enable="YES"
# (default: "")
So now I know that in order to activate the MySQL or Dovecot server I'd need to use
mysql_enable and/or
dovecot_enable. Although it's usually best to view the rc script itself, because it is possible that there are some extra (usually optional) variables which can also be set.
Niatross said:
Base system
rc(8) scripts are enabled by default and disabled via "
/etc/defaults/rc.conf" and port
rc(8) scripts are disabled by default and need to be enabled in "
/etc/rc.conf"
Yes and no.
Basically the behaviour isn't that much different. The main difference is that an rc script provided by a port needs to specify a default behaviour by itself. This is a strict requirement. If I use the same scripts which I showed above you'll soon come across this:
Code:
([FILE]dovecot[/FILE])
. /etc/rc.subr
name=dovecot
rcvar=dovecot_enable
# read configuration and set defaults
load_rc_config ${name}
[b]: ${dovecot_enable:="NO"}[/b]
[B]: ${dovecot_config:="/usr/local/etc/${name}.conf"}[/B]
([file]mysql-server[/file])
. /etc/rc.subr
name="mysql"
rcvar=mysql_enable
load_rc_config $name
[B]: ${mysql_enable="NO"}[/B]
[B]: ${mysql_limits="NO"}[/B]
: ${mysql_dbdir="/var/db/mysql"}
The lines in bold are the ones which set the scripts default behaviour.
So in the end both script types behave completely the same. The main difference is that rc scripts and their options in the base system all have their default values defined in
/etc/defaults/rc.conf whereas in the ports it's up to the port maintainer to do this.
And if you don't meet this requirement then this can happen:
Code:
root@smtp2:/usr/local/etc/rc.d # ./samba status
./samba: WARNING: $samba_enable is not set properly - see rc.conf(5).
Cannot 'status' samba. Set samba_enable to YES in /etc/rc.conf or use 'onestatus' instead of 'status'.
This may look like a weird error message, but the fact of the matter is that Samba hasn't been enabled at all on my server (I'm only after
smbclient). The problem is that the default value isn't set properly which results in this error message.
Hope this can give you some ideas too. I also want to stress out that a lot of this information can be found in both the manual pages as well as the excellent
FreeBSD handbook.