st782s | 21a8761 | 2018-01-30 17:29:36 -0500 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Starts the Apache-Tomcat web container. |
| 3 | # If arguments "-i ip.2.3.4" AND "-n name" are present, adds an entry to /etc/hosts; |
| 4 | # this was added as a workaround for missing DNS in the CSIT environment. |
| 5 | |
| 6 | hostip="" |
| 7 | hostname="" |
Kotta, Shireesha (sk434m) | b75f35b | 2019-06-13 14:41:15 -0400 | [diff] [blame] | 8 | BASE=/opt/apache-tomcat-8.0.37 |
st782s | 21a8761 | 2018-01-30 17:29:36 -0500 | [diff] [blame] | 9 | while [ $# -gt 0 ]; do |
| 10 | key="$1" |
| 11 | case $key in |
| 12 | -i|--ip) |
| 13 | hostip="$2" |
| 14 | echo "$0: option -i value is $hostip" |
| 15 | shift # past argument |
| 16 | shift # past value |
| 17 | ;; |
| 18 | -n|--name) |
| 19 | hostname="$2" |
| 20 | echo "$0: option -n value is $hostname" |
| 21 | shift # past argument |
| 22 | shift # past value |
| 23 | ;; |
Kotta, Shireesha (sk434m) | b75f35b | 2019-06-13 14:41:15 -0400 | [diff] [blame] | 24 | -b|--base) |
| 25 | BASE="$2" |
| 26 | echo "$0: option -b value is $BASE" |
| 27 | shift # past argument |
| 28 | shift # past value |
| 29 | ;; |
st782s | 21a8761 | 2018-01-30 17:29:36 -0500 | [diff] [blame] | 30 | *) |
| 31 | echo "$0: ignoring argument $key" |
| 32 | shift |
| 33 | ;; |
| 34 | esac |
| 35 | done |
| 36 | |
| 37 | # Optionally add to /etc/hosts |
| 38 | # Docker-compose supplies arguments "" |
| 39 | if [ ${#hostip} -lt 3 -o ${#hostname} -lt 3 ]; then |
| 40 | echo "$0: values for IP (-i) and/or name (-n) are empty or short" |
| 41 | else |
| 42 | echo "$0: using IP-name arguments $hostip $hostname" |
| 43 | grep $hostname /etc/hosts |
| 44 | ret_code=$? |
| 45 | if [ $ret_code != 0 ]; then |
| 46 | echo "$0: extending hosts with $hostname" |
| 47 | echo "$hostip $hostname" >> /etc/hosts |
| 48 | else |
| 49 | echo "$0: hosts already has $hostname" |
| 50 | fi |
| 51 | fi |
| 52 | |
st782s | 21a8761 | 2018-01-30 17:29:36 -0500 | [diff] [blame] | 53 | if [ ! -d $BASE ] ; then |
| 54 | echo "$0: $BASE not found or not a directory" |
| 55 | exit 1 |
| 56 | fi |
| 57 | echo "$0: Starting server from $BASE" |
| 58 | LOGFILE=${BASE}/logs/catalina.out |
| 59 | echo "`date`:<-------------------- Starting -------------------->" >> $LOGFILE |
sa282w | aa9b320 | 2018-07-25 13:25:43 -0400 | [diff] [blame] | 60 | exec ${BASE}/bin/catalina.sh run 2>&1 | tee -a $LOGFILE |