-1

I'm developing an app which will be run on linux. It can run on most distributions.

Is there any way to create a startup/service script that will work on any distribution? I've read about /etc/init.d but is that only for Debian based distros? I would like an alternative that work on most (all?) distros.

Thanks in advance for any input!

  • 1
    `I've read about /etc/init.d but is that only for Debian based distros?` You have a lot of learning to do! – Sven May 11 '16 at 13:48
  • Yes, it is! It should make it clear to you that you first need to learn how startup scripts works on all (the most common?) distributions and what the differences are. Yes, that's a lot of work, but no one here can or want to do this work for you. – Sven May 11 '16 at 13:58
  • I'm not expecting anyone to provide finished scripts for me, I was expecting someone to help me further on what to read about. – gregoff May 11 '16 at 14:00
  • Start by reading the documentations of the common versions of RHEL, Fedora, Debian and Ubuntu. And oh joy, there are even major differences between versions due to the introduction of SystemD (though a compability layer to SysV init exists). – Sven May 11 '16 at 14:02
  • 1
    Init scripts are following the dodo bird into extinction. Don't waste too much time on them. Write a systemd unit, which will usually be identical across distributions. – Michael Hampton May 11 '16 at 14:21
  • @MichaelHampton: so in your opinion I should dig into systemd service scripts which will be compatible with most current linux distribution versions? – gregoff May 12 '16 at 07:39

1 Answers1

2

To best deal with the different distributions and their quirks:

  • either don't create an init script and leave it as an problem/exercise to your users/customers
  • or take proper distribution into account and create distribution dependant RPM/deb packages that your users can easily install using their package manager.

The latter means you'll have to deal with distro dependant conventions & packaging tools and will end up writing multiple init scripts and you will also need to create a systemd unit.

HBruijn
  • 72,524
  • 21
  • 127
  • 192
  • Hi, thanks for your input! Giving it as a technical exercise for my customers wont be an alternative unfortunately. Do you have any suggestions on further reading on the latter? I can hardly be the first one developing an application that is supposed to be run on boot across several linux distros? – gregoff May 12 '16 at 06:42
  • The leave it to your users was a bit tongue in cheek, systemd is used by Red Hat Enterprise Linux since major release 7 (and derivatives such as CentOS 7), all the current Fedora distro's and Ubuntu 16 and presumably Debian and documented [here](https://www.freedesktop.org/wiki/Software/systemd/) most distributions have a packaging manual as well – HBruijn May 12 '16 at 08:30