aoetools.init 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #! /bin/sh
  2. #
  3. # Based on a example file to build /etc/init.d/ scripts,
  4. # written by Miquel van Smoorenburg <miquels@cistron.nl>
  5. # and later modified by Ian Murdock <imurdock@gnu.ai.mit.edu>.
  6. #
  7. # Also based on init script mountnfs.sh from initscripts package.
  8. #
  9. # Modified for aoetools by David Martínez Moreno <ender@debian.org>.
  10. #
  11. ### BEGIN INIT INFO
  12. # Provides: aoe
  13. # Required-Start: $local_fs $network
  14. # Required-Stop: $local_fs $network
  15. # Should-Start:
  16. # Default-Start: S
  17. # Default-Stop: 0 6
  18. # Short-Description: Begin AoE discovery and mount related filesystems.
  19. # Description: Begin AoE discovery and mount filesystems residing
  20. # on AoE volumes.
  21. ### END INIT INFO
  22. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  23. NAME=aoetools
  24. DESC="AoE devices discovery and mounting AoE filesystems"
  25. [ -f /etc/default/rcS ] && . /etc/default/rcS
  26. . /lib/lsb/init-functions
  27. # Include aoetools defaults if available
  28. if [ -f /etc/default/aoetools ] ; then
  29. . /etc/default/aoetools
  30. fi
  31. set -e
  32. do_start() {
  33. # We exit if the user do not want us to try this.
  34. if [ "$INTERFACES" = "none" ]
  35. then
  36. echo "not started."
  37. exit 0
  38. fi
  39. # Usually aoe is a module, so we will try to load it.
  40. # Also, if udev is being used, the /dev/etherd devices
  41. # are not created until aoe module insertion.
  42. modprobe aoe >/dev/null 2>&1 || true
  43. if [ ! -c /dev/etherd/discover ]
  44. then
  45. echo "Missing devices under /dev/etherd/. Please run" >&2
  46. echo " aoe-mkdevs /dev/etherd" >&2
  47. echo "and try again."
  48. exit 1
  49. fi
  50. # Try to set up interfaces for discovery, if any.
  51. if [ ! -z "$INTERFACES" ]
  52. then
  53. aoe-interfaces $INTERFACES
  54. fi
  55. aoe-discover
  56. [ -f /etc/fstab ] || return
  57. #
  58. # Read through fstab line by line. If it contains /dev/etherd, set the flag
  59. # for mounting file systems over AoE.
  60. #
  61. exec 9<&0 </etc/fstab
  62. waitaoe=
  63. while read DEV MTPT FSTYPE OPTS REST
  64. do
  65. case "$OPTS" in
  66. noauto|*,noauto|noauto,*|*,noauto,*)
  67. continue
  68. ;;
  69. esac
  70. case "$DEV" in
  71. ""|\#*)
  72. continue
  73. ;;
  74. /dev/etherd/*)
  75. waitaoe="$waitaoe $MTPT"
  76. esac
  77. done
  78. exec 0<&9 9<&-
  79. if [ ! -z "$waitaoe" ]
  80. then
  81. echo
  82. fi
  83. for mountpt in $waitaoe; do
  84. echo "Mounting $mountpt..."
  85. mount $mountpt
  86. #log_action_begin_msg "Waiting for $mountpt"
  87. done
  88. }
  89. case "$1" in
  90. start|restart|reload|force-reload)
  91. echo -n "Starting $DESC: "
  92. do_start
  93. #echo "$NAME."
  94. ;;
  95. stop)
  96. #echo -n "Stopping $DESC: "
  97. #echo "$NAME."
  98. ;;
  99. *)
  100. N=/etc/init.d/$NAME
  101. echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
  102. exit 1
  103. ;;
  104. esac
  105. exit 0