sleepctl 873 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. #set -e #(errexit) esce quando un comando ritorna un valore diverso da zero (non va bene per come è implementata la funzione monitor)
  3. set -u #tratta le variabili non definite come errori
  4. set -o pipefail #ritorna zero se tutto è andato a buon fine (di default guarda solo l'ultimo comando)
  5. command_parsed=0
  6. . functions
  7. . conf
  8. while getopts 'hms:k:' OPTION; do
  9. case "$OPTION" in
  10. m) #funzione monitor
  11. monitor
  12. ;;
  13. s) #funzione start
  14. node=$OPTARG
  15. if [ $node == '1' ];then
  16. start_1
  17. elif [ $node == '2' ];then
  18. start_2
  19. else
  20. start_node $node
  21. fi
  22. ;;
  23. k) #funzione kill
  24. node=$OPTARG
  25. if [ $node == '1' ];then
  26. kill_1
  27. elif [ $node == '2' ];then
  28. kill_2
  29. else
  30. kill_process $node
  31. fi
  32. ;;
  33. h)
  34. print_help
  35. ;;
  36. ?)
  37. print_usage
  38. exit 1
  39. ;;
  40. esac
  41. done
  42. if [ $command_parsed -eq 0 ]
  43. then
  44. print_usage
  45. fi