blob: b0e915e5b62499334ef1a4fd41dc1cbddd9afebc [file] [log] [blame]
sg481naaf2df82017-08-03 17:56:38 -04001#!/bin/bash
Fiachra Corcoranfa1da982018-07-26 07:23:34 +01002# ============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.
sg481naaf2df82017-08-03 17:56:38 -040021
22umask 0022
23TZ=GMT0
24export TZ
25PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/java/jdk/jdk180/bin
26export PATH
eronkeo1841cb52018-08-12 15:46:43 +010027CLASSPATH=`echo /opt/app/datartr/etc /opt/app/datartr/lib/*.jar | tr ' ' ':'`
sg481naaf2df82017-08-03 17:56:38 -040028export CLASSPATH
29
30pids() {
eronkeo1841cb52018-08-12 15:46:43 +010031 ps -ef | grep java | grep node.NodeMain | sed -e 's/[^ ]* *//' -e 's/ .*//'
sg481naaf2df82017-08-03 17:56:38 -040032}
33
34start() {
eronkeo1841cb52018-08-12 15:46:43 +010035 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
sg481naaf2df82017-08-03 17:56:38 -040061
eronkeo1841cb52018-08-12 15:46:43 +010062 mkdir -p /opt/app/datartr/spool/s
63 chmod 755 /opt/app/datartr/spool/s
sg481naaf2df82017-08-03 17:56:38 -040064
eronkeo1841cb52018-08-12 15:46:43 +010065 rm -f /opt/app/datartr/etc/SHUTDOWN
efiacoradb2ad22019-10-23 15:31:43 +010066 nohup java org.onap.dmaap.datarouter.node.NodeRunner </dev/null >/dev/null 2>&1 &
eronkeo1841cb52018-08-12 15:46:43 +010067 sleep 5
68 PIDS=`pids`
69 if [ "$PIDS" = "" ]
70 then
71 echo drtrnode startup failed
72 else
73 echo drtrnode started
74 fi
sg481naaf2df82017-08-03 17:56:38 -040075}
76
77stop() {
eronkeo1841cb52018-08-12 15:46:43 +010078 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
sg481naaf2df82017-08-03 17:56:38 -0400101}
102
103status() {
eronkeo1841cb52018-08-12 15:46:43 +0100104 PIDS=`pids`
105 if [ "$PIDS" != "" ]
106 then
107 echo drtrnode running
108 else
109 echo drtrnode not running
110 fi
sg481naaf2df82017-08-03 17:56:38 -0400111}
112
113case "$1" in
114'start')
eronkeo1841cb52018-08-12 15:46:43 +0100115 start
116 ;;
sg481naaf2df82017-08-03 17:56:38 -0400117'stop')
eronkeo1841cb52018-08-12 15:46:43 +0100118 stop
119 ;;
sg481naaf2df82017-08-03 17:56:38 -0400120'restart')
eronkeo1841cb52018-08-12 15:46:43 +0100121 stop
122 sleep 20
123 start
124 ;;
sg481naaf2df82017-08-03 17:56:38 -0400125'status')
eronkeo1841cb52018-08-12 15:46:43 +0100126 status
127 ;;
sg481naaf2df82017-08-03 17:56:38 -0400128*)
eronkeo1841cb52018-08-12 15:46:43 +0100129 echo "Usage: $0 { start | stop | restart }"
130 exit 1
131 ;;
sg481naaf2df82017-08-03 17:56:38 -0400132esac
133exit 0