Replacing att.com namespace
[dmaap/datarouter.git] / datarouter-prov / src / main / resources / misc / drtrprov
1 #!/bin/bash
2 # ============LICENSE_START=======================================================
3 # org.onap.dmaap
4 # ================================================================================
5 # Copyright © 2018 AT&T Intellectual Property. All rights reserved.
6 # ================================================================================
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 # ============LICENSE_END=========================================================
19 #
20 # ECOMP is a trademark and service mark of AT&T Intellectual Property.
21
22
23 umask 0022
24
25 JAVA_HOME=/opt/java/jdk/jdk180
26 JAVA_OPTS="-Xms2G -Xmx8G"
27 TZ=GMT0
28 PATH=$JAVA_HOME/bin:/bin:/usr/bin
29 CLASSPATH=`echo /opt/app/datartr/etc /opt/app/datartr/lib/*.jar | tr ' ' ':'`
30 export CLASSPATH JAVA_HOME JAVA_OPTS TZ PATH
31
32 pids() {
33         pgrep -u datartr -f provisioning.Main
34 }
35
36 start() {
37         ID=`id -n -u`
38         GRP=`id -n -g`
39         if [ "$ID" != "root" ]
40         then
41                 echo drtrprov must be started as user datartr not $ID
42                 exit 1
43         fi
44 #  if [ "$GRP" != "datartr" ]
45 #       then
46 #               echo drtrprov must be started as group datartr not $GRP
47 #               exit 1
48 #       fi  
49 #       cd /opt/app/datartr
50 #       if etc/havecert
51 #       then
52 #               echo >/dev/null
53 #       else
54 #               echo No certificate file available.  Cannot start
55 #               exit 0
56 #       fi
57         if [ "`pgrep -u mysql mysqld`" = "" ]
58         then
59                 echo MySQL is not running.  It must be started before drtrprov
60                 exit 0
61         fi
62         PIDS=`pids`
63         if [ "$PIDS" != "" ]
64         then
65                 echo drtrprov already running
66                 exit 0
67         fi
68         echo '0 1 * * * /opt/app/datartr/bin/runreports' | crontab
69         nohup java $JAVA_OPTS org.onap.dmaap.datarouter.provisioning.Main </dev/null &
70         sleep 5
71         PIDS=`pids`
72         if [ "$PIDS" = "" ]
73         then
74                 echo drtrprov startup failed
75         else
76                 echo drtrprov started
77         fi
78 }
79
80 stop() {
81         ID=`id -n -u`
82         GRP=`id -n -g`
83         if [ "$ID" != "datartr" ]
84         then
85                 echo drtrprov must be stopped as user datartr not $ID
86                 exit 1
87         fi
88         if [ "$GRP" != "datartr" ]
89         then
90                 echo drtrprov must be stopped as group datartr not $GRP
91                 exit 1
92         fi
93         /usr/bin/curl http://127.0.0.1:8080/internal/halt
94         sleep 5
95         PIDS=`pids`
96         if [ "$PIDS" != "" ]
97         then
98                 sleep 5
99                 kill -9 $PIDS
100                 sleep 5
101                 echo drtrprov stopped
102         else
103                 echo drtrprov not running
104         fi
105 }
106
107 status() {
108         PIDS=`pids`
109         if [ "$PIDS" != "" ]
110         then
111                 echo drtrprov running
112         else
113                 echo drtrprov not running
114         fi
115 }
116
117 case "$1" in
118 'start')
119         start
120         ;;
121 'stop')
122         stop
123         ;;
124 'restart')
125         stop
126         sleep 20
127         start
128         ;;
129 'status')
130         status
131         ;;
132 *)
133         echo "Usage: $0 { start | stop | restart | status }"
134         exit 1
135         ;;
136 esac
137 exit 0