- 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
+ 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
- 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}
+ 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}
- [ "${RC_QUIET_STDOUT}" = "yes" ] && return 0
- [ "${RC_ENDCOL}" != "yes" ] && [ "${LAST_E_CMD}" = "ebegin" ] && echo
- printf " ${GOOD}*${NORMAL} ${RC_INDENTATION}$*"
- LAST_E_CMD=einfon
- return 0
+ [ "${RC_QUIET_STDOUT}" = "yes" ] && return 0
+ [ "${RC_ENDCOL}" != "yes" ] && [ "${LAST_E_CMD}" = "ebegin" ] && echo
+ printf " ${GOOD}*${NORMAL} ${RC_INDENTATION}$*"
+ LAST_E_CMD=einfon
+ return 0
- if [ "${RC_QUIET_STDOUT}" = "yes" ]; then
- printf " $*\n"
- else
- [ "${RC_ENDCOL}" != "yes" ] && [ "${LAST_E_CMD}" = "ebegin" ] && echo
- printf " ${WARN}*${NORMAL} ${RC_INDENTATION}$*\n"
- fi
+ if [ "${RC_QUIET_STDOUT}" = "yes" ]; then
+ printf " $*\n"
+ else
+ [ "${RC_ENDCOL}" != "yes" ] && [ "${LAST_E_CMD}" = "ebegin" ] && echo
+ printf " ${WARN}*${NORMAL} ${RC_INDENTATION}$*\n"
+ fi
- if [ "${RC_QUIET_STDOUT}" = "yes" ]; then
- printf " $*\n" >/dev/stderr
- else
- [ "${RC_ENDCOL}" != "yes" ] && [ "${LAST_E_CMD}" = "ebegin" ] && echo
- printf " ${BAD}*${NORMAL} ${RC_INDENTATION}$*\n"
- fi
+ if [ "${RC_QUIET_STDOUT}" = "yes" ]; then
+ printf " $*\n" >/dev/stderr
+ else
+ [ "${RC_ENDCOL}" != "yes" ] && [ "${LAST_E_CMD}" = "ebegin" ] && echo
+ printf " ${BAD}*${NORMAL} ${RC_INDENTATION}$*\n"
+ fi
- local msg="$*" dots spaces
- spaces="$(printf '%'"${#RC_DOT_PATTERN}"'s' '')"
- [ "${RC_QUIET_STDOUT}" = "yes" ] && return 0
-
- if [ -n "${RC_DOT_PATTERN}" ]; then
- dots=$(printf "%$(( COLS - 3 - ${#RC_INDENTATION} - ${#msg} - 7 ))s" '')
- while [ "${dots#${spaces}}" != "${dots}" ] ; do
- dots="${dots#${spaces}}${RC_DOT_PATTERN}"
- done
- msg="${msg}${dots}"
- else
- msg="${msg} ..."
- fi
- einfon "${msg}"
- [ "${RC_ENDCOL}" = "yes" ] && echo
-
- LAST_E_LEN=$(( 3 + ${#RC_INDENTATION} + ${#msg} ))
- LAST_E_CMD=ebegin
- return 0
+ local msg="$*" dots spaces
+ spaces="$(printf '%'"${#RC_DOT_PATTERN}"'s' '')"
+ [ "${RC_QUIET_STDOUT}" = "yes" ] && return 0
+
+ if [ -n "${RC_DOT_PATTERN}" ]; then
+ dots=$(printf "%$(( COLS - 3 - ${#RC_INDENTATION} - ${#msg} - 7 ))s" '')
+ while [ "${dots#${spaces}}" != "${dots}" ] ; do
+ dots="${dots#${spaces}}${RC_DOT_PATTERN}"
+ done
+ msg="${msg}${dots}"
+ else
+ msg="${msg} ..."
+ fi
+ einfon "${msg}"
+ [ "${RC_ENDCOL}" = "yes" ] && echo
+
+ LAST_E_LEN=$(( 3 + ${#RC_INDENTATION} + ${#msg} ))
+ LAST_E_CMD=ebegin
+ return 0
- if [ "${retval}" -eq 0 ]; then
- [ "${RC_QUIET_STDOUT}" = "yes" ] && return 0
- msg="${BRACKET}[ ${GOOD}ok${BRACKET} ]${NORMAL}"
- else
- if [ -n "$*" ]; then
- "${efunc}" "$*"
- fi
- msg="${BRACKET}[ ${BAD}!!${BRACKET} ]${NORMAL}"
- fi
+ if [ "${retval}" -eq 0 ]; then
+ [ "${RC_QUIET_STDOUT}" = "yes" ] && return 0
+ msg="${BRACKET}[ ${GOOD}ok${BRACKET} ]${NORMAL}"
+ else
+ if [ -n "$*" ]; then
+ "${efunc}" "$*"
+ fi
+ msg="${BRACKET}[ ${BAD}!!${BRACKET} ]${NORMAL}"
+ fi
- if [ "${RC_ENDCOL}" = "yes" ]; then
- printf "${ENDCOL} ${msg}\n"
- else
- [ "${LAST_E_CMD}" = "ebegin" ] || LAST_E_LEN=0
- printf "%$(( "${COLS}" - "${LAST_E_LEN}" - 6 ))s%b\n" '' "${msg}"
- fi
+ if [ "${RC_ENDCOL}" = "yes" ]; then
+ printf "${ENDCOL} ${msg}\n"
+ else
+ [ "${LAST_E_CMD}" = "ebegin" ] || LAST_E_LEN=0
+ printf "%$(( "${COLS}" - "${LAST_E_LEN}" - 6 ))s%b\n" '' "${msg}"
+ fi
}
# v-e-commands honor RC_VERBOSE which defaults to no.
# The condition is negated so the return value will be zero.
}
# 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 "$@"; }
+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 "$@"; }
- [ "${RC_VERBOSE}" = "yes" ] && { ewend "$@"; return $?; }
- return ${1:-0}
-}
-
-# char *KV_major(string)
-#
-# Return the Major (X of X.Y.Z) kernel version
-#
-KV_major() {
- [ -z "$1" ] && return 1
-
- local KV=$@
- printf "${KV%%.*}\n"
-}
-
-# char *KV_minor(string)
-#
-# Return the Minor (Y of X.Y.Z) kernel version
-#
-KV_minor() {
- [ -z "$1" ] && return 1
-
- local KV="$@"
- KV="${KV#*.}"
- printf "${KV%%.*}\n"
+ [ "${RC_VERBOSE}" = "yes" ] && { ewend "$@"; return $?; }
+ return ${1:-0}
- [ -z "$1" ] && return 1
-
- local KV_MAJOR="$(KV_major "$1")"
- local KV_MINOR="$(KV_minor "$1")"
- local KV_MICRO="$(KV_micro "$1")"
- local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO ))
-
- # We make version 2.2.0 the minimum version we will handle as
- # a sanity check ... if its less, we fail ...
- if [ "${KV_int}" -ge 131584 ] ; then
- printf "${KV_int}\n"
- return 0
- fi
+ [ -z "$1" ] && return 1
+
+ local KV_MAJOR="$(KV_major "$1")"
+ local KV_MINOR="$(KV_minor "$1")"
+ local KV_MICRO="$(KV_micro "$1")"
+ local KV_int=$(( KV_MAJOR * 65536 + KV_MINOR * 256 + KV_MICRO ))
+
+ # We make version 2.2.0 the minimum version we will handle as
+ # a sanity check ... if its less, we fail ...
+ if [ "${KV_int}" -ge 131584 ] ; then
+ printf "${KV_int}\n"
+ return 0
+ fi
# e.g. 2.4.25, 2.6.10, 2.6.4-rc3, 2.2.40-poop, 2.0.15+foo
#
get_KV() {
# e.g. 2.4.25, 2.6.10, 2.6.4-rc3, 2.2.40-poop, 2.0.15+foo
#
get_KV() {
- 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}
+ 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}
- if [ ! -d "${x}" ] && ( [ -L "${x}" -o -f "${x}" ] )
- then
- mylist="${mylist} $(ls "${x}" 2> /dev/null)"
- else
- [ "${x%/}" != "${x}" ] && x="${x%/}"
+ if [ ! -d "${x}" ] && ( [ -L "${x}" ] || [ -f "${x}" ] )
+ then
+ mylist="${mylist} $(ls "${x}" 2> /dev/null)"
+ else
+ [ "${x%/}" != "${x}" ] && x="${x%/}"
# Returns a config file name with the softlevel suffix
# appended to it. For use with multi-config services.
add_suffix() {
# Returns a config file name with the softlevel suffix
# appended to it. For use with multi-config services.
add_suffix() {
- if [ "${RC_USE_CONFIG_PROFILE}" = "yes" -a -e "$1.${DEFAULTLEVEL}" ]
- then
- printf "$1.${DEFAULTLEVEL}\n"
- else
- printf "$1\n"
- fi
+ if [ "${RC_USE_CONFIG_PROFILE}" = "yes" -a -e "$1.${DEFAULTLEVEL}" ]
+ then
+ printf "$1.${DEFAULTLEVEL}\n"
+ else
+ printf "$1\n"
+ fi
- 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
+ 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
- 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
+ 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