geoserver_deb 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. # Author: Lennart Jütte <lenn@rtjuette.de>
  11. # Geoserver configuration - use /etc/default/geoserver to override these vars
  12. # user that shall run GeoServer
  13. USER=geoserver
  14. GEOSERVER_DATA_DIR=/home/$USER/data_dir
  15. GEOSERVER_HOME=/home/$USER/geoserver
  16. PATH=/usr/sbin:/usr/bin:/sbin:/bin
  17. DESC="GeoServer daemon"
  18. NAME=geoserver
  19. JAVA_HOME=/usr/lib/jvm/java-6-sun
  20. JAVA_OPTS="-Xms128m -Xmx512m"
  21. PIDFILE=/var/run/$NAME.pid
  22. SCRIPTNAME=/etc/init.d/$NAME
  23. # Read configuration variable file if it is present
  24. [ -r /etc/default/$NAME ] && . /etc/default/$NAME
  25. DAEMON="$JAVA_HOME/bin/java"
  26. DAEMON_ARGS="$JAVA_OPTS $DEBUG_OPTS -DGEOSERVER_DATA_DIR=$GEOSERVER_DATA_DIR -Djava.awt.headless=true -jar start.jar"
  27. # Load the VERBOSE setting and other rcS variables
  28. [ -f /etc/default/rcS ] && . /etc/default/rcS
  29. # Define LSB log_* functions.
  30. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
  31. . /lib/lsb/init-functions
  32. do_start(){
  33. # Return
  34. # 0 if daemon has been started
  35. # 1 if daemon was already running
  36. # 2 if daemon could not be started
  37. start-stop-daemon --start --pidfile $PIDFILE --make-pidfile \
  38. --chuid $USER --chdir $GEOSERVER_HOME \
  39. -b --test --exec $DAEMON -- $DAEMON_ARGS > /dev/null \
  40. || return 1
  41. start-stop-daemon --start --pidfile $PIDFILE --make-pidfile \
  42. --chuid $USER --chdir $GEOSERVER_HOME \
  43. -b --exec $DAEMON -- $DAEMON_ARGS \
  44. || return 2
  45. }
  46. do_stop(){
  47. # Return
  48. # 0 if daemon has been stopped
  49. # 1 if daemon was already stopped
  50. # 2 if daemon could not be stopped
  51. # other if a failure occurred
  52. start-stop-daemon --stop --pidfile $PIDFILE \
  53. --user $USER \
  54. --retry=TERM/30/KILL/5
  55. RETVAL="$?"
  56. [ "$RETVAL" = 2 ] && return 2
  57. # Many daemons don't delete their pidfiles when they exit.
  58. rm -f $PIDFILE
  59. return "$RETVAL"
  60. }
  61. case "$1" in
  62. start)
  63. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  64. do_start
  65. case "$?" in
  66. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  67. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  68. esac
  69. ;;
  70. stop)
  71. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  72. do_stop
  73. case "$?" in
  74. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  75. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  76. esac
  77. ;;
  78. restart|force-reload)
  79. log_daemon_msg "Restarting $DESC" "$NAME"
  80. do_stop
  81. case "$?" in
  82. 0|1)
  83. do_start
  84. case "$?" in
  85. 0) log_end_msg 0 ;;
  86. 1) log_end_msg 1 ;; # Old process is still running
  87. *) log_end_msg 1 ;; # Failed to start
  88. esac
  89. ;;
  90. *)
  91. # Failed to stop
  92. log_end_msg 1
  93. ;;
  94. esac
  95. ;;
  96. *)
  97. #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  98. echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
  99. exit 3
  100. ;;
  101. esac
  102. :