7d3a8ada06be92bf14f3471fa7c4aeacd8b10255
[portal.git] / deliveries / start-apps-cmd.sh
1 #!/bin/sh
2 # Starts the Apache-Tomcat web container with the Portal, EPSDK and DMaaP BC web apps.
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=""
8 while [ $# -gt 0 ]; do
9     key="$1"
10     case $key in
11         -i|--ip)
12         hostip="$2"
13         shift # past argument
14         shift # past value
15         ;;
16         -n|--name)
17         hostname="$2"
18         shift # past argument
19         shift # past value
20         ;;
21         *)
22         echo "$0: ignoring argument $key"
23         shift
24         ;;
25     esac
26 done
27
28 # Optionally add to /etc/hosts
29 if [ -z "${hostip}" -o -z "${hostname}" ]; then
30     echo "$0: Arguments for IP and name not found, continuing."
31 else
32     echo "$0: Using IP-name arguments $hostip $hostname"
33     grep $hostname /etc/hosts
34     ret_code=$?
35     if [ $ret_code != 0 ]; then
36         echo "$hostip $hostname" >> /etc/hosts
37     fi
38 fi
39
40 BASE=/opt/apache-tomcat-8.0.37
41 if [ ! -d $BASE ] ; then
42     echo "$0: $BASE not found or not a directory"
43     exit 1
44 fi
45 echo "$0: Starting server from $BASE"
46 LOGFILE=${BASE}/logs/catalina.out
47 echo "`date`:<--------------------    Starting     -------------------->" >> $LOGFILE
48 exec ${BASE}/bin/catalina.sh run  2>&1 | tee -a $LOGFILE