Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly use log_daemon_msg, log_end_msg, log_progress_msg to write a proper daemon script?

Tags:

daemon

I was suprised not to be able to find any documentation regarding the proper user of these functions:

log_daemon_msg
log_progress_msg
log_end_msg
log_action_msg
log_success_msg
log_failure_msg
log_warning_msg

Where can I find more information about their usage and maybe other related functions?

Note, I found them inside /lib/lsb/init-functions but the is documentation regarding their usage is mostly missing.

like image 944
sorin Avatar asked May 31 '13 10:05

sorin


2 Answers

I think this is what you are looking for:

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

I've been reading a lot of init scripts on debian wheezy but there doesn't seems to be a unified way of creating init scripts. Some people use echo instead of log_warning_msg or log_failure_msg.

Note: /lib/lsb/init-functions doesn't seem to work well under bash. So remember to use the appropriate shebang:

#!/bin/sh 
like image 174
alfredocambera Avatar answered Oct 23 '22 04:10

alfredocambera


just try to test that with any script:

vim 123.sh

#!/bin/sh
. /lib/lsb/init-functions

[ 1 != 2 ] && log_end_msg 1

So I`ve included funcs from /lib/lsb/init-functions.

And execute:

bash 123.sh 
   ...fail!

And so on:

cat 123.sh 
#!/bin/sh
. /lib/lsb/init-functions

[ 1 != 2 ] && log_end_msg 0

And run:

bash 123.sh 
   ...done.
like image 23
ipeacocks Avatar answered Oct 23 '22 04:10

ipeacocks