Guest User

Untitled

a guest
Jan 16th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.46 KB | None | 0 0
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: geoserver
  4. # Required-Start: $local_fs $remote_fs
  5. # Required-Stop: $local_fs $remote_fs
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: S 0 1 6
  8. # Short-Description: GeoServer OGC server
  9. ### END INIT INFO
  10.  
  11. # Author: Lennart Jütte <lenn@rtjuette.de>
  12.  
  13. # Geoserver configuration - use /etc/default/geoserver to override these vars
  14. # user that shall run GeoServer
  15. USER=ubuntu
  16. GEOSERVER_DATA_DIR=/var/www/geoserver/data_dir
  17. GEOSERVER_HOME=/var/www/geoserver
  18.  
  19. PATH=/usr/sbin:/usr/bin:/sbin:/bin
  20. DESC="GeoServer daemon"
  21. NAME=geoserver
  22. JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
  23. JAVA_OPTS="-Xms128m -Xmx512m"
  24. PIDFILE=/var/run/$NAME.pid
  25. SCRIPTNAME=/etc/init.d/$NAME
  26.  
  27. # Read configuration variable file if it is present
  28. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  29.  
  30. DAEMON="$JAVA_HOME/bin/java"
  31. DAEMON_ARGS="$JAVA_OPTS $DEBUG_OPTS -DGEOSERVER_DATA_DIR=$GEOSERVER_DATA_DIR -Djava.awt.headless=true -jar start.jar"
  32.  
  33. # Load the VERBOSE setting and other rcS variables
  34. [ -f /etc/default/rcS ] && . /etc/default/rcS
  35.  
  36. # Define LSB log_* functions.
  37. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
  38. . /lib/lsb/init-functions
  39.  
  40. do_start(){
  41.  
  42. # Return
  43. # 0 if daemon has been started
  44. # 1 if daemon was already running
  45. # 2 if daemon could not be started
  46.  
  47. start-stop-daemon --start --pidfile $PIDFILE --make-pidfile \
  48. --chuid $USER --chdir $GEOSERVER_HOME \
  49. -b --test --exec $DAEMON -- $DAEMON_ARGS > /dev/null \
  50. || return 1
  51.  
  52. start-stop-daemon --start --pidfile $PIDFILE --make-pidfile \
  53. --chuid $USER --chdir $GEOSERVER_HOME \
  54. -b --exec $DAEMON -- $DAEMON_ARGS \
  55. || return 2
  56. }
  57.  
  58. do_stop(){
  59.  
  60. # Return
  61. # 0 if daemon has been stopped
  62. # 1 if daemon was already stopped
  63. # 2 if daemon could not be stopped
  64. # other if a failure occurred
  65.  
  66. start-stop-daemon --stop --pidfile $PIDFILE \
  67. --user $USER \
  68. --retry=TERM/30/KILL/5
  69.  
  70. RETVAL="$?"
  71. [ "$RETVAL" = 2 ] && return 2
  72.  
  73. # Many daemons don't delete their pidfiles when they exit.
  74. rm -f $PIDFILE
  75. return "$RETVAL"
  76.  
  77. }
  78.  
  79. case "$1" in
  80. start)
  81. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  82. do_start
  83. case "$?" in
  84. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  85. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  86. esac
  87. ;;
  88. stop)
  89. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  90. do_stop
  91. case "$?" in
  92. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  93. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  94. esac
  95. ;;
  96. restart|force-reload)
  97. log_daemon_msg "Restarting $DESC" "$NAME"
  98. do_stop
  99. case "$?" in
  100. 0|1)
  101. do_start
  102. case "$?" in
  103. 0) log_end_msg 0 ;;
  104. 1) log_end_msg 1 ;; # Old process is still running
  105. *) log_end_msg 1 ;; # Failed to start
  106. esac
  107. ;;
  108. *)
  109. # Failed to stop
  110. log_end_msg 1
  111. ;;
  112. esac
  113. ;;
  114. *)
  115. #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  116. echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
  117. exit 3
  118. ;;
  119. esac
  120.  
  121. :
Add Comment
Please, Sign In to add comment