blob: bf6b78727401ddf2cdec3c401f4bb37acf05b1f3 (
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
78
79
80
81
82
83
84
85
86
87
88
89
90
|
### Sample netcfg hook script for logging/debugging connections
### To install, make this executable and put it in /etc/network.d/hooks
. /etc/rc.conf
. /etc/rc.d/functions
# if NETCFG_DEBUG is set, debugging messages go to stderr instead of syslog
# What facility to send log messages to? if set to "", nothing will be sent to syslog
NETCFG_LOG="${NETCFG_LOG-local0}"
function report_log {
if [[ -n "$NETCFG_LOG" ]]; then
local caller level="$1"
shift
case "$0" in
net-auto|netcfg-auto-*) caller=net-auto;;
net-profiles) caller=net-profiles;;
net-rename) caller=net-rename;;
*) caller=netcfg;;
esac
logger -p "${NETCFG_LOG}.$level" -t "$caller" -- "$*"
fi
}
function report_err {
report_log err "$*"
printhl "$*"
}
function report_warn {
report_log warning "$*"
# printhl "$*"
checkyesno "$NETCFG_DEBUG" && echo "DEBUG: $*" >&2
}
function report_notify {
report_log notice "$*"
# print "$*" >&2
checkyesno "$NETCFG_DEBUG" && echo "DEBUG: $*" >&2
}
function report_debug {
if checkyesno "$NETCFG_DEBUG"; then
echo "DEBUG: $*" >&2
else
report_log debug "$*"
fi
}
function report_try {
report_log notice "trying $*..."
stat_busy "$*"
REPORT_TRYING=1
}
function report_fail {
if [[ -n "$*" ]]; then
report_log err "$*"
if [[ -n "$REPORT_TRYING" ]]; then
stat_append "- $*"
REPORT_TRYING=
stat_fail
else
printhl "$*"
fi
elif [[ -n "$REPORT_TRYING" ]]; then
REPORT_TRYING=
stat_fail
fi
}
function report_success {
if [[ -n "$*" ]]; then
stat_append "- $*"
REPORT_TRYING=
fi
report_log notice "${*:-succeeded}"
stat_done
}
|