Magellan Linux

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

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

branches/unlabeled-1.1.1/magellan-initscripts/etc/rc.d/init.d/functions revision 2 by niro, Mon Dec 13 22:52:07 2004 UTC trunk/magellan-initscripts/etc/rc.d/init.d/functions revision 1241 by niro, Fri Mar 11 17:13:32 2011 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    # $Id$
3    
4  # Begin $rc_base/init.d/functions - Run Level Control Functions  # Begin $rc_base/init.d/functions - Run Level Control Functions
5    
6  # Based on functions script from LFS-3.1 and earlier.  # Based on functions script from LFS-3.1 and earlier.
# Line 38  COLDEFAULT="\033[0m" Line 40  COLDEFAULT="\033[0m"
40    
41  COLOREDSTAR="${COLBLUE}(${COLGREEN}*${COLBLUE})${COLDEFAULT} "  COLOREDSTAR="${COLBLUE}(${COLGREEN}*${COLBLUE})${COLDEFAULT} "
42    
43  #location to save the started services  # location to save the started services
44  svcdir="/var/lib/init.d"  svcdir="/var/lib/init.d"
45  svclib="/lib/rcscripts"  svclib="/lib/rcscripts"
46  svcmount="no"  svcmount="no"
47  svcfstype="tmpfs"  svcfstype="tmpfs"
48  svcsize=1024  svcsize=1024
49    
50    rc_echo() { echo $@; }
51    rc_print() { rc_echo -e "${COLOREDSTAR}$@"; }
52    
53  # dummy function; needed if splashutils are not installed  # dummy function; needed if splashutils are not installed
54  splash() {  splash() { return 0; }
         return 0  
 }  
   
55    
56  #source splash functions if exists  # source splash functions if exists
57  [ -f /etc/init.d/splash-functions ] && source /etc/init.d/splash-functions  [ -f /etc/init.d/splash-functions ] && source /etc/init.d/splash-functions
58    
   
   
59  print_error_msg()  print_error_msg()
60  {  {
61   return 0   return 0
# Line 96  update_svcstatus() Line 95  update_svcstatus()
95   local SVCD_INITSCRIPT   local SVCD_INITSCRIPT
96   local x   local x
97    
   
98   #do this only if proc is mounted   #do this only if proc is mounted
99   [ ! -f /proc/mounts ] && return 0   [ ! -f /proc/mounts ] && return 0
100    
# Line 106  update_svcstatus() Line 104  update_svcstatus()
104   then   then
105   #check if statedir exists   #check if statedir exists
106   [ ! -d ${svcdir}/started ] && mkdir ${svcdir}/started   [ ! -d ${svcdir}/started ] && mkdir ${svcdir}/started
107    
108   #get real name of the initscript, not from the symlink   #get real name of the initscript, not from the symlink
109   if [ -L "$0" ]   if [ -L "$0" ]
110   then   then
# Line 135  update_svcstatus() Line 133  update_svcstatus()
133    
134  evaluate_retval()  evaluate_retval()
135  {  {
136   error_value=$?   local error_value="$1"
137     [[ -z ${error_value} ]] && error_value=$?
138    
139   if [ $error_value = 0 ]   if [[ ${error_value} = 0 ]]
140   then   then
141   print_status success   print_status success
142   else   else
143   print_status failure   print_status failure
144   fi   fi
145    
146   return $error_value   return ${error_value}
147  }  }
148    
149  print_status()  print_status()
# Line 285  reloadproc() Line 284  reloadproc()
284   else   else
285   signal=${2##-}   signal=${2##-}
286   signal=${signal##SIG}   signal=${signal##SIG}
   
287   fi   fi
288    
289   getpids $1   getpids $1
# Line 346  progressbar() Line 344  progressbar()
344   fi   fi
345  }  }
346    
347    kernel_version()
348    {
349     local KV="$(uname -r | cut -d- -f1)"
350     echo "${KV}"
351    }
352    
353  kernel_major_version()  kernel_major_version()
354  {  {
355   local KV   local KV
356   KV="$(uname -r|cut -d. -f1-2)"   KV="$(uname -r | cut -d. -f1-2)"
357   echo "${KV}"   echo "${KV}"
358  }  }
359    
360  dolisting()  dolisting()
361  {  {
362   local x=   local x=
363   local y=   local y=
# Line 387  dolisting() Line 391  dolisting()
391    
392   echo "${mylist}"   echo "${mylist}"
393  }  }
394    
395    # searches /proc/mounts for mounted fstypes (like ext3)
396    is_fstype_mounted()
397    {
398     local filesys
399     local i
400     filesys=$1
401    
402     i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f3)"
403     [[ ${i} != ${filesys} ]] && return 1
404    
405     return 0
406    }
407    
408    # searches /proc/mounts for mounted fs names (like udev, proc)
409    is_fs_mounted()
410    {
411     local filesys
412     local i
413     filesys=$1
414    
415     i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f1)"
416     [[ ${i} != ${filesys} ]] && return 1
417    
418     return 0
419    }
420    
421    # checks if kernel supports fs xy
422    kernel_supports_fs()
423    {
424     local filesys
425     local i
426     filesys=$1
427    
428     i="$(cat /proc/filesystems | grep ${filesys} | cut -d $'\t' -f2)"
429     [[ ${i} != ${filesys} ]] && return 1
430    
431     return 0
432    }
433    
434    # bool is_older_than(reference, files/dirs to check)
435    #
436    #   return 0 if any of the files/dirs are newer than
437    #   the reference file
438    #
439    #   EXAMPLE: if is_older_than a.out *.o ; then ...
440    is_older_than()
441    {
442     local x=
443     local ref="$1"
444     shift
445    
446     for x in "$@"
447     do
448     [[ ${x} -nt ${ref} ]] && return 0
449    
450     if [[ -d ${x} ]]
451     then
452     is_older_than "${ref}" "${x}"/* && return 0
453     fi
454     done
455    
456     return 1
457    }
458    
459    start_devicemanager() { touch /dev/.none; return 0; }
460    stop_devicemanager() { return 0; }

Legend:
Removed from v.2  
changed lines
  Added in v.1241