blob: 98dde8b9720b3ed92f711feb2bb790f1c6aa2fff [file] [log] [blame]
st782s21a87612018-01-30 17:29:36 -05001#!/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
6hostip=""
7hostname=""
Kotta, Shireesha (sk434m)b75f35b2019-06-13 14:41:15 -04008BASE=/opt/apache-tomcat-8.0.37
st782s21a87612018-01-30 17:29:36 -05009while [ $# -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)b75f35b2019-06-13 14:41:15 -040024 -b|--base)
25 BASE="$2"
26 echo "$0: option -b value is $BASE"
27 shift # past argument
28 shift # past value
29 ;;
st782s21a87612018-01-30 17:29:36 -050030 *)
31 echo "$0: ignoring argument $key"
32 shift
33 ;;
34 esac
35done
36
37# Optionally add to /etc/hosts
38# Docker-compose supplies arguments ""
39if [ ${#hostip} -lt 3 -o ${#hostname} -lt 3 ]; then
40 echo "$0: values for IP (-i) and/or name (-n) are empty or short"
41else
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
51fi
52
st782s21a87612018-01-30 17:29:36 -050053if [ ! -d $BASE ] ; then
54 echo "$0: $BASE not found or not a directory"
55 exit 1
56fi
57echo "$0: Starting server from $BASE"
58LOGFILE=${BASE}/logs/catalina.out
59echo "`date`:<-------------------- Starting -------------------->" >> $LOGFILE
sa282waa9b3202018-07-25 13:25:43 -040060exec ${BASE}/bin/catalina.sh run 2>&1 | tee -a $LOGFILE