Look at this topic, it may be interesting: how to write a bash script like the ones used in init.d?
On Linux CentOS 6.5 I use the file /etc/init.d/functions:
#!/bin/bash . /etc/init.d/functions
Assuming command returns 0 on success, a positive value if an error occurs. To make the script easy to read, I use a function call instead of the whole command.
Here is an example:
#!/bin/bash . /etc/init.d/functions this_will_fail() { # Do some operations... return 1 } this_will_succeed() { # Do other operations... return 0 } action "This will fail" this_will_fail action "This will succeed" this_will_succeed exit 0
leads to:
(note: French ;-))
Hope this helps!
Aloïké go
source share