Package name vs service name in rc.conf

Hi all,

Can someone help me understand the reason why package names configured in rc.conf use an underscore while the service name uses a dash/hyphen?

Examples:
Code:
sysrc avahi_daemon_enable=YES
sysrc emby_server_enable=YES
but
Code:
service avahi-daemon start
service emby-server start

I see the rc.conf syntax seems to leverage the underscore but I am not entirely sure why it could not have been consistently underscore everywhere or dash/hyphen everywhere instead between service name and package name.
 
You basically said it yourself: it helps to separate the service name from the script name.

However, in the end it's all at the discretion of the port maintainer. Samba for example uses /usr/local/etc/rc.d/samba_server and the service is also called samba_server. Spamassasin on the other hand uses the spamd servicename whereas the script is called sa-spamd.

Generally speaking though it's more common to use the same name for both the service and the script (if you include the scripts from the base system). But in the end it's always safer to check an rc.d script to see what it's service name is going to be. I've even seen script names which had dashes in between while the service name simply removed all of those.
 
Actually, shelluser is wrong and, rc.conf is a shell script sourced by rc and to use "-" as opposed to "_" would require escaping those "-" characters to allow interpretation of the "-" meaning.. The underscore "_' is just another character and has no special meaning. A rc.d startup script can have any file name with a dash or underscore or not - it's the contents that matters.
 
Back
Top