aboutsummaryrefslogtreecommitdiff
path: root/functions
blob: dcd391ad419cfd1cca1d6a68d2dfcaf726a29433 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
#
# functions
#

STAT_COL=68

deltext() {
	echo -ne "\033[$(($STAT_COL+4))G"
}

stat_busy() {
	echo -n "[ $1 "
	awk "BEGIN { for (j=length(\"$1\"); j<$STAT_COL; j++) printf \" \" }"
	echo -n "   BUSY ]"
}

stat_done() {
	deltext
	echo "   DONE ]"
}

stat_fail() {
	deltext
	echo " FAILED ]"
}

stat_die() {
	stat_fail
	exit 1
}

#
# here for legcay reasons: use 'status' instead
#
checkret() {
	$* >/dev/null 2>&1
	if [ $? -gt 0 ]; then
		stat_fail
		return 0
	else
		stat_done
		return 1
	fi
}

status() {
	stat_busy "$1"
	shift
	$* >/dev/null 2>&1
	if [ $? -eq 0 ]; then
		stat_done
		return 0
	else
		stat_fail
		return 1
	fi
}

add_daemon() {
	[ -d /var/run/daemons ] || mkdir -p /var/run/daemons
	touch /var/run/daemons/$1
}

rm_daemon() {
	rm -f /var/run/daemons/$1
}

ck_daemon() {
	if [ -f /var/run/daemons/$1 ]; then
		return 1
	else
		return 0
	fi
}

# End of file