5

I am trying to migrate an init.d script from centos 6.6 server to ubuntu 14.04. Centos machine start, status, stop commands are,

daemon --pidfile=/path/to/pidfile /path/to/daemon/script
status -p /path/to/pidfile /path/to/daemon/script
killproc -p /path/to/pidfile /path/to/daemon/script

start command works good in its original form on ubuntu 14.04 but the other two functions, status, killproc are not defined on ubuntu distros.

What is the equivalent of these commands in ubuntu machines?

Mikel
  • 57,299
  • 15
  • 134
  • 153

2 Answers2

5

On my Ubuntu system, killproc is provided by /lib/lsb/init-functions.

http://refspecs.linuxbase.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptfunc.html

Have you tried putting

. /lib/lsb/init-functions

near the top of your init script?

$ dpkg -S /lib/lsb/init-functions
lsb-base: /lib/lsb/init-functions

$ dpkg -S /sbin/status
upstart: /sbin/status

$ apt-cache show lsb-base
Package: lsb-base
Priority: required
Mikel
  • 57,299
  • 15
  • 134
  • 153
  • hi Mikkel, this solves the killproc issue. But status on debian is a binary and the Centos cmd - status -p /path/to/pidfile /path/to/daemon/script doesn't work with debian's /sbin/status/. man status took me to initctl but it is not very clear, how i can pass the pidfile argument and get the job status. thanks man. –  Jun 06 '15 at 16:57
  • Off the top of my head, I don't know how to do that portably. But normally on Debian and Ubuntu you can use start-stop-daemon – Mikel Jun 06 '15 at 17:55
  • It sounds like start_daemon is equivalent to daemon and pidofproc is equivalent to status, but I don't have a system to test on. – Mikel Jun 06 '15 at 19:14
2

. /lib/lsb/init-functions

This addition of line worked for me. Thanks:)

stop)
    echo -n "Shutting down noip2."
    . /lib/lsb/init-functions
    killproc -TERM /usr/local/bin/noip2