TPUT="${TPUT:-"/usr/bin/tput"}"
-have_tput() {
+_have_tput() {
[ -x "$TPUT" ] && "$TPUT" hpa 60 >/dev/null 2>&1 \
&& return 0 \
|| return 1
}
-log_success_msg () {
+log_success_msg() {
printf " * $@\n"
}
-log_failure_msg () {
- if have_tput ; then
+log_failure_msg() {
+ if _have_tput ; then
RED="$("$TPUT" setaf 1)"
#NORMAL="$("$TPUT" op)"
printf " ${RED}*${NORMAL} $@\n"
fi
}
-log_warning_msg () {
- if have_tput ; then
+log_warning_msg() {
+ if _have_tput ; then
YELLOW="$("$TPUT" setaf 3)"
#NORMAL="$("$TPUT" op")"
# printf " *${NORMAL} $@\n"
fi
}
-log_warning_msg_nn () {
- if have_tput ; then
+log_warning_msg_nn() {
+ if _have_tput ; then
YELLOW="$("$TPUT" setaf 3)"
printf " ${BLUE}*${NORMAL} $@"
else
}
# int log_begin_message (char *message)
-log_begin_msg () {
+log_begin_msg() {
if [ "$#" -eq 0 ]; then
return 1
fi
printf " ${GREEN}*${NORMAL} $@\n"
}
-log_begin_msg_nn () {
+log_begin_msg_nn() {
if [ "$#" -eq 0 ]; then
return 1
fi
SUBMSG=" ${GREEN}-${NORMAL} "
# int log_end_message (int exitstatus)
-log_end_msg () {
+log_end_msg() {
# If no arguments were passed, return
[ "$#" -eq 0 ] && return 1
# Only do the fancy stuff if we have an appropriate terminal
# and if /usr is already mounted
- if have_tput ; then
+ if _have_tput ; then
COLS="$("$TPUT" cols)"
if [ -n "$COLS" ]; then
COL=$(( "$COLS" - 7 ))
#RC_DOT_PATTERN=' .'
RC_DOT_PATTERN=''
-# void splash(...)
-#
-# Notify bootsplash/splashutils/gensplash/whatever about
-# important events.
-#
-splash() {
- return 0
-}
-
-# void profiling(...)
-#
-# Notify bootsplash/whatever about important events.
-#
-profiling() {
- return 0
-}
-
-# void get_bootconfig()
-#
-# Get the BOOTLEVEL and SOFTLEVEL by setting
-# 'bootlevel' and 'softlevel' via kernel
-# parameters.
-#
-get_bootconfig() {
- local copt
- local newbootlevel
- local newsoftlevel
-
- for copt in $(</proc/cmdline) ; do
- case "${copt%=*}" in
- "bootlevel")
- newbootlevel="${copt##*=}"
- ;;
- "softlevel")
- newsoftlevel="${copt##*=}"
- ;;
- esac
- done
-
- if [ -n "${newbootlevel}" ] ; then
- export BOOTLEVEL="${newbootlevel}"
- else
- export BOOTLEVEL="boot"
- fi
-
- if [ -n "${newsoftlevel}" ] ; then
- export DEFAULTLEVEL="${newsoftlevel}"
- else
- export DEFAULTLEVEL="default"
- fi
-
- return 0
-}
-
-# void get_libdir(void)
-#
-# prints the current libdir {lib,lib32,lib64}
-#
-get_libdir() {
- if [ -n "${CONF_LIBDIR_OVERRIDE}" ] ; then
- CONF_LIBDIR="${CONF_LIBDIR_OVERRIDE}"
- elif [ -x "/usr/bin/portageq" ] ; then
- CONF_LIBDIR="$(/usr/bin/portageq envvar CONF_LIBDIR)"
- fi
- printf '%s\n' ${CONF_LIBDIR:=lib}
-}
-
# void esyslog(char* priority, char* tag, char* message)
#
# use the system logger to log a message
return $retval
}
-# v-e-commands honor RC_VERBOSE which defaults to no.
-# The condition is negated so the return value will be zero.
-veinfo() { [ "${RC_VERBOSE}" != "yes" ] || einfo "$@"; }
-veinfon() { [ "${RC_VERBOSE}" != "yes" ] || einfon "$@"; }
-vewarn() { [ "${RC_VERBOSE}" != "yes" ] || ewarn "$@"; }
-veerror() { [ "${RC_VERBOSE}" != "yes" ] || eerror "$@"; }
-vebegin() { [ "${RC_VERBOSE}" != "yes" ] || ebegin "$@"; }
-veend() {
- [ "${RC_VERBOSE}" = "yes" ] && { eend "$@"; return $?; }
- return ${1:-0}
-}
-veend() {
- [ "${RC_VERBOSE}" = "yes" ] && { ewend "$@"; return $?; }
- return ${1:-0}
-}
-
-# int get_KV()
-#
-# Return the kernel version (major, minor and micro concated) as an integer.
-# Assumes X and Y of X.Y.Z are numbers. Also assumes that some leading
-# portion of Z is a number.
-# e.g. 2.4.25, 2.6.10, 2.6.4-rc3, 2.2.40-poop, 2.0.15+foo
-#
-get_KV() {
- local KV="$(uname -r)"
-
- printf "$(KV_to_int "${KV}")\n"
-
- return $?
-}
-
-# bool get_bootparam(param)
-#
-# return 0 if gentoo=param was passed to the kernel
-#
-# EXAMPLE: if get_bootparam "nodevfs" ; then ....
-#
-get_bootparam() {
- local x copt params retval=1
-
- [ ! -r "/proc/cmdline" ] && return 1
-
- for copt in $(< /proc/cmdline)
- do
- if [ "${copt%=*}" = "gentoo" ]
- then
- params="$(gawk -v PARAMS="${copt##*=}" '
- BEGIN {
- split(PARAMS, nodes, ",")
- for (x in nodes)
- print nodes[x]
- }')"
-
- # Parse gentoo option
- for x in ${params}
- do
- if [ "${x}" = "$1" ]
- then
-# printf "YES\n"
- retval=0
- fi
- done
- fi
- done
-
- return ${retval}
-}
-
-# Safer way to list the contents of a directory,
-# as it do not have the "empty dir bug".
-#
-# char *dolisting(param)
-#
-# print a list of the directory contents
-#
-# NOTE: quote the params if they contain globs.
-# also, error checking is not that extensive ...
-#
-dolisting() {
- local x
- local y
- local tmpstr
- local mylist
- local mypath="$*"
-
- if [ "${mypath%/\*}" != "${mypath}" ]
- then
- mypath="${mypath%/\*}"
- fi
-
- for x in ${mypath}
- do
- [ ! -e "${x}" ] && continue
-
- if [ ! -d "${x}" ] && ( [ -L "${x}" ] || [ -f "${x}" ] )
- then
- mylist="${mylist} $(ls "${x}" 2> /dev/null)"
- else
- [ "${x%/}" != "${x}" ] && x="${x%/}"
-
- cd "${x}"; tmpstr="$(ls)"
-
- for y in ${tmpstr}
- do
- mylist="${mylist} ${x}/${y}"
- done
- fi
- done
-
- printf "${mylist}\n"
-}
-
# char *add_suffix(char * configfile)
#
# Returns a config file name with the softlevel suffix
return 0
}
-# Network filesystems list for common use in rc-scripts.
-# This variable is used in is_net_fs and other places such as
-# localmount.
-NET_FS_LIST="afs cifs coda gfs ncpfs nfs nfs4 shfs smbfs"
-
-# bool is_net_fs(path)
-#
-# return 0 if path is the mountpoint of a networked filesystem
-#
-# EXAMPLE: if is_net_fs / ; then ...
-#
-is_net_fs() {
- local fstype
- # /proc/mounts is always accurate but may not always be available
- if [ -e /proc/mounts ]; then
- fstype="$( sed -n -e '/^rootfs/!s:.* '"$1"' \([^ ]*\).*:\1:p' /proc/mounts )"
- else
- fstype="$( mount | sed -n -e 's:.* on '"$1"' type \([^ ]*\).*:\1:p' )"
- fi
- case " ${NET_FS_LIST} " in
- *" ${fstype} "*)
- return 0
- ;;
- *)
- return 1
- ;;
- esac
-}
-
-# bool is_uml_sys()
-#
-# return 0 if the currently running system is User Mode Linux
-#
-# EXAMPLE: if is_uml_sys ; then ...
-#
-is_uml_sys() {
- grep -qs 'UML' /proc/cpuinfo
- return $?
-}
-
-# bool is_vserver_sys()
-#
-# return 0 if the currently running system is a Linux VServer
-#
-# EXAMPLE: if is_vserver_sys ; then ...
-#
-is_vserver_sys() {
- grep -qs '^s_context:[[:space:]]*[1-9]' /proc/self/status
- return $?
-}
-
-# bool get_mount_fstab(path)
-#
-# return the parameters to pass to the mount command generated from fstab
-#
-# EXAMPLE: cmd=$( get_mount_fstab /proc )
-# cmd=${cmd:--t proc none /proc}
-# mount -n ${cmd}
-#
-get_mount_fstab() {
- awk '$1 ~ "^#" { next }
- $2 == "'$*'" { if (found++ == 0) { print "-t "$3,"-o "$4,$1,$2 } }
- END { if (found > 1) { print "More than one entry for '$*' found in /etc/fstab!" > "/dev/stderr" } }
- ' /etc/fstab
-}
-
# char *reverse_list(list)
#
# Returns the reversed order of list