Magellan Linux

Diff of /trunk/initscripts/sysvinit/rc/functions

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 71 by niro, Tue Mar 15 19:07:56 2005 UTC revision 931 by niro, Thu Nov 5 12:57:14 2009 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  # $Header: /home/cvsd/magellan-cvs/magellan-src/magellan-initscripts/etc/rc.d/init.d/functions,v 1.3 2005-03-15 19:07:56 niro Exp $  # $Id$
3    
4  # Begin $rc_base/init.d/functions - Run Level Control Functions  # Begin $rc_base/init.d/functions - Run Level Control Functions
5    
# Line 137  update_svcstatus() Line 137  update_svcstatus()
137    
138  evaluate_retval()  evaluate_retval()
139  {  {
140   error_value=$?   local error_value="$1"
141     [[ -z ${error_value} ]] && error_value=$?
142    
143   if [ $error_value = 0 ]   if [[ ${error_value} = 0 ]]
144   then   then
145   print_status success   print_status success
146   else   else
147   print_status failure   print_status failure
148   fi   fi
149    
150   return $error_value   return ${error_value}
151  }  }
152    
153  print_status()  print_status()
# Line 348  progressbar() Line 349  progressbar()
349   fi   fi
350  }  }
351    
352    kernel_version()
353    {
354     local KV="$(uname -r | cut -d- -f1)"
355     echo "${KV}"
356    }
357    
358  kernel_major_version()  kernel_major_version()
359  {  {
360   local KV   local KV
361   KV="$(uname -r|cut -d. -f1-2)"   KV="$(uname -r | cut -d. -f1-2)"
362   echo "${KV}"   echo "${KV}"
363  }  }
364    
365  dolisting()  dolisting()
366  {  {
367   local x=   local x=
368   local y=   local y=
# Line 389  dolisting() Line 396  dolisting()
396    
397   echo "${mylist}"   echo "${mylist}"
398  }  }
399    
400    # searches /proc/mounts for mounted fstypes (like ext3)
401    is_fstype_mounted() {
402     local filesys
403     local i
404     filesys=$1
405    
406     i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f3)"
407     [[ ${i} != ${filesys} ]] && return 1
408    
409     return 0
410    }
411    
412    # searches /proc/mounts for mounted fs names (like udev, proc)
413    is_fs_mounted() {
414     local filesys
415     local i
416     filesys=$1
417    
418     i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f1)"
419     [[ ${i} != ${filesys} ]] && return 1
420    
421     return 0
422    }
423    
424    # checks if kernel supports fs xy
425    kernel_supports_fs() {
426     local filesys
427     local i
428     filesys=$1
429    
430     i="$(cat /proc/filesystems | grep ${filesys} | cut -d $'\t' -f2)"
431     [[ ${i} != ${filesys} ]] && return 1
432    
433     return 0
434    }
435    
436    # bool is_older_than(reference, files/dirs to check)
437    #
438    #   return 0 if any of the files/dirs are newer than
439    #   the reference file
440    #
441    #   EXAMPLE: if is_older_than a.out *.o ; then ...
442    is_older_than() {
443     local x=
444     local ref="$1"
445     shift
446    
447     for x in "$@"
448     do
449     [[ ${x} -nt ${ref} ]] && return 0
450    
451     if [[ -d ${x} ]]
452     then
453     is_older_than "${ref}" "${x}"/* && return 0
454     fi
455     done
456    
457     return 1
458    }

Legend:
Removed from v.71  
changed lines
  Added in v.931