null JETTY_LOG_DIR=/var/log echo "JETTY_LOG_DIR not set, using default ${JETTY_LOG_DIR}" fi
test -f "${JAVA_CMD}" || exit 0 test -d "${JETTY_HOME}" || exit 0
rotate_logs() { if test -f ${JETTY_LOG_DIR}/jetty_bootstart_04 then rm ${JETTY_LOG_DIR}/jetty_bootstart_04 fi if test -f ${JETTY_LOG_DIR}/jetty_bootstart_03 then mv ${JETTY_LOG_DIR}/jetty_bootstart_03 ${JETTY_LOG_DIR}/jetty_bootstart_04 fi if test -f ${JETTY_LOG_DIR}/jetty_bootstart_02 then mv ${JETTY_LOG_DIR}/jetty_bootstart_02 ${JETTY_LOG_DIR}/jetty_bootstart_03 fi if test -f ${JETTY_LOG_DIR}/jetty_bootstart_01 then mv ${JETTY_LOG_DIR}/jetty_bootstart_01 ${JETTY_LOG_DIR}/jetty_bootstart_02 fi if test -f ${JETTY_LOG_DIR}/jetty_bootstart then mv ${JETTY_LOG_DIR}/jetty_bootstart ${JETTY_LOG_DIR}/jetty_bootstart_01 fi }
kill_jetty() {
- Guarantee jetty exits
jetty_pid="" for p in `ps -fC java | grep "$SCRIPTNAME" | tr -s " " | cut -f2 -d" "` do jetty_pid="$jetty_pid $p" done
if test -n "$jetty_pid" then
- Grace
sleep 5 kill -4 $jetty_pid >/dev/null 2>&1 sleep 3 kill -9 $jetty_pid >/dev/null 2>&1 fi }
startJetty() { gprintf "Starting Jetty Server: " rotate_logs sudo -u $JETTY_USER nohup $JAVA_CMD $JAVA_OPTS -Djetty.home=${JETTY_HOME} -jar ${JETTY_HOME}/start.jar ${JETTY_XML_FILE} > ${JETTY_LOG_DIR}/jetty_bootstart 2>&1 & success echo }
stopJetty() { gprintf "Stopping Jetty Server: " sudo -u $JETTY_USER $JAVA_CMD $JAVA_OPTS -Djetty.home=${JETTY_HOME} -jar ${JETTY_HOME}/stop.jar ${JETTY_XML_FILE} > ${JETTY_LOG_DIR}/jetty_bootstop 2>&1 kill_jetty success echo }
- Set umask for public read of created files
umask 0022
- set the TZ for java logging
- some java/unix combos don't understand Daylight Savings Time
if test -z "${TZ}" then if test -f /etc/timezone then TZ="`cat /etc/timezone`" export TZ elif test -L /etc/localtime then
- Symlink (RedHat style)
TZ="`ls -l /etc/localtime | sed -e 's%..*/usr/share/zoneinfo/%%g'`" export TZ elif test -f /etc/localtime then
- Maybe it's a hardlink (SuSE Linux style)
tz_inode=`ls -i /etc/localtime | cut -f1 -d"/"` TZ="`find /usr/share/zoneinfo -inum $tz_inode -print | sed -n 1p | sed -e 's%/usr/share/zoneinfo/%%g'`" export TZ fi fi
case "$1" in start) startJetty ;; stop) stopJetty ;; restart|force-reload) stopJetty startJetty ;; *) gprintf "Usage: /etc/init.d/${SCRIPTNAME} {start|stop|restart|force-reload}" >&2 exit 1 ;; esac
exit 0