--- trunk/magellan-initscripts/etc/rc.d/init.d/functions 2005/07/03 21:30:58 147 +++ trunk/magellan-initscripts/etc/rc.d/init.d/functions 2011/03/11 17:14:05 1242 @@ -1,5 +1,5 @@ #!/bin/bash -# $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/functions,v 1.4 2005-07-03 21:30:58 niro Exp $ +# $Id$ # Begin $rc_base/init.d/functions - Run Level Control Functions @@ -40,25 +40,22 @@ COLOREDSTAR="${COLBLUE}(${COLGREEN}*${COLBLUE})${COLDEFAULT} " -#location to save the started services +# location to save the started services svcdir="/var/lib/init.d" svclib="/lib/rcscripts" svcmount="no" svcfstype="tmpfs" svcsize=1024 +rc_echo() { echo $@; } +rc_print() { rc_echo -e "${COLOREDSTAR}$@"; } # dummy function; needed if splashutils are not installed -splash() { - return 0 -} +splash() { return 0; } - -#source splash functions if exists +# source splash functions if exists [ -f /etc/init.d/splash-functions ] && source /etc/init.d/splash-functions - - print_error_msg() { return 0 @@ -98,7 +95,6 @@ local SVCD_INITSCRIPT local x - #do this only if proc is mounted [ ! -f /proc/mounts ] && return 0 @@ -137,16 +133,22 @@ evaluate_retval() { - error_value=$? + local error_value="$1" + [[ -z ${error_value} ]] && error_value=$? - if [ $error_value = 0 ] + if [[ ${error_value} = 0 ]] then print_status success else print_status failure + + if [[ ${SPLASH_VERBOSE_ON_ERRORS} = 1 ]] + then + splash "rc_verbose" "${runlevel}" + fi fi - return $error_value + return ${error_value} } print_status() @@ -287,7 +289,6 @@ else signal=${2##-} signal=${signal##SIG} - fi getpids $1 @@ -348,14 +349,20 @@ fi } +kernel_version() +{ + local KV="$(uname -r | cut -d- -f1)" + echo "${KV}" +} + kernel_major_version() { local KV - KV="$(uname -r|cut -d. -f1-2)" + KV="$(uname -r | cut -d. -f1-2)" echo "${KV}" } -dolisting() +dolisting() { local x= local y= @@ -391,7 +398,8 @@ } # searches /proc/mounts for mounted fstypes (like ext3) -is_fstype_mounted() { +is_fstype_mounted() +{ local filesys local i filesys=$1 @@ -403,7 +411,8 @@ } # searches /proc/mounts for mounted fs names (like udev, proc) -is_fs_mounted() { +is_fs_mounted() +{ local filesys local i filesys=$1 @@ -415,7 +424,8 @@ } # checks if kernel supports fs xy -kernel_supports_fs() { +kernel_supports_fs() +{ local filesys local i filesys=$1 @@ -425,3 +435,31 @@ return 0 } + +# bool is_older_than(reference, files/dirs to check) +# +# return 0 if any of the files/dirs are newer than +# the reference file +# +# EXAMPLE: if is_older_than a.out *.o ; then ... +is_older_than() +{ + local x= + local ref="$1" + shift + + for x in "$@" + do + [[ ${x} -nt ${ref} ]] && return 0 + + if [[ -d ${x} ]] + then + is_older_than "${ref}" "${x}"/* && return 0 + fi + done + + return 1 +} + +start_devicemanager() { touch /dev/.none; return 0; } +stop_devicemanager() { return 0; }