Ian Maxon | d8071ee | 2015-06-24 17:39:05 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Ian Maxon | 305858c | 2015-10-01 19:00:14 -0700 | [diff] [blame] | 2 | # Licensed to the Apache Software Foundation (ASF) under one |
| 3 | # or more contributor license agreements. See the NOTICE file |
| 4 | # distributed with this work for additional information |
| 5 | # regarding copyright ownership. The ASF licenses this file |
| 6 | # to you under the Apache License, Version 2.0 (the |
| 7 | # "License"); you may not use this file except in compliance |
| 8 | # with the License. You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, |
| 13 | # software distributed under the License is distributed on an |
| 14 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | # KIND, either express or implied. See the License for the |
| 16 | # specific language governing permissions and limitations |
| 17 | # under the License. |
Ian Maxon | d8071ee | 2015-06-24 17:39:05 -0700 | [diff] [blame] | 18 | |
ramangrover29 | bfe4623 | 2013-05-30 23:16:32 -0700 | [diff] [blame] | 19 | USERNAME=$1 |
| 20 | if [ ! -d $MANAGIX_HOME/logs ]; |
| 21 | then |
| 22 | mkdir -p $MANAGIX_HOME/logs |
| 23 | fi |
| 24 | LOGDIR=$MANAGIX_HOME/logs |
| 25 | if [ $DAEMON == "false" ]; then |
| 26 | if [ -z $USERNAME ] |
| 27 | then |
| 28 | cmd_output=$(ssh $IP_LOCATION "$ENV $SCRIPT $ARGS" 2>&1 >/dev/null) |
| 29 | echo "ssh $IP_LOCATION $ENV $SCRIPT $ARGS" >> $LOGDIR/execute.log |
| 30 | echo "$cmd_output" |
| 31 | else |
| 32 | echo "ssh -l $USERNAME $IP_LOCATION $ENV $SCRIPT $ARGS" >> $LOGDIR/execute.log |
| 33 | cmd_output=$(ssh -l $USERNAME $IP_LOCATION "$ENV $SCRIPT $ARGS" 2>&1 >/dev/null) |
| 34 | echo "$cmd_output" |
| 35 | fi |
| 36 | else |
| 37 | if [ -z $USERNAME ]; |
| 38 | then |
| 39 | echo "ssh $IP_LOCATION $ENV $SCRIPT $ARGS &" >> $LOGDIR/execute.log |
| 40 | ssh $IP_LOCATION "$ENV $SCRIPT $ARGS" & |
| 41 | else |
| 42 | echo "ssh -l $USERNAME $IP_LOCATION $ENV $SCRIPT $ARGS &" >> $LOGDIR/execute.log |
| 43 | ssh -l $USERNAME $IP_LOCATION "$ENV $SCRIPT $ARGS" & |
| 44 | fi |
| 45 | fi |