X-Git-Url: https://git.grml.org/?a=blobdiff_plain;f=etc%2Fgrml%2Flsb-functions;h=4dc84413977baa621afe1a8e7a91b4afbda5f1c0;hb=9112e5bdd49f8f4f4abf79c219af7c54b57cfb80;hp=094395ae1c15fded8d27d486eed7384dd7b4cf74;hpb=4bfb41b45facbda837c14aeac6ead19b112ee1d9;p=grml-etc-core.git diff --git a/etc/grml/lsb-functions b/etc/grml/lsb-functions index 094395a..4dc8441 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"}" @@ -151,6 +157,14 @@ log_end_msg() { # initialisation {{{ # internal variables +# Dont output to stdout? +RC_QUIET_STDOUT="no" + +# Default values for e-message indentation and dots +RC_INDENTATION='' +RC_DEFAULT_INDENT=2 +#RC_DOT_PATTERN=' .' +RC_DOT_PATTERN='' # dont output to stdout? rc_quiet_stdout="no" @@ -166,9 +180,18 @@ if [ -r /proc/cmdline ] ; then fi [ -n "$NOCOLORS" ] && RC_NOCOLOR='yes' RC_NOCOLOR="${RC_NOCOLOR:-no}" +if [ "$RC_NOCOLOR" = "no" ] ; then + if [ -r /etc/grml_colors ] ; then + . /etc/grml_colors + fi +fi # Can the terminal handle endcols? -RC_ENDCOL="yes" +if [ "${RC_NOCOLOR}" = "yes" ]; then + RC_ENDCOL="no" +else + RC_ENDCOL="yes" +fi # Setup COLS and ENDCOL so eend can line up the [ ok ] # width of [ ok ] == 7 @@ -396,4 +419,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