This may have more to do with detecting operating systems, but I specifically need the init system currently in use on the system.
Fedora 15 now uses systemd, Ubuntu uses Upstart, while others use variations of System V.
I have an application that I am writing to be a cross-platform daemon. The init scripts are being dynamically generated based on parameters that can be passed in on configure.
What I'd like to do is only generate the script for the particular init system that they are using. This way the install script can be run reasonably without parameters as root and the daemon can be "installed" automagically.
This is what I've come up with:
- Search for systemd, upstart, etc in /bin
- Compare /proc/1/comm to the systemd, upstart, etc
- Ask the user
What would be the best cross/platform way of doing this?
Kind of related, Can I depend on bash to be on the majority of *nix or is it distribution/OS dependent?
- Mac OS
- Linux (all distributions)
- BSD (all versions)
- Solaris, Minix, and other *nix