home *** CD-ROM | disk | FTP | other *** search
/ ftp.comtrol.com / 2014.07.ftp.comtrol.com.tar / ftp.comtrol.com / rport_express / diag / userdiag-2.07.iso / isolinux / initram.igz / initram / lib / udev / hotplug.functions < prev    next >
Text File  |  2013-11-05  |  1KB  |  62 lines

  1. # Setup and shell utility functions for use in hotplug agents.
  2. # vim: syntax=sh
  3. #
  4. # This program is free software; you can redistribute it and/or modify it
  5. # under the terms of the GNU General Public License as published by the
  6. # Free Software Foundation version 2 of the License.
  7.  
  8. if [ "$UDEV_LOG" ] && [ "$UDEV_LOG" -ge 7 ]; then
  9.     DEBUG=yes
  10. fi
  11.  
  12. PATH='/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin'
  13.  
  14. [ -e /etc/default/hotplug ] && . /etc/default/hotplug
  15.  
  16.  
  17. if [ -x /usr/bin/logger ]; then
  18.     LOGGER=/usr/bin/logger
  19. elif [ -x /bin/logger ]; then
  20.     LOGGER=/bin/logger
  21. else
  22.     unset LOGGER
  23. fi
  24.  
  25. # for diagnostics
  26. if [ -t 1 -a -z "$LOGGER" ] || [ ! -e '/dev/log' ]; then
  27.     mesg() {
  28.         echo "$@" >&2
  29.     }
  30. elif [ -t 1 ]; then
  31.     mesg() {
  32.         echo "$@"
  33.         $LOGGER -t "${0##*/}[$$]" "$@"
  34.     }
  35. else
  36.     mesg() {
  37.         $LOGGER -t "${0##*/}[$$]" "$@"
  38.     }
  39. fi
  40.  
  41. debug_mesg() {
  42.     [ -z "$DEBUG" -o "$DEBUG" = no ] && return 0
  43.     mesg "$@"
  44. }
  45.  
  46. wait_for_file() {
  47.     local file=$1
  48.     local timeout=$2
  49.     [ "$timeout" ] || timeout=120
  50.  
  51.     local count=$timeout
  52.     while [ $count != 0 ]; do
  53.         [ -e "$file" ] && return 0
  54.         sleep 1
  55.         count=$(($count - 1))
  56.     done
  57.  
  58.     mesg "$file did not appear before the timeout!"
  59.     exit 1
  60. }
  61.  
  62.