/etc/rc.start_packages double-starts some packages
During boot process, /etc/rc.start_packages double starts some packages, slowing down boot significantly in some cases. An example in point is named/bind. Appears to be as the package internal name is different from the rc script name (bind vs named).
Explaining, using bind/named as an example:
- Package name is "bind"
- bind.xml configuration file has rcfile set as "named.sh"
- /etc/rc.start_packages then collects two lists: xml defined packages and all *.sh scripts
- runs each package rc file (which does include named.sh)
- subtracts the package name + ".sh" from the glob list (in this case tries to remove "bind.sh")
- runs the remaining files in the glob list. (which runs "named.sh" again)
The start_packages script does not use the name of the service startup script to determine what to remove from the "have run list", it creates a new file name using the package title, in this case, "bind" and tries to remove it from the array. "bind.sh" is not in the list, named.sh is. the "named.sh" is left in the ".sh" list and then run again - run twice during boot.
Specific line: /etc/rc.start_packages that tries to remove "bind.sh" instead of "named.sh" from the list of residual "*.sh" files in /usr/local/etc/rc.d/
unset($rcfiles[RCFILEPREFIX . strtolower($internal_name) . ".sh"]); #
Not 100% clear whether this is a bind package issue (name vs startup script vs xml config) or a pfsense startup script issue.
I propose this is a pfsense core issue with /etc/rc.start_packages as this script is not attempting to eliminate the actual scripts run from the remaining scripts list, it is making an assumption that the script name is the same as the package name - a wrong assumption. It should be using the "rcfile" xml element value from the package to determine which start scripts to eliminate from the "*.sh" glob list as already run.