20

I created a startup script to start/restart/stop a group of applications. I used the lib /etc/init.d/functions in my script. It is working well on my system, but it not working for my client; he is getting the error:

No such file or directory /etc/init.d/functions

Right now I don't know which linux distro my client uses. Is the init.d/functions file different for different Linux distros? If so, how can I find it?

  • Note that this error can also be caused by Windows line endings. – Emerson Rocha Aug 4 '13 at 18:47
24

It's specific to whatever distribution you're running. Debian and Ubuntu have /lib/lsb/init-functions; SuSE has /etc/rc.status; none of them are compatible with the others. In fact, some distributions don't use /etc/init.d at all, or use it in an incompatible way (Slackware and Arch occur to me off the top of my head; there are others).

  • can i know which is the file and where is it located for Redhat 5.5? – tecman Mar 15 '11 at 20:52
  • Also, how can i find those file name and path? is there any way to do that or is it that we can only find it from the documentation? – tecman Mar 15 '11 at 20:54
  • I did it by looking, as I have both of those available; I don't have a Red Hat install. But you may have missed the importance of what I said in bold above: the functions in your /etc/init.d/functions don't exist on other distributions. Every distribution has its own rules for /etc/init.d, and its function library (if any) is oriented around those rules; for example, SuSE's rc_status -s. There are some LSB "standard" functions, which are supposed to be found in /lib/lsb/init-functions, but your client may not be running a distribution which has been updated to provide it. – geekosaur Mar 15 '11 at 21:04
13

In CentOS 7 Docker image I had to simply install the package initscripts in order for this script to be installed:

yum install -y initscripts

(Thanks to this issue on docker-library which made me look at this commit)

  • This fixed my issue using Jenkins on Fedora 24 in a Docker container. (just used dnf instead of yum of course). Thanks! – geerlingguy Apr 12 '17 at 19:04
  • This also works when installing MarkLogic 9 into a Centos7 docker container. The installation docs only mention needing lib.so.6 and lsb-core-amd64, but I'm guessing since they're talking about installing on a full CentOS 7 install, they would overlook that you'd need the initscripts package. – alc6379 May 8 '17 at 22:50
12

That is absolutely distribution dependent. You're really going to need to find out the distro in order to write a properly-matching init script.

You can also follow the LSB (Linux Standard Base) specification and hope that the distro in question did too. The current specification dictates that the standard init script functions be available as /lib/lsb/init-functions (see docs here). On Fedora and other Red Hat related distros, that's provided by the redhat-lsb package, which is optional.

So, you really have to figure out what you're targeting. Sorry.

0

I missed those functions when I moved to Ubuntu, so I created a library that recreates their functionality: efunctions.

0

Adding a recent answer

As noted in another answers, Linux Standard Base (LSB) specs provide a way to write platform independent init.d based startup scripts, using the LSB defined init functions as listed here

All LSB compliant distributions (all the big ones) provide the file /lib/lsb/init-functions (which defines the listed functions) in the meta-package lsb-core-noarch which can be installed using the distribution's package manager $PKGMAN $INSTOPT lsb-core-noarch (yum,dnf,apt,...).

An example of such an init script is this.

However, given how systemd is now the de-facto system and service manager for most distributions, it's better to write a systemd service unit instead of writing out an initscript.

0

I too got the same error while I run my docker container. It was fixed by adding below line in my Dockerfile

RUN yum install -y initscripts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.