aoetools.init 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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: mountaoe
  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. if [ ! -c /dev/etherd/discover ]
  34. then
  35. echo "Missing devices under /dev/etherd/. Please run" >&2
  36. echo " aoe-mkdevs /dev/etherd" >&2
  37. echo "and try again."
  38. exit 1
  39. fi
  40. # We exit if the user do not want us to try this.
  41. if [ "$INTERFACES" = "none" ]
  42. then
  43. echo "not started."
  44. exit 0
  45. fi
  46. # Try to set up interfaces for discovery, if any.
  47. if [ ! -z "$INTERFACES" ]
  48. then
  49. aoe-interfaces $INTERFACES
  50. fi
  51. aoe-discover
  52. [ -f /etc/fstab ] || return
  53. #
  54. # Read through fstab line by line. If it contains /dev/etherd, set the flag
  55. # for mounting file systems over AoE.
  56. #
  57. exec 9<&0 </etc/fstab
  58. waitaoe=
  59. while read DEV MTPT FSTYPE OPTS REST
  60. do
  61. case "$OPTS" in
  62. noauto|*,noauto|noauto,*|*,noauto,*)
  63. continue
  64. ;;
  65. esac
  66. case "$DEV" in
  67. ""|\#*)
  68. continue
  69. ;;
  70. /dev/etherd/*)
  71. waitaoe="$waitaoe $MTPT"
  72. esac
  73. done
  74. exec 0<&9 9<&-
  75. if [ ! -z "$waitaoe" ]
  76. then
  77. echo
  78. fi
  79. for mountpt in $waitaoe; do
  80. echo "Mounting $mountpt..."
  81. mount $mountpt
  82. #log_action_begin_msg "Waiting for $mountpt"
  83. done
  84. }
  85. case "$1" in
  86. start|restart|reload|force-reload)
  87. echo -n "Starting $DESC: "
  88. do_start
  89. #echo "$NAME."
  90. ;;
  91. stop)
  92. #echo -n "Stopping $DESC: "
  93. #echo "$NAME."
  94. ;;
  95. *)
  96. N=/etc/init.d/$NAME
  97. echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
  98. exit 1
  99. ;;
  100. esac
  101. exit 0