home *** CD-ROM | disk | FTP | other *** search
/ chilidog.highland.cc.ks.us / chilidog.highland.cc.ks.us.zip / chilidog.highland.cc.ks.us / backup / bradford.20120305.etc.tar.gz / bradford.20120305.etc.tar / etc / init.d / boot.md < prev    next >
Text File  |  2006-05-03  |  5KB  |  145 lines

  1. #!/bin/sh
  2. #
  3. #     SUSE system startup script for MD Raid autostart
  4. #     Copyright (C) 1995--2005  Kurt Garloff, SUSE / Novell Inc.
  5. #     Copyright (C) 2006  Marian Jancar, SUSE / Novell Inc.
  6. #          
  7. #     This library is free software; you can redistribute it and/or modify it
  8. #     under the terms of the GNU Lesser General Public License as published by
  9. #     the Free Software Foundation; either version 2.1 of the License, or (at
  10. #     your option) any later version.
  11. #                  
  12. #     This library is distributed in the hope that it will be useful, but
  13. #     WITHOUT ANY WARRANTY; without even the implied warranty of
  14. #     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. #     Lesser General Public License for more details.
  16. #      
  17. #     You should have received a copy of the GNU Lesser General Public
  18. #     License along with this library; if not, write to the Free Software
  19. #     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307,
  20. #     USA.
  21. #
  22. ### BEGIN INIT INFO
  23. # Provides:          boot.md
  24. # Required-Start:    boot.proc boot.udev
  25. # X-SUSE-Should-Start: boot.ibmsis boot.scsidev boot.multipath
  26. # Default-Start:     B
  27. # Default-Stop:
  28. # Short-Description: Multiple Device RAID
  29. # Description:       Start MD RAID
  30. #    RAID devices are virtual devices created from two or more real block devices.
  31. #    This allows multiple devices (typically disk drives or partitions there-of)
  32. #    to be combined into a single device to hold (for example) a single filesystem.
  33. #    Some RAID levels include redundancy and so can survive some degree of device failure.
  34. ### END INIT INFO
  35.  
  36. # Source LSB init functions
  37. # providing start_daemon, killproc, pidofproc, 
  38. # log_success_msg, log_failure_msg and log_warning_msg.
  39. # This is currently not used by UnitedLinux based distributions and
  40. # not needed for init scripts for UnitedLinux only. If it is used,
  41. # the functions from rc.status should not be sourced or used.
  42. #. /lib/lsb/init-functions
  43.  
  44. # Shell functions sourced from /etc/rc.status:
  45. #      rc_check         check and set local and overall rc status
  46. #      rc_status        check and set local and overall rc status
  47. #      rc_status -v     be verbose in local rc status and clear it afterwards
  48. #      rc_status -v -r  ditto and clear both the local and overall rc status
  49. #      rc_status -s     display "skipped" and exit with status 3
  50. #      rc_status -u     display "unused" and exit with status 3
  51. #      rc_failed        set local and overall rc status to failed
  52. #      rc_failed <num>  set local and overall rc status to <num>
  53. #      rc_reset         clear both the local and overall rc status
  54. #      rc_exit          exit appropriate to overall rc status
  55. #      rc_active        checks whether a service is activated by symlinks
  56. . /etc/rc.status
  57.  
  58. # Reset status of this service
  59. rc_reset
  60.  
  61. # Return values acc. to LSB for all commands but status:
  62. # 0      - success
  63. # 1       - generic or unspecified error
  64. # 2       - invalid or excess argument(s)
  65. # 3       - unimplemented feature (e.g. "reload")
  66. # 4       - user had insufficient privileges
  67. # 5       - program is not installed
  68. # 6       - program is not configured
  69. # 7       - program is not running
  70. # 8--199  - reserved (8--99 LSB, 100--149 distrib, 150--199 appl)
  71. # Note that starting an already running service, stopping
  72. # or restarting a not-running service as well as the restart
  73. # with force-reload (in case signaling is not supported) are
  74. # considered a success.
  75.  
  76. mdadm_BIN=/sbin/mdadm
  77. mdrun_BIN=/sbin/mdrun
  78. mdadm_CONFIG="/etc/mdadm.conf"
  79. mdadm_SYSCONFIG="/etc/sysconfig/mdadm"
  80.  
  81. # udev integration
  82. if [ -x /sbin/udevsettle ] ; then
  83.     [ -z "$MDADM_DEVICE_TIMEOUT" ] && MDADM_DEVICE_TIMEOUT=60
  84. else
  85.     MDADM_DEVICE_TIMEOUT=0
  86. fi
  87.  
  88. function _rc_exit {
  89.     [ "x$2" != x"" ] && echo -n $2
  90.     rc_failed $1
  91.     rc_status -v
  92.     rc_exit
  93. }
  94.  
  95. case "$1" in
  96.     start)
  97.     echo -n "Starting MD Raid "
  98.     
  99.     # Check for existence of needed config file and read it
  100.     [ -r $mdadm_SYSCONFIG ] || _rc_exit 6 "... $mdadm_SYSCONFIG not existing "
  101.  
  102.     # Read config
  103.     . $mdadm_SYSCONFIG
  104.     
  105.     [ "x$MDADM_CONFIG" != x"" ] && mdadm_CONFIG="$MDADM_CONFIG"
  106.  
  107.     # Check for missing binaries (stale symlinks should not happen)
  108.         [ -x $mdadm_BIN ] || _rc_exit 5 "... $mdadm_BIN not installed "
  109.     [ -x $mdrun_BIN ] || _rc_exit 5 "... $mdrun_BIN not installed "
  110.  
  111.     # Try to load md_mod
  112.     [ ! -f /proc/mdstat -a -x /sbin/modprobe ] && /sbin/modprobe -k md_mod 2>&1 | :
  113.     [ -f /proc/mdstat ] || _rc_exit 5 "... no MD support in kernel "
  114.  
  115.     # Wait for udev to settle
  116.     if [ "$MDADM_DEVICE_TIMEOUT" -gt 0 ] ; then
  117.         /sbin/udevsettle --timeout="$MDADM_DEVICE_TIMEOUT"
  118.     fi
  119.  
  120.     # Fallback to mdrun when $mdadm_CONFIG missing or mdadm exits with an error
  121.     [ "$BOOT_MD_USE_MDADM_CONFIG" = "yes" -a -s "$mdadm_CONFIG" ]
  122.     [ $? = 0 ] && { $mdadm_BIN -A -s -c $mdadm_CONFIG || rc_failed 1; }
  123.     [ $? = 0 ] || $mdrun_BIN
  124.  
  125.     # Remember status and be verbose
  126.     rc_status -v
  127.     ;;
  128.     stop)
  129.     echo -n "Shutting down MD Raid "
  130.  
  131.     # Remember status and be verbose
  132.     rc_status -v
  133.     ;;
  134.     status)
  135.     rc_failed 4
  136.     rc_status -v
  137.     ;;
  138.     *)
  139.     echo "Usage: $0 {start|stop|status}"
  140.     exit 1
  141.     ;;
  142. esac
  143. rc_exit
  144.