Advertisement
Guest User

nova-compute

a guest
Oct 17th, 2011
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. #!/bin/sh -e
  2. # upstart-job
  3. #
  4. # Symlink target for initscripts that have been converted to Upstart.
  5.  
  6. set -e
  7.  
  8. INITSCRIPT="$(basename "$0")"
  9. JOB="${INITSCRIPT%.sh}"
  10.  
  11. if [ "$JOB" = "upstart-job" ]; then
  12. if [ -z "$1" ]; then
  13. echo "Usage: upstart-job JOB COMMAND" 1>&2
  14. exit 1
  15. fi
  16.  
  17. JOB="$1"
  18. INITSCRIPT="$1"
  19. shift
  20. else
  21. if [ -z "$1" ]; then
  22. echo "Usage: $0 COMMAND" 1>&2
  23. exit 1
  24. fi
  25. fi
  26.  
  27. COMMAND="$1"
  28. shift
  29.  
  30.  
  31. if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then
  32. ECHO=echo
  33. else
  34. ECHO=:
  35. fi
  36.  
  37. $ECHO "Rather than invoking init scripts through /etc/init.d, use the service(8)"
  38. $ECHO "utility, e.g. service $INITSCRIPT $COMMAND"
  39.  
  40. case $COMMAND in
  41. status)
  42. $ECHO
  43. $ECHO "Since the script you are attempting to invoke has been converted to an"
  44. $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
  45. $COMMAND "$JOB"
  46. ;;
  47. start|stop)
  48. $ECHO
  49. $ECHO "Since the script you are attempting to invoke has been converted to an"
  50. $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
  51. if status "$JOB" 2>/dev/null | grep -q ' start/'; then
  52. RUNNING=1
  53. fi
  54. if [ -z "$RUNNING" ] && [ "$COMMAND" = "stop" ]; then
  55. exit 0
  56. elif [ -n "$RUNNING" ] && [ "$COMMAND" = "start" ]; then
  57. exit 0
  58. fi
  59. $COMMAND "$JOB"
  60. ;;
  61. restart)
  62. $ECHO
  63. $ECHO "Since the script you are attempting to invoke has been converted to an"
  64. $ECHO "Upstart job, you may also use the stop(8) and then start(8) utilities,"
  65. $ECHO "e.g. stop $JOB ; start $JOB. The restart(8) utility is also available."
  66. if status "$JOB" 2>/dev/null | grep -q ' start/'; then
  67. RUNNING=1
  68. fi
  69. if [ -n "$RUNNING" ] ; then
  70. stop "$JOB"
  71. fi
  72. start "$JOB"
  73. ;;
  74. reload|force-reload)
  75. $ECHO
  76. $ECHO "Since the script you are attempting to invoke has been converted to an"
  77. $ECHO "Upstart job, you may also use the reload(8) utility, e.g. reload $JOB"
  78. reload "$JOB"
  79. ;;
  80. *)
  81. $ECHO
  82. $ECHO "The script you are attempting to invoke has been converted to an Upstart" 1>&2
  83. $ECHO "job, but $COMMAND is not supported for Upstart jobs." 1>&2
  84. exit 1
  85. esac
  86.  
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement