blob: fc198ad136c49071e7d60057467fb38a0a346c8f [file] [log] [blame]
Ian Maxond8071ee2015-06-24 17:39:05 -07001#!/usr/bin/env bash
Till Westmannea8ab392013-06-05 15:17:08 -07002#/*
3# Copyright 2009-2013 by The Regents of the University of California
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# you may obtain a copy of the License from
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#*/
ramangrover29116eb972013-02-20 20:47:35 +000016USERNAME=$1
ramangrover29@gmail.com3bfd1b52013-03-08 18:56:42 +000017if [ ! -d $MANAGIX_HOME/logs ];
18then
19 mkdir -p $MANAGIX_HOME/logs
20fi
21LOGDIR=$MANAGIX_HOME/logs
ramangrover29116eb972013-02-20 20:47:35 +000022if [ $DAEMON == "false" ]; then
23 if [ -z $USERNAME ]
24 then
25 cmd_output=$(ssh $IP_LOCATION "$ENV $SCRIPT $ARGS" 2>&1 >/dev/null)
ramangrover29@gmail.com3bfd1b52013-03-08 18:56:42 +000026 echo "ssh $IP_LOCATION $ENV $SCRIPT $ARGS" >> $LOGDIR/execute.log
ramangrover29116eb972013-02-20 20:47:35 +000027 echo "$cmd_output"
28 else
ramangrover29@gmail.com3bfd1b52013-03-08 18:56:42 +000029 echo "ssh -l $USERNAME $IP_LOCATION $ENV $SCRIPT $ARGS" >> $LOGDIR/execute.log
ramangrover29116eb972013-02-20 20:47:35 +000030 cmd_output=$(ssh -l $USERNAME $IP_LOCATION "$ENV $SCRIPT $ARGS" 2>&1 >/dev/null)
31 echo "$cmd_output"
32 fi
33else
34 if [ -z $USERNAME ];
35 then
ramangrover29@gmail.com3bfd1b52013-03-08 18:56:42 +000036 echo "ssh $IP_LOCATION $ENV $SCRIPT $ARGS &" >> $LOGDIR/execute.log
ramangrover29116eb972013-02-20 20:47:35 +000037 ssh $IP_LOCATION "$ENV $SCRIPT $ARGS" &
38 else
ramangrover29@gmail.com3bfd1b52013-03-08 18:56:42 +000039 echo "ssh -l $USERNAME $IP_LOCATION $ENV $SCRIPT $ARGS &" >> $LOGDIR/execute.log
ramangrover29116eb972013-02-20 20:47:35 +000040 ssh -l $USERNAME $IP_LOCATION "$ENV $SCRIPT $ARGS" &
41 fi
42fi