sportrum-deploy/upgrade.sh
Claude 54bfeb73e7
Import existing manual deploy scripts as a starting point
These are the scripts currently run by hand on the old EC2 server to do a
full upgrade (safe storeall handshake, backups, explode WAR, run the
manager schema-migration tool, restart Tomcat). Committed as-is for now to
review and refactor from, except tomcat_ctl.sh, which is already rewritten
to control Tomcat via the new Docker container's supervisord (through the
"service" shim) instead of the old host's /etc/init.d/tomcat8, since that
service doesn't exist there. Kept as a drop-in replacement: the "status"
output still contains both literal substrings upgrade.sh and restart.sh
each grep for, so neither caller needed to change yet.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tj4SF2BGFxgoRYrCAzNpDb
2026-09-29 17:04:18 +00:00

57 lines
1.1 KiB
Bash

#!/bin/bash
. ./upgrade-funs.sh
action="reboot"
pid=$$
backup_sql="true"
backup_war="true"
storeonly="false"
while getopts "fsw" option
do
case $option in
f)
backup_sql="false"
backup_war="false"
;;
w)
backup_sql="false"
;;
s)
storeonly="true"
;;
?)
usage
exit
;;
esac
done
shift $(($OPTIND - 1))
if [ "x$1" != "x" ]; then
action=$1;
fi
running=$(./tomcat_ctl.sh status | grep "tomcat8 is stopped")
if [ "x$running" == "x" ]; then
printf "Call server command storeall.."; sleep 2
runcmd result
if [ "x$result" == "xsuccess" ]
then
echo " done!"
else
echo " failed! exiting..."
exit 1
fi
echo "Stopping tomcat.."; sleep 2
./tomcat_ctl.sh stop
else
echo "Tomcat is not running!"
fi
if [ $storeonly != "true" ]; then
runcmds=$(cat upgrade-cmds.sh)
sudo su - sportrum -c "backup_sql=$backup_sql; backup_war=$backup_war; ${runcmds}"
else
echo "Skipping upgrade commands, store only mode"
fi
if [ $action == "reboot" ]; then
echo "Starting tomcat..."; sleep 2
./tomcat_ctl.sh start
fi