]> pd.if.org Git - startuptools/blob - scripts/functions.rc
add is_true function and stub upport for color
[startuptools] / scripts / functions.rc
1 #!/bin/sh
2
3 if [ "$USE_COLOR" = '1' ] && [ -x /usr/bin/tput ]; then
4 red=$(tput setaf 1)
5 green=$(tput setaf 2)
6 off=$(tput sgr0)
7 fi
8
9 status_msg() {
10         echo "\r[$1]"
11 }
12
13 status_starting() {
14         echo -n "[      ] Starting $1"
15 }
16
17 status_begin() {
18         echo -n "[      ] $*"
19 }
20
21 status_stopping() {
22         echo -n "[      ] Stopping $1"
23 }
24
25 status_ok() {
26         echo    "\r[  ${green}OK$off  ]"
27 }
28
29 status_fail() {
30         echo    "\r[FAILED]"
31 }
32
33 status_check() {
34         test $? -eq 0 && status_ok || status_fail
35 }
36
37 is_true() {
38    [ "$1" = "1" ] || [ "$1" = "yes" ] || [ "$1" = "true" ] ||  [ "$1" = "y" ] ||
39    [ "$1" = "t" ]
40 }