You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
1.8 KiB

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: fuse
  4. # Required-Start:
  5. # Should-Start: udev
  6. # Required-Stop:
  7. # Default-Start: S
  8. # Default-Stop:
  9. # Short-Description: Start and stop fuse.
  10. # Description: Load the fuse module and mount the fuse control
  11. # filesystem.
  12. ### END INIT INFO
  13. set -e
  14. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  15. MOUNTPOINT=/sys/fs/fuse/connections
  16. # Gracefully exit if the package has been removed.
  17. which fusermount &>/dev/null || exit 5
  18. case "$1" in
  19. start|restart|force-reload)
  20. if ! grep -qw fuse /proc/filesystems; then
  21. echo -n "Loading fuse module"
  22. if ! modprobe fuse >/dev/null 2>&1; then
  23. echo " failed!"
  24. exit 1
  25. else
  26. echo "."
  27. fi
  28. else
  29. echo "Fuse filesystem already available."
  30. fi
  31. if grep -qw fusectl /proc/filesystems && \
  32. ! grep -qw $MOUNTPOINT /proc/mounts; then
  33. echo -n "Mounting fuse control filesystem"
  34. if ! mount -t fusectl fusectl $MOUNTPOINT >/dev/null 2>&1; then
  35. echo " failed!"
  36. exit 1
  37. else
  38. echo "."
  39. fi
  40. else
  41. echo "Fuse control filesystem already available."
  42. fi
  43. ;;
  44. stop)
  45. if ! grep -qw fuse /proc/filesystems; then
  46. echo "Fuse filesystem not loaded."
  47. exit 7
  48. fi
  49. if grep -qw $MOUNTPOINT /proc/mounts; then
  50. echo -n "Unmounting fuse control filesystem"
  51. if ! umount $MOUNTPOINT >/dev/null 2>&1; then
  52. echo " failed!"
  53. else
  54. echo "."
  55. fi
  56. else
  57. echo "Fuse control filesystem not mounted."
  58. fi
  59. if grep -qw "^fuse" /proc/modules; then
  60. echo -n "Unloading fuse module"
  61. if ! rmmod fuse >/dev/null 2>&1; then
  62. echo " failed!"
  63. else
  64. echo "."
  65. fi
  66. else
  67. echo "Fuse module not loaded."
  68. fi
  69. ;;
  70. status)
  71. echo -n "Checking fuse filesystem"
  72. if ! grep -qw fuse /proc/filesystems; then
  73. echo " not available."
  74. exit 3
  75. else
  76. echo " ok."
  77. fi
  78. ;;
  79. *)
  80. echo "Usage: $0 {start|stop|restart|force-reload|status}"
  81. exit 1
  82. ;;
  83. esac
  84. exit 0