Q:

Ubuntu equivalent of CentOS success / failure

A lot of services in CentOS look like this (except green and red, respectively):
$ sudo service blah start
Starting blah:           [  OK  ]
$ sudo service notrunning stop
Stopping notrunning:     [FAILED]

This happens because the /etc/init.d scripts use utility scripts in /etc/rc.d/init.d/functions called success and failure. Here's a snippet from /etc/init.d/sshd in CentOS:
echo -n $"Starting $prog: "
$SSHD $OPTIONS && success || failure

My question is: is there a ubuntu equivalent? I could copy the scripts over, but they're more complicated than you'd think, and why reinvent the wheel if I don't have to? 

A:

I think the functions you are looking for are sourced from /lib/lsb/init-functions, and named log_success_msg and log_failure_msg:
$ . /lib/lsb/init-functions
$ log_success_msg foo
 * foo
$ log_failure_msg foo 
 * foo

In this output, the first * is grey, the second is red (error case). Not extremely colorful, just enoug to get the point across...

From /lib/lsb/init-functions:
[ ... ]

log_success_msg () {
    if [ -n "${1:-}" ]; then
        log_begin_msg $@
    fi
    log_end_msg 0
}

log_failure_msg () {
    if [ -n "${1:-}" ]; then
        log_begin_msg $@ "..."
    fi
    log_end_msg 1 || true
}

[ ... ]

