18

I was looking through /etc/init.d/ssh to get an idea of how a "proper" sys daemon is run at boot (I'm trying to add svnserve to that list). I saw this log_daemon_msg used as a command, but I have no idea what it is.

which log_daemon_msg and man log_daemon_msg came up empty.

Example:

log_daemon_msg "Starting OpenBSD Secure Shell server" "sshd" || true
if start-stop-daemon --start --quiet --oknodo --pidfile /var/run/sshd.pid --exec /usr/sbin/sshd -- $SSHD_OPTS; then
    log_end_msg 0 || true
else
    log_end_msg 1 || true
fi

How does that work? I tried Googling around, but the only things I could find were questions about where it records its messages, which is useless since I hardly know how to use it or what it even is - a command, a builtin, or something else?

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
Dubslow
  • 292
  • 1
  • 2
  • 9
  • 1
    Show the complete file: it is likely that this is function defined in a file sourced at the beginning of `/etc/init.d/ssh` – Matteo Jan 24 '13 at 07:33

2 Answers2

21

That is LSB related functions. Please have a look to /lib/lsb/init-functions and/or /etc/redhat-lsb/lsb_log_message. The path depends on your distro.

dchirikov
  • 3,818
  • 2
  • 15
  • 18
  • 2
    Thank you! My googling had revealed that it was somehow related to LSB, and I looked at the Wiki page in fact, but it wasn't particularly useful. Thanks for the path! (It was the former, this is Ubuntu server.) – Dubslow Jan 24 '13 at 07:40
  • Wow, I just missed this little `. /lib/lsb/init-functions` at the top of the init script I was analyzing... Seems like it's better to write `source <...>` instead of `. <...>` when you want the script to be easily analyzed. – Tomasz Gandor Aug 25 '17 at 12:07
-2

I don't have BSD and never used it... but for sure log_daemon_message must be a shell function. Look above that to statements like:

. ./functions

That sources all the functions in the function file. The other thing you can do is to look for the specific function with find:

find /etc -type f -exec grep -li log_daemon_msg {} \;

And see what is in the files. As I said I don't have BSD, but research is fun!

Cheers and good luck

  • It's not BSD, it's Ubuntu 12.04 server; it's just that ssh is a BSD program. @Matteo, I grep'd the file, it's not a locally defined function. I didn't think to check what other files it loads, I'll go do that now. The reason I asked here though is that [one result](http://ubuntu.5.n6.nabble.com/where-does-log-daemon-msg-and-related-functions-post-there-output-td1662828.html) suggested that it's a family of common/widespread functions. – Dubslow Jan 24 '13 at 07:36