Guest User

Untitled

a guest
Mar 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. #!/bin/sh
  2. # /etc/init.d/metabase
  3. ### BEGIN INIT INFO
  4. # Provides: Metabase
  5. # Required-Start: $local_fs $network $named $time $syslog
  6. # Required-Stop: $local_fs $network $named $time $syslog
  7. # Default-Start: 2 3 4 5
  8. # Default-Stop: 0 1 6
  9. # Description: Metabase analytics and intelligence platform
  10. ### END INIT INFO
  11.  
  12. # where is the Metabase jar located?
  13. METABASE=/opt/metabase/metabase.jar
  14.  
  15. # where will our environment variables be stored?
  16. METABASE_CONFIG=/etc/default/metabase
  17.  
  18. # which (unprivileged) user should we run Metabase as?
  19. RUNAS=metabase
  20.  
  21. # where should we store the pid/log files?
  22. PIDFILE=/var/run/metabase.pid
  23. LOGFILE=/var/log/metabase.log
  24.  
  25. start() {
  26. # ensure we only run 1 Metabase instance
  27. if [ -f "$PIDFILE" ] && kill -0 $(cat "$PIDFILE"); then
  28. echo 'Metabase already running' >&2
  29. return 1
  30. fi
  31. echo 'Starting Metabase...' >&2
  32. # execute the Metabase jar and send output to our log
  33. local CMD="nohup java -jar \"$METABASE\" &> \"$LOGFILE\" & echo \$!"
  34. # load Metabase config before we start so our env vars are available
  35. . "$METABASE_CONFIG"
  36. # run our Metabase cmd as unprivileged user
  37. su -c "$CMD" $RUNAS > "$PIDFILE"
  38. echo 'Metabase started.' >&2
  39. }
  40.  
  41. stop() {
  42. # ensure Metabase is running
  43. if [ ! -f "$PIDFILE" ] || ! kill -0 $(cat "$PIDFILE"); then
  44. echo 'Metabase not running' >&2
  45. return 1
  46. fi
  47. echo 'Stopping Metabase ...' >&2
  48. # send Metabase TERM signal
  49. kill -15 $(cat "$PIDFILE") && rm -f "$PIDFILE"
  50. echo 'Metabase stopped.' >&2
  51. }
  52.  
  53. uninstall() {
  54. echo -n "Are you really sure you want to uninstall Metabase? That cannot be undone. [yes|No] "
  55. local SURE
  56. read SURE
  57. if [ "$SURE" = "yes" ]; then
  58. stop
  59. rm -f "$PIDFILE"
  60. rm -f "$METABASE_CONFIG"
  61. # keep logfile around
  62. echo "Notice: log file is not be removed: '$LOGFILE'" >&2
  63. update-rc.d -f metabase remove
  64. rm -fv "$0"
  65. fi
  66. }
  67.  
  68. case "$1" in
  69. start)
  70. start
  71. ;;
  72. stop)
  73. stop
  74. ;;
  75. uninstall)
  76. uninstall
  77. ;;
  78. retart)
  79. stop
  80. start
  81. ;;
  82. *)
  83. echo "Usage: $0 {start|stop|restart|uninstall}"
  84. esac
Add Comment
Please, Sign In to add comment