sg481n | aaf2df8 | 2017-08-03 17:56:38 -0400 | [diff] [blame] | 1 | #!/bin/bash |
Fiachra Corcoran | fa1da98 | 2018-07-26 07:23:34 +0100 | [diff] [blame] | 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. |
sg481n | aaf2df8 | 2017-08-03 17:56:38 -0400 | [diff] [blame] | 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 |
eronkeo | 1841cb5 | 2018-08-12 15:46:43 +0100 | [diff] [blame] | 27 | CLASSPATH=`echo /opt/app/datartr/etc /opt/app/datartr/lib/*.jar | tr ' ' ':'` |
sg481n | aaf2df8 | 2017-08-03 17:56:38 -0400 | [diff] [blame] | 28 | export CLASSPATH |
| 29 | |
| 30 | pids() { |
eronkeo | 1841cb5 | 2018-08-12 15:46:43 +0100 | [diff] [blame] | 31 | ps -ef | grep java | grep node.NodeMain | sed -e 's/[^ ]* *//' -e 's/ .*//' |
sg481n | aaf2df8 | 2017-08-03 17:56:38 -0400 | [diff] [blame] | 32 | } |
| 33 | |
| 34 | start() { |
eronkeo | 1841cb5 | 2018-08-12 15:46:43 +0100 | [diff] [blame] | 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 |
sg481n | aaf2df8 | 2017-08-03 17:56:38 -0400 | [diff] [blame] | 61 | |
eronkeo | 1841cb5 | 2018-08-12 15:46:43 +0100 | [diff] [blame] | 62 | mkdir -p /opt/app/datartr/spool/s |
| 63 | chmod 755 /opt/app/datartr/spool/s |
sg481n | aaf2df8 | 2017-08-03 17:56:38 -0400 | [diff] [blame] | 64 | |
eronkeo | 1841cb5 | 2018-08-12 15:46:43 +0100 | [diff] [blame] | 65 | rm -f /opt/app/datartr/etc/SHUTDOWN |
efiacor | adb2ad2 | 2019-10-23 15:31:43 +0100 | [diff] [blame] | 66 | nohup java org.onap.dmaap.datarouter.node.NodeRunner </dev/null >/dev/null 2>&1 & |
eronkeo | 1841cb5 | 2018-08-12 15:46:43 +0100 | [diff] [blame] | 67 | sleep 5 |
| 68 | PIDS=`pids` |
| 69 | if [ "$PIDS" = "" ] |
| 70 | then |
| 71 | echo drtrnode startup failed |
| 72 | else |
| 73 | echo drtrnode started |
| 74 | fi |
sg481n | aaf2df8 | 2017-08-03 17:56:38 -0400 | [diff] [blame] | 75 | } |
| 76 | |
| 77 | stop() { |
eronkeo | 1841cb5 | 2018-08-12 15:46:43 +0100 | [diff] [blame] | 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 |
sg481n | aaf2df8 | 2017-08-03 17:56:38 -0400 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | status() { |
eronkeo | 1841cb5 | 2018-08-12 15:46:43 +0100 | [diff] [blame] | 104 | PIDS=`pids` |
| 105 | if [ "$PIDS" != "" ] |
| 106 | then |
| 107 | echo drtrnode running |
| 108 | else |
| 109 | echo drtrnode not running |
| 110 | fi |
sg481n | aaf2df8 | 2017-08-03 17:56:38 -0400 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | case "$1" in |
| 114 | 'start') |
eronkeo | 1841cb5 | 2018-08-12 15:46:43 +0100 | [diff] [blame] | 115 | start |
| 116 | ;; |
sg481n | aaf2df8 | 2017-08-03 17:56:38 -0400 | [diff] [blame] | 117 | 'stop') |
eronkeo | 1841cb5 | 2018-08-12 15:46:43 +0100 | [diff] [blame] | 118 | stop |
| 119 | ;; |
sg481n | aaf2df8 | 2017-08-03 17:56:38 -0400 | [diff] [blame] | 120 | 'restart') |
eronkeo | 1841cb5 | 2018-08-12 15:46:43 +0100 | [diff] [blame] | 121 | stop |
| 122 | sleep 20 |
| 123 | start |
| 124 | ;; |
sg481n | aaf2df8 | 2017-08-03 17:56:38 -0400 | [diff] [blame] | 125 | 'status') |
eronkeo | 1841cb5 | 2018-08-12 15:46:43 +0100 | [diff] [blame] | 126 | status |
| 127 | ;; |
sg481n | aaf2df8 | 2017-08-03 17:56:38 -0400 | [diff] [blame] | 128 | *) |
eronkeo | 1841cb5 | 2018-08-12 15:46:43 +0100 | [diff] [blame] | 129 | echo "Usage: $0 { start | stop | restart }" |
| 130 | exit 1 |
| 131 | ;; |
sg481n | aaf2df8 | 2017-08-03 17:56:38 -0400 | [diff] [blame] | 132 | esac |
| 133 | exit 0 |