X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=scripts%2Ffunctions.rc;h=854a56735c3e1af787a09b41f95eeaf6ee2db962;hb=d9f823e06902b93c9a708bf831128fe0f4d8d5a3;hp=031eaa17c9d90594974dba27a9907d8465ec564b;hpb=9ea1bff7b049ce152767460c68bb61f6aa500cef;p=startuptools diff --git a/scripts/functions.rc b/scripts/functions.rc index 031eaa1..854a567 100644 --- a/scripts/functions.rc +++ b/scripts/functions.rc @@ -1,3 +1,15 @@ +#!/bin/sh + +if [ "$USE_COLOR" = '1' ] && [ -x /usr/bin/tput ]; then +red=$(tput setaf 1) +green=$(tput setaf 2) +off=$(tput sgr0) +fi + +status_msg() { + echo "\r[$1]" +} + status_starting() { echo -n "[ ] Starting $1" } @@ -11,7 +23,7 @@ status_stopping() { } status_ok() { - echo "\r[ OK ]" + echo "\r[ ${green}OK$off ]" } status_fail() { @@ -19,6 +31,10 @@ status_fail() { } status_check() { - local r=$1 - test ${r:=$?} -eq 0 && status_ok || status_fail + test $? -eq 0 && status_ok || status_fail +} + +is_true() { + [ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ] || [ "$1" = "y" ] || + [ "$1" = "t" ] }