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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155 | ~$ cat /etc/lsb*
cat: /etc/lsb-base: Ist ein Verzeichnis
# Default init script logging functions suitable for Ubuntu.
# See /lib/lsb/init-functions for usage help.
log_use_usplash () {
if [ "${loop:-n}" = y ]; then
return 1
fi
type usplash_write >/dev/null 2>&1
}
log_success_msg () {
if log_use_usplash; then
usplash_write "TEXT $*" || true
fi
echo " * $@"
}
log_failure_msg () {
if log_use_usplash; then
usplash_write "TEXT $*" || true
fi
if log_use_fancy_output; then
RED=`$TPUT setaf 1`
NORMAL=`$TPUT op`
echo " $RED*$NORMAL $@"
else
echo " * $@"
fi
}
log_warning_msg () {
if log_use_usplash; then
usplash_write "TEXT $*" || true
fi
if log_use_fancy_output; then
YELLOW=`$TPUT setaf 3`
NORMAL=`$TPUT op`
echo " $YELLOW*$NORMAL $@"
else
echo " * $@"
fi
}
log_begin_msg () {
log_daemon_msg "$1"
}
log_daemon_msg () {
if [ -z "$1" ]; then
return 1
fi
if log_use_usplash; then
usplash_write "TEXT $*" || true
fi
if log_use_fancy_output && $TPUT xenl >/dev/null 2>&1; then
COLS=`$TPUT cols`
if [ "$COLS" ] && [ "$COLS" -gt 6 ]; then
COL=`$EXPR $COLS - 7`
else
COLS=80
COL=73
fi
# We leave the cursor `hanging' about-to-wrap (see terminfo(5)
# xenl, which is approximately right). That way if the script
# prints anything then we will be on the next line and not
# overwrite part of the message.
# Previous versions of this code attempted to colour-code the
# asterisk but this can't be done reliably because in practice
# init scripts sometimes print messages even when they succeed
# and we won't be able to reliably know where the colourful
# asterisk ought to go.
printf " * $* "
# Enough trailing spaces for ` [fail]' to fit in; if the message
# is too long it wraps here rather than later, which is what we
# want.
$TPUT hpa `$EXPR $COLS - 1`
printf ' '
else
echo " * $@"
COL=
fi
}
log_progress_msg () {
:
}
log_end_msg () {
if [ -z "$1" ]; then
return 1
fi
if log_use_usplash; then
if [ "$1" -eq 0 ]; then
usplash_write "SUCCESS OK" || true
else
usplash_write "FAILURE failed" || true
fi
fi
if [ "$COL" ] && [ -x "$TPUT" ]; then
printf "\r"
$TPUT hpa $COL
if [ "$1" -eq 0 ]; then
echo "[ OK ]"
else
printf '['
$TPUT setaf 1 # red
printf fail
$TPUT op # normal
echo ']'
fi
else
if [ "$1" -eq 0 ]; then
echo " ...done."
else
echo " ...fail!"
fi
fi
return $1
}
log_action_msg () {
if log_use_usplash; then
usplash_write "TEXT $*" || true
fi
echo " * $@"
}
log_action_begin_msg () {
log_daemon_msg "$@..."
}
log_action_cont_msg () {
log_daemon_msg "$@..."
}
log_action_end_msg () {
# In the future this may do something with $2 as well.
log_end_msg "$1" || true
}
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04.2 LTS"
|