sg481n | aaf2df8 | 2017-08-03 17:56:38 -0400 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | umask 0022 |
| 4 | TZ=GMT0 |
| 5 | export TZ |
| 6 | PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/java/jdk/jdk180/bin |
| 7 | export PATH |
| 8 | CLASSPATH=`echo /opt/app/datartr/etc /opt/app/datartr/lib/*.jar | tr ' ' ':'` |
| 9 | export CLASSPATH |
| 10 | |
| 11 | pids() { |
| 12 | ps -ef | grep java | grep node.NodeMain | sed -e 's/[^ ]* *//' -e 's/ .*//' |
| 13 | } |
| 14 | |
| 15 | start() { |
| 16 | ID=`id -n -u` |
| 17 | GRP=`id -n -g` |
| 18 | if [ "$ID" != "root" ] |
| 19 | then |
| 20 | echo drtrnode must be started as user datartr not $ID |
| 21 | exit 1 |
| 22 | fi |
| 23 | if [ "$GRP" != "datartr" ] |
| 24 | then |
| 25 | echo drtrnode must be started as group datartr not $GRP |
| 26 | exit 1 |
| 27 | fi |
| 28 | cd /opt/app/datartr |
| 29 | if etc/havecert |
| 30 | then |
| 31 | echo >/dev/null |
| 32 | else |
| 33 | echo No certificate file available. Cannot start |
| 34 | exit 0 |
| 35 | fi |
| 36 | PIDS=`pids` |
| 37 | if [ "$PIDS" != "" ] |
| 38 | then |
| 39 | echo drtrnode already running |
| 40 | exit 0 |
| 41 | fi |
| 42 | |
| 43 | mkdir -p /opt/app/datartr/spool/s |
| 44 | chmod 755 /opt/app/datartr/spool/s |
| 45 | |
| 46 | rm -f /opt/app/datartr/etc/SHUTDOWN |
| 47 | nohup java com.att.research.datarouter.node.NodeMain </dev/null >/dev/null 2>&1 & |
| 48 | sleep 5 |
| 49 | PIDS=`pids` |
| 50 | if [ "$PIDS" = "" ] |
| 51 | then |
| 52 | echo drtrnode startup failed |
| 53 | else |
| 54 | echo drtrnode started |
| 55 | fi |
| 56 | } |
| 57 | |
| 58 | stop() { |
| 59 | ID=`id -n -u` |
| 60 | GRP=`id -n -g` |
| 61 | if [ "$ID" != "datartr" ] |
| 62 | then |
| 63 | echo drtrnode must be stopped as user datartr not $ID |
| 64 | exit 1 |
| 65 | fi |
| 66 | if [ "$GRP" != "datartr" ] |
| 67 | then |
| 68 | echo drtrnode must be stopped as group datartr not $GRP |
| 69 | exit 1 |
| 70 | fi |
| 71 | touch /opt/app/datartr/etc/SHUTDOWN |
| 72 | PIDS=`pids` |
| 73 | if [ "$PIDS" != "" ] |
| 74 | then |
| 75 | sleep 5 |
| 76 | kill -9 $PIDS |
| 77 | sleep 5 |
| 78 | echo drtrnode stopped |
| 79 | else |
| 80 | echo drtrnode not running |
| 81 | fi |
| 82 | } |
| 83 | |
| 84 | status() { |
| 85 | PIDS=`pids` |
| 86 | if [ "$PIDS" != "" ] |
| 87 | then |
| 88 | echo drtrnode running |
| 89 | else |
| 90 | echo drtrnode not running |
| 91 | fi |
| 92 | } |
| 93 | |
| 94 | case "$1" in |
| 95 | 'start') |
| 96 | start |
| 97 | ;; |
| 98 | 'stop') |
| 99 | stop |
| 100 | ;; |
| 101 | 'restart') |
| 102 | stop |
| 103 | sleep 20 |
| 104 | start |
| 105 | ;; |
| 106 | 'status') |
| 107 | status |
| 108 | ;; |
| 109 | *) |
| 110 | echo "Usage: $0 { start | stop | restart }" |
| 111 | exit 1 |
| 112 | ;; |
| 113 | esac |
| 114 | exit 0 |