Magellan Linux

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

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

trunk/magellan-initscripts/etc/rc.d/init.d/functions revision 71 by niro, Tue Mar 15 19:07:56 2005 UTC trunk/initscripts/sysvinit/rc/functions revision 1893 by niro, Wed Aug 22 17:57:39 2012 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 17  KILLDELAY=3 Line 17  KILLDELAY=3
17    
18  COLUMNS=$(stty size)  COLUMNS=$(stty size)
19  COLUMNS=${COLUMNS##* }  COLUMNS=${COLUMNS##* }
20    if [[ -z ${COLUMNS} ]] || [[ ${COLUMNS} = 0 ]]
21    then
22     COLUMNS=80
23    fi
24  COL=$[ $COLUMNS - 10 ]  COL=$[ $COLUMNS - 10 ]
25  WCOL=$[ $COLUMNS - 30 ]  WCOL=$[ $COLUMNS - 30 ]
26  WWCOL=$[ $COLUMNS - 40 ]  WWCOL=$[ $COLUMNS - 40 ]
# Line 40  COLDEFAULT="\033[0m" Line 44  COLDEFAULT="\033[0m"
44    
45  COLOREDSTAR="${COLBLUE}(${COLGREEN}*${COLBLUE})${COLDEFAULT} "  COLOREDSTAR="${COLBLUE}(${COLGREEN}*${COLBLUE})${COLDEFAULT} "
46    
47  #location to save the started services  # location to save the started services
48  svcdir="/var/lib/init.d"  svcdir="/var/lib/init.d"
49  svclib="/lib/rcscripts"  svclib="/lib/rcscripts"
50  svcmount="no"  svcmount="no"
51  svcfstype="tmpfs"  svcfstype="tmpfs"
52  svcsize=1024  svcsize=1024
53    
54    rc_echo() { echo "$@"; }
55    rc_print() { rc_echo -e "${COLOREDSTAR}$@"; }
56    
57  # dummy function; needed if splashutils are not installed  # dummy function; needed if splashutils are not installed
58  splash() {  splash() { return 0; }
  return 0  
 }  
59    
60    # source splash functions if exists
 #source splash functions if exists  
61  [ -f /etc/init.d/splash-functions ] && source /etc/init.d/splash-functions  [ -f /etc/init.d/splash-functions ] && source /etc/init.d/splash-functions
62    
   
   
63  print_error_msg()  print_error_msg()
64  {  {
65   return 0   return 0
# Line 98  update_svcstatus() Line 99  update_svcstatus()
99   local SVCD_INITSCRIPT   local SVCD_INITSCRIPT
100   local x   local x
101    
   
102   #do this only if proc is mounted   #do this only if proc is mounted
103   [ ! -f /proc/mounts ] && return 0   [ ! -f /proc/mounts ] && return 0
104    
# 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    
149     if [[ ${SPLASH_VERBOSE_ON_ERRORS} = 1 ]]
150     then
151     splash "rc_verbose" "${runlevel}"
152     fi
153   fi   fi
154    
155   return $error_value   return ${error_value}
156  }  }
157    
158  print_status()  print_status()
# Line 201  print_status() Line 207  print_status()
207    
208  getpids()  getpids()
209  {  {
210   base=${1##*/}   local base=${1##*/}
211   pidlist=$(pidof -o $$ -o $PPID -x $base)   local opts
212     if [[ $(readlink /bin/pidof) = *busybox ]]
213     then
214     opts=""
215     else
216     opts="-x"
217     fi
218     pidlist=$(pidof -o $$ -o $PPID ${opts} $base)
219  }  }
220    
221  loadproc()  loadproc()
# Line 264  killproc() Line 277  killproc()
277   done   done
278    
279   base=${1##*/}   base=${1##*/}
280   if [ $failure = 0 ]; then rm -f /var/run/$base.pid; fi   if [ $failure = 0 ]; then rm -f /run/$base.pid; fi
281    
282   (exit $failure)   (exit $failure)
283   evaluate_retval   evaluate_retval
# Line 287  reloadproc() Line 300  reloadproc()
300   else   else
301   signal=${2##-}   signal=${2##-}
302   signal=${signal##SIG}   signal=${signal##SIG}
   
303   fi   fi
304    
305   getpids $1   getpids $1
# Line 324  statusproc() Line 336  statusproc()
336   then   then
337   echo "$base is running with Process ID(s) $pidlist"   echo "$base is running with Process ID(s) $pidlist"
338   else   else
339   if [ -s /var/run/$base.pid ]   if [ -s /run/$base.pid ]
340   then   then
341   echo "$1 is not running but /var/run/$base.pid exists"   echo "$1 is not running but /run/$base.pid exists"
342   return 1   return 1
343   else   else
344   echo "$1 is not running"   echo "$1 is not running"
# Line 348  progressbar() Line 360  progressbar()
360   fi   fi
361  }  }
362    
363    kernel_version()
364    {
365     local KV="$(uname -r | cut -d- -f1)"
366     echo "${KV}"
367    }
368    
369  kernel_major_version()  kernel_major_version()
370  {  {
371   local KV   local KV
372   KV="$(uname -r|cut -d. -f1-2)"   KV="$(uname -r | cut -d. -f1-2)"
373   echo "${KV}"   echo "${KV}"
374  }  }
375    
376  dolisting()  dolisting()
377  {  {
378   local x=   local x=
379   local y=   local y=
# Line 389  dolisting() Line 407  dolisting()
407    
408   echo "${mylist}"   echo "${mylist}"
409  }  }
410    
411    # searches /proc/mounts for mounted fstypes (like ext3)
412    is_fstype_mounted()
413    {
414     local filesys
415     local i
416     filesys=$1
417    
418     i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f3)"
419     [[ ${i} != ${filesys} ]] && return 1
420    
421     return 0
422    }
423    
424    # searches /proc/mounts for mounted fs names (like udev, proc)
425    is_fs_mounted()
426    {
427     local filesys
428     local i
429     filesys=$1
430    
431     i="$(cat /proc/mounts | grep ${filesys} | cut -d ' ' -f1)"
432     [[ ${i} != ${filesys} ]] && return 1
433    
434     return 0
435    }
436    
437    # checks if kernel supports fs xy
438    kernel_supports_fs()
439    {
440     local filesys
441     local i
442     filesys=$1
443    
444     i="$(cat /proc/filesystems | grep ${filesys} | cut -d $'\t' -f2)"
445     [[ ${i} != ${filesys} ]] && return 1
446    
447     return 0
448    }
449    
450    # bool is_older_than(reference, files/dirs to check)
451    #
452    #   return 0 if any of the files/dirs are newer than
453    #   the reference file
454    #
455    #   EXAMPLE: if is_older_than a.out *.o ; then ...
456    is_older_than()
457    {
458     local x=
459     local ref="$1"
460     shift
461    
462     for x in "$@"
463     do
464     [[ ${x} -nt ${ref} ]] && return 0
465    
466     if [[ -d ${x} ]]
467     then
468     is_older_than "${ref}" "${x}"/* && return 0
469     fi
470     done
471    
472     return 1
473    }
474    
475    # read /etc/os-release file
476    # read_os_release $item
477    read_os_release()
478    {
479     local NAME
480     local ID
481     local Version
482     local Version_ID
483     local PRETTY_NAME
484     local ANSI_COLOR
485     local CPE_NAME
486    
487     if [[ -f /etc/os-release ]]
488     then
489     source /etc/os-release
490    
491     case $1 in
492     name) echo "${NAME}" ;;
493     id) echo "${ID}" ;;
494     version) echo "${Version}" ;;
495     version_id) echo "${Version_ID}" ;;
496     pretty_name) echo "${PRETTY_NAME}" ;;
497     ansi_color) echo "${ANSI_COLOR}" ;;
498     cpe_name) echo "${CPE_NAME}" ;;
499     esac
500     fi
501    }
502    
503    start_devicemanager() { touch /dev/.none; return 0; }
504    stop_devicemanager() { return 0; }

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