Guest User

Untitled

a guest
Dec 16th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.32 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # chkconfig: 2345 95 5
  4. # description: Virtual OpenCL (VCL) is a cluster platform that allows OpenCL applications
  5. #        : to transparently utilize many devices in a cluster,  as if all the devices
  6. #        : are on the local computer.
  7. #
  8. # vcl          Script to stop/start VCL
  9. #
  10. # Author:      epixoip
  11. # Original:    Amnon Shiloh
  12. ### BEGIN INIT INFO
  13. # Provides: VCL
  14. # Required-Start: $network
  15. # Should-Start:
  16. # Required-Stop:
  17. # Should-Stop:
  18. # Default-Start: 2 3 4 5
  19. # Default-Stop: 0 1 6
  20. # Short-Description: VCL
  21. # Description: VCL - Virtual OpenCL for combining the power of many remote GPUs
  22. ### END INIT INFO
  23. #
  24.  
  25.  
  26. check_retval()
  27. {
  28.     if test "$?" -eq 0; then
  29.         echo '  Ok.'
  30.     else
  31.         echo '  Failed!'
  32.     fi
  33. }
  34.  
  35.  
  36. check_proc()
  37. {
  38.     pidof $1 >/dev/null
  39.     return $?
  40. }
  41.  
  42.  
  43. kill_proc()
  44. {
  45.     if check_proc $1; then
  46.         killall $1
  47.         sleep 1
  48.  
  49.         if check_proc $1; then
  50.             killall -9 $1
  51.             sleep 2
  52.  
  53.             if check_proc $1; then
  54.                 return 1
  55.             else
  56.                 return 0
  57.             fi
  58.         else
  59.             return 0
  60.         fi
  61.     else
  62.         return 0
  63.     fi
  64. }
  65.  
  66.  
  67. stop_host()
  68. {
  69.     printf '    Killing broker: '
  70.  
  71.     kill_proc /sbin/broker
  72.     check_retval
  73. }
  74.  
  75.  
  76. stop_backend()
  77. {
  78.     printf '    Killing opencld: '
  79.  
  80.     kill_proc /sbin/opencld
  81.     check_retval
  82. }
  83.  
  84.  
  85. start_host()
  86. {
  87.     test -e /etc/vcl/is_host || return 0
  88.  
  89.     printf '    Starting broker: '
  90.  
  91.     if check_proc /sbin/broker; then
  92.         echo ' already running.'
  93.         return 1
  94.     fi
  95.  
  96.     if test -e /etc/vcl/nodes; then
  97.         args='-f/etc/vcl/nodes'
  98.     else
  99.         echo 'No compute nodes defined, will use only localhost!'
  100.         args='-llocalhost'
  101.     fi
  102.  
  103.     /sbin/broker $args
  104.     check_retval
  105. }
  106.  
  107.  
  108. start_backend()
  109. {
  110.     test -e /etc/vcl/is_back_end || return 0
  111.  
  112.     printf '    Starting opencld: '
  113.  
  114.     if check_proc /sbin/opencld; then
  115.         echo ' already running.'
  116.         return 1
  117.     fi
  118.  
  119.     /sbin/opencld
  120.     check_retval
  121. }
  122.  
  123.  
  124. case "$1" in
  125.     start)
  126.         echo 'Starting VCL...'
  127.         start_host
  128.         start_backend
  129.         ;;
  130.     stop)
  131.         echo 'Stopping VCL...'
  132.         stop_host
  133.         stop_backend
  134.         ;;
  135.     status)
  136.         if check_proc /sbin/broker; then
  137.             echo 'broker is running.'
  138.         else
  139.             echo 'broker is not running.'
  140.         fi
  141.  
  142.         if check_proc /sbin/opencld; then
  143.             echo 'opencld is running.'
  144.         else
  145.             echo 'opencld is not running.'
  146.         fi
  147.         ;;
  148.     restart|reload)
  149.         echo 'Restarting VCL...'
  150.         stop_host
  151.         stop_backend
  152.         start_host
  153.         start_backend
  154.         ;;
  155. esac
Add Comment
Please, Sign In to add comment