X-Git-Url: https://git.grml.org/?a=blobdiff_plain;f=etc%2Fgrml%2Flsb-functions;h=d6513db226cee8c1dfad139356bcc8b381998185;hb=aaa1e7fa0cf1a864cb163b212c9b9b8a8488541d;hp=ceffb0c922d613bd38aad9fabe32a825e6c5ffdf;hpb=527ab1159d79e9d52878e27429d470ae9f35686a;p=grml-etc-core.git diff --git a/etc/grml/lsb-functions b/etc/grml/lsb-functions index ceffb0c..d6513db 100644 --- a/etc/grml/lsb-functions +++ b/etc/grml/lsb-functions @@ -30,6 +30,12 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. +if [ "$(cat /proc/1/comm 2>/dev/null)" = "systemd" ] ; then + SYSTEMD=true +else + SYSTEMD=false +fi + # log_*() functions {{{ TPUT="${TPUT:-"/usr/bin/tput"}" @@ -177,9 +183,9 @@ RC_NOCOLOR="${RC_NOCOLOR:-no}" # Can the terminal handle endcols? if [ "${RC_NOCOLOR}" = "yes" ]; then - RC_ENDCOL="yes" -else RC_ENDCOL="no" +else + RC_ENDCOL="yes" fi # Setup COLS and ENDCOL so eend can line up the [ ok ] @@ -408,4 +414,27 @@ ewend() { } #}}} +# if we're using systemd then redfine functions for +# output in systemd style +if $SYSTEMD ; then + einfo() { + printf "[ ${GREEN}OK${NORMAL} ] %s\n" "$*" + } + + ewarn() { + printf "[ ${YELLOW}WARN${NORMAL} ] %s\n" "$*" + } + + eerror() { + printf "[ ${RED}FAIL${NORMAL} ] %s\n" "$*" + } + + eend() { + : + } +fi + +# don't expose unneeded local variables +unset SYSTEMD + # vim: ft=sh tw=80 ts=4 foldmethod=marker