'action' is defined inside a library called functions. You have to source your script first with this library in order to use it. This library is a distro distribution dependent and none of these distro libraries are compatible with the others. In Ubuntu is /lib/lsb/init-functions, SuSE has /etc/rc.status and in Centos is /etc/rc.d/init.d/functions. Some distributions don't use it at all.
Example of 'action':
Example of 'action':
# Source function library. . /etc/rc.d/init.d/functions # Now you can use action: action $"Perform an action:" /bin/trueIn Centos 7, 'action' definition inside /etc/rc.d/init.d/functions is as the following:
# Run some action. Log its output. action() { local STRING rc STRING=$1 echo -n "$STRING " shift "$@" && success $"$STRING" || failure $"$STRING" rc=$? echo return $rc }