summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc/hooks/fancy50
-rwxr-xr-xsrc/hooks/initscripts48
2 files changed, 76 insertions, 22 deletions
diff --git a/src/hooks/fancy b/src/hooks/fancy
index f0ad3bb..26665eb 100755
--- a/src/hooks/fancy
+++ b/src/hooks/fancy
@@ -5,16 +5,16 @@
### Fancy Logging/Error reporting
function report_err {
- print_prefixed "${C_PREFIX}" "${C_HIGHLIGHT}$*"
+ print_prefixed "${FANCY_OTHER}" "${FANCY_HIGHLIGHT}$*"
}
function report_notice {
- print_prefixed "${C_PREFIX}" "$*"
+ print_prefixed "${FANCY_OTHER}" "$*"
}
function report_try {
- printf "${C_PREFIX}${PREFIX_BUSY}${C_NORMAL} %s " "$*"
- report_status " BUSY " "${C_BUSY}"
+ printf "${FANCY_OTHER}${PREFIX_BUSY}${FANCY_NORMAL} %s " "$*"
+ report_busy
REPORT_TRYING=1
}
@@ -22,13 +22,13 @@ function report_fail {
if [[ -n "$*" ]]; then
if [[ -n "$REPORT_TRYING" ]]; then
report_append "$*"
- report_status "FAILED" "${C_FAILED}" $'\n'
+ report_failed
REPORT_TRYING=
else
- print_prefixed "${C_FAILED}" "${C_HIGHLIGHT}$*"
+ print_prefixed "${FANCY_FAILED}" "${FANCY_HIGHLIGHT}$*"
fi
elif [[ -n "$REPORT_TRYING" ]]; then
- report_status "FAILED" "${C_FAILED}" $'\n'
+ report_failed
REPORT_TRYING=
fi
}
@@ -37,31 +37,37 @@ function report_success {
if [[ -n "$*" ]]; then
if [[ -n "$REPORT_TRYING" ]]; then
report_append "$*"
- report_status " DONE " "${C_DONE}" $'\n'
+ report_done
REPORT_TRYING=
else
- print_prefixed "${C_DONE}" "$*"
+ print_prefixed "${FANCY_DONE}" "$*"
fi
elif [[ -n "$REPORT_TRYING" ]]; then
- report_status " DONE " "${C_DONE}" $'\n'
+ report_done
REPORT_TRYING=
fi
}
function report_append {
- printf -- "${RESTORE_POSITION}${C_PREFIX}-${C_NORMAL} %s " "$*"
+ printf -- "${RESTORE_POSITION}${FANCY_OTHER}-${FANCY_NORMAL} %s " "$*"
}
-function report_status {
- local status=$1 color=$2
- shift 2
- printf "${CURSOR_STATUS} [${color}%s${C_NORMAL}] %s" "$status" "$*"
+function report_busy {
+ printf "${CURSOR_STATUS} [${FANCY_BUSY} BUSY ${FANCY_NORMAL}] "
+}
+
+function report_failed {
+ printf "${CURSOR_STATUS} [${FANCY_FAILED}FAILED${FANCY_NORMAL}]\n"
+}
+
+function report_done {
+ printf "${CURSOR_STATUS} [${FANCY_DONE} DONE ${FANCY_NORMAL}]\n"
}
function print_prefixed {
local c_prefix=$1
shift
- printf "${c_prefix}${PREFIX_ATTENTION}${C_NORMAL} %s${C_NORMAL}\n" "$*"
+ printf "${c_prefix}${PREFIX_ATTENTION}${FANCY_NORMAL} %s${FANCY_NORMAL}\n" "$*"
}
@@ -71,12 +77,12 @@ COLUMNS=$(tput cols)
(( COLUMNS == 0 )) && COLUMNS=80
CURSOR_STATUS=${SAVE_POSITION}$(tput hpa $(( COLUMNS - 10 )) )
-C_NORMAL=$(tput sgr0)
-C_HIGHLIGHT=${C_NORMAL}$(tput bold)
-C_PREFIX=${C_HIGHLIGHT}$(tput setaf 4) # blue
-C_BUSY=${C_NORMAL}$(tput setaf 6) # cyan
-C_FAILED=${C_HIGHLIGHT}$(tput setaf 1) # red
-C_DONE=${C_HIGHLIGHT}$(tput setaf 2) # green
+FANCY_NORMAL=$(tput sgr0)
+FANCY_HIGHLIGHT=${FANCY_NORMAL}$(tput bold)
+FANCY_BUSY=${FANCY_NORMAL}$(tput setaf 6) # cyan
+FANCY_FAILED=${FANCY_HIGHLIGHT}$(tput setaf 1) # red
+FANCY_DONE=${FANCY_HIGHLIGHT}$(tput setaf 2) # green
+FANCY_OTHER=${FANCY_HIGHLIGHT}$(tput setaf 4) # blue
PREFIX_BUSY="::"
PREFIX_ATTENTION=" >"
diff --git a/src/hooks/initscripts b/src/hooks/initscripts
new file mode 100755
index 0000000..06d467c
--- /dev/null
+++ b/src/hooks/initscripts
@@ -0,0 +1,48 @@
+# Use initscripts output formatting.
+# This hook must be loaded after 'fancy'.
+
+# At some point, this can be removed. Configuration through rc.conf is
+# than still possible for initscripts users as a side effect.
+if [[ -f /etc/rc.conf ]]; then
+ . /etc/rc.conf
+ if ! checkyesno $WARNED &&
+ [[ ${NETWORKS+x} = x || ${WIRED_INTERFACE+x} = x ||
+ ${WIRELESS_INTERFACE+x} = x || ${AUTO_PROFILES+x} = x ]]; then
+ report_err "Using /etc/rc.conf for netcfg settings is deprecated.
+ Use /etc/conf.d/netcfg instead."
+ export WARNED=yes
+ fi
+fi
+
+[[ ${FANCY_NORMAL+x} = x && -f /etc/rc.d/functions ]] || return
+#. /etc/rc.conf
+. /etc/rc.d/functions
+
+
+function report_try {
+ stat_busy "$*"
+ REPORT_TRYING=1
+}
+
+function report_append {
+ stat_append "- $*"
+}
+
+function report_failed {
+ stat_fail
+}
+
+function report_done {
+ stat_done
+}
+
+
+FANCY_NORMAL=$C_CLEAR
+FANCY_HIGHLIGHT=$C_H1
+FANCY_FAILED=$C_FAIL
+FANCY_DONE=$C_DONE
+FANCY_OTHER=$C_OTHER
+
+PREFIX_ATTENTION=$PREFIX_HL
+
+# vim: ft=sh ts=4 et sw=4: