For some services (ex: bluetooth) I have entries in both /etc/init.d/ and in /etc/init/ directory.
How do I know how this service is started ? By sysvinit or upstart ?
I am using Ubuntu 14.04.
For some services (ex: bluetooth) I have entries in both /etc/init.d/ and in /etc/init/ directory.
How do I know how this service is started ? By sysvinit or upstart ?
I am using Ubuntu 14.04.
You may have two sets of scripts, but you only have one active init system. On Ubuntu 14.04, that's Upstart.
So no matter whether your script is under /etc/init.d or /etc/init, the answer for which init system runs your script under Ubuntu 14.04 is always Upstart.
You can watch what happens when you try run an /etc/init.d script by using strace to log the system calls to STDOUT:
sudo strace /etc/init.d/bluetooth start
First you'll see that the init script first loads some header functions through /lib/lsb/init-functions
open("/lib/lsb/init-functions", O_RDONLY) = 3
Pretty soon you'll see the activity diverted to an Upstart related script:
open("/lib/lsb/init-functions.d/01-upstart-lsb", O_RDONLY) = 3
That's just a shell script, so you can open it and read the source to see what it does.
As you continue to full the output, I think you'll see that command is redirected to start the script using the Upstart script instead of the SysV init script.
What's interesting to see is that on 16.04, Upstart further redirects the control to systemd, and the related systemd service is started instead:
write(1, "Starting bluetooth (via systemct"..., 53Starting bluetooth (via systemctl): bluetooth.service) = 53
The bottom-line advice to use Upstart scripts and service management commands on Ubuntu 14.04 to avoid the complexity and potential confusion of the SysV init compatibility layer. Likewise, once you upgrade to 16.04, start using the native systemd unity files and systemctl command to avoid involve unnecessary compatibility layers.