ibmvscsis 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/sbin/openrc-run
  2. # Copyright 1999-2006 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. #
  5. # This file is tasked with testing for the existence of the ibmvscsis driver
  6. # and configuring the ibmvscsi server properly as indicated by the config file
  7. # located at /etc/ibmvscsis.conf
  8. #
  9. DRIVER=ibmvscsis
  10. SYSFS=/sys/bus/vio/drivers/ibmvscsis
  11. CONFIG=/etc/ibmvscsis.conf
  12. depend() {
  13. need logger
  14. provide ibmvscsis
  15. }
  16. checkconfig() {
  17. if [ ! -e ${CONFIG} ] ; then
  18. eerror " ${CONFIG} does not exist."
  19. return 1
  20. fi
  21. }
  22. checkmodule_load() {
  23. # The existence of $SYSFS indicates that the module has been loaded or that
  24. # the driver is at least built into the kernel.
  25. if [ ! -e ${SYSFS} ] ; then
  26. ewarn " Module ${DRIVER} is not loaded, attempting to load it"
  27. /sbin/modprobe ${DRIVER} &> /dev/null && return 0
  28. eerror " Failed to load module ${DRIVER}"
  29. return 1
  30. fi
  31. }
  32. checkmodule() {
  33. # The existence of $SYSFS indicates that the module has been loaded or that
  34. # the driver is at least built into the kernel.
  35. if [ ! -e ${SYSFS} ] ; then
  36. eerror " Module ${DRIVER} is not loaded"
  37. return 1
  38. fi
  39. }
  40. start() {
  41. ebegin "Starting vscsiadmin"
  42. checkconfig || return 1
  43. checkmodule_load || return 1
  44. /usr/sbin/vscsiadmin -start &> /dev/null
  45. eend $? "Failed to start vscsiadmin"
  46. }
  47. stop() {
  48. ebegin "Stopping vscsiadmin"
  49. checkmodule || return 1
  50. /usr/sbin/vscsiadmin -stop &> /dev/null
  51. eend $? "Failed to stop vscsiadmin"
  52. }
  53. status() {
  54. checkmodule || return 1
  55. /usr/sbin/vscsiadmin -status
  56. }
  57. restart() {
  58. stop
  59. start
  60. }