#!/bin/bash
# tomcat_port_changer.sh
usage() {
echo "apache-tomcat port changer"
echo "$0 <index> <server.xml>"
echo "ex)"
echo "$0 3 ./conf/server.xml : Port 8083 use"
exit 1
}
if [ $# -ne 2 ]; then
usage
fi
PORT1=$(expr 8080 + $1)
PORT2=$(expr 8443 + $1)
PORT3=$(expr 8009 + $1)
PORT4=$(expr 8005 + $1)
if ! [ -w $2 ]; then
usage
fi
echo "> index: $1"
echo "> file: $2"
sed -i "s/8080/${PORT1}/g" $2
sed -i "s/8443/${PORT2}/g" $2
sed -i "s/8009/${PORT3}/g" $2
sed -i "s/8005/${PORT4}/g" $2
