Replacing att.com namespace
[dmaap/datarouter.git] / datarouter-node / src / main / resources / misc / drtrnode
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 umask 0022
23 TZ=GMT0
24 export TZ
25 PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/java/jdk/jdk180/bin
26 export PATH
27 CLASSPATH=`echo /opt/app/datartr/etc /opt/app/datartr/lib/*.jar | tr ' ' ':'` 
28 export CLASSPATH
29
30 pids() {
31         ps -ef | grep java | grep node.NodeMain | sed -e 's/[^ ]* *//' -e 's/ .*//'
32 }
33
34 start() {
35         ID=`id -n -u`
36         GRP=`id -n -g`
37         if [ "$ID" != "root" ]
38         then
39                 echo drtrnode must be started as user datartr not $ID
40                 exit 1
41         fi
42         if [ "$GRP" != "datartr" ]
43         then
44                 echo drtrnode must be started as group datartr not $GRP
45                 exit 1
46         fi
47         cd /opt/app/datartr
48         if etc/havecert
49         then
50                 echo >/dev/null
51         else
52                 echo No certificate file available.  Cannot start
53                 exit 0
54         fi
55         PIDS=`pids`
56         if [ "$PIDS" != "" ]
57         then
58                 echo drtrnode already running
59                 exit 0
60         fi
61
62         mkdir -p /opt/app/datartr/spool/s
63         chmod 755 /opt/app/datartr/spool/s
64
65         rm -f /opt/app/datartr/etc/SHUTDOWN
66         nohup java org.onap.dmaap.datarouter.node.NodeMain </dev/null >/dev/null 2>&1 &
67         sleep 5
68         PIDS=`pids`
69         if [ "$PIDS" = "" ]
70         then
71                 echo drtrnode startup failed
72         else
73                 echo drtrnode started
74         fi
75 }
76
77 stop() {
78         ID=`id -n -u`
79         GRP=`id -n -g`
80         if [ "$ID" != "datartr" ]
81         then
82                 echo drtrnode must be stopped as user datartr not $ID
83                 exit 1
84         fi
85         if [ "$GRP" != "datartr" ]
86         then
87                 echo drtrnode must be stopped as group datartr not $GRP
88                 exit 1
89         fi
90         touch /opt/app/datartr/etc/SHUTDOWN
91         PIDS=`pids`
92         if [ "$PIDS" != "" ]
93         then
94                 sleep 5
95                 kill -9 $PIDS
96                 sleep 5
97                 echo drtrnode stopped
98         else
99                 echo drtrnode not running
100         fi
101 }
102
103 status() {
104         PIDS=`pids`
105         if [ "$PIDS" != "" ]
106         then
107                 echo drtrnode running
108         else
109                 echo drtrnode not running
110         fi
111 }
112
113 case "$1" in
114 'start')
115         start
116         ;;
117 'stop')
118         stop
119         ;;
120 'restart')
121         stop
122         sleep 20
123         start
124         ;;
125 'status')
126         status
127         ;;
128 *)
129         echo "Usage: $0 { start | stop | restart }"
130         exit 1
131         ;;
132 esac
133 exit 0