#!/bin/bash # Rewritten for the new Docker-based server: Tomcat runs under supervisord # inside the app container, not as a real /etc/init.d/tomcat8 service like on # the old EC2 host. start/stop/restart go through the "service" shim the # Dockerfile installs (sportrum-ansible's files/app/service-shim.sh), already # proven working this session (`sudo service tomcat restart` -> "tomcat: # stopped" / "tomcat: started"). status queries supervisorctl directly # instead, since its output format is well-defined and doesn't depend on # what commands the shim itself happens to support. # # Kept as a drop-in replacement on purpose: upgrade.sh and restart.sh each # grep this script's "status" output for a different literal string # ("tomcat8 is stopped" vs "not running") depending on which one calls it. # Both substrings are included below whenever tomcat isn't running, so # neither caller needs to change. # # JAVA_HOME/JAVA_OPTS from the old version are dropped: the container's base # image (eclipse-temurin) already sets JAVA_HOME itself, and the JAVA_OPTS # line here was commented out (inactive) in the original anyway. If real # JAVA_OPTS are ever needed, set them in the container's own environment # (docker-compose.yml.j2's "environment:" block for the app service) rather # than here. cmd=$1 case "$cmd" in status) raw=$(sudo supervisorctl status tomcat) if echo "$raw" | grep -q "RUNNING"; then echo "tomcat8 is running: $raw" else echo "tomcat8 is stopped, not running: $raw" fi ;; start|stop|restart) sudo service tomcat "$cmd" ;; *) echo "Unknown command: $cmd" >&2 exit 1 ;; esac