Till Westmann | ea8ab39 | 2013-06-05 15:17:08 -0700 | [diff] [blame] | 1 | #/* |
| 2 | # Copyright 2009-2013 by The Regents of the University of California |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # you may obtain a copy of the License from |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | #*/ |
ramangrover29 | 116eb97 | 2013-02-20 20:47:35 +0000 | [diff] [blame] | 15 | USERNAME=$1 |
| 16 | FILE_TO_TRANSFER=$2 |
| 17 | DEST_HOST=$3 |
| 18 | DEST_DIR=$4 |
| 19 | POST_ACTION=$5 |
| 20 | ssh -l $USERNAME $DEST_HOST "mkdir -p $DEST_DIR" |
| 21 | echo "scp $FILE_TO_TRANSFER $USERNAME@$DEST_HOST:$DEST_DIR/" |
| 22 | scp $FILE_TO_TRANSFER $USERNAME@$DEST_HOST:$DEST_DIR/ |
| 23 | if [ $POST_ACTION == "unpack" ] |
| 24 | then |
| 25 | filename=`echo ${FILE_TO_TRANSFER##*/}` |
| 26 | fileType=`echo ${FILE_TO_TRANSFER##*.}` |
| 27 | if [ $fileType == "tar" ] |
| 28 | then |
| 29 | echo "ssh -l $USERNAME $DEST_HOST cd $DEST_DIR && tar xf $filename" |
| 30 | ssh -l $USERNAME $DEST_HOST "cd $DEST_DIR && tar xf $filename" |
| 31 | else if [ $fileType == "zip" ] |
| 32 | then |
| 33 | echo "ssh -l $USERNAME $DEST_HOST unzip -o -q -d $DEST_DIR $DEST_DIR/$filename" |
| 34 | ssh -l $USERNAME $DEST_HOST "unzip -o -q -d $DEST_DIR $DEST_DIR/$filename" |
ramangrover29@gmail.com | 4ba2152 | 2013-02-27 23:35:42 +0000 | [diff] [blame] | 35 | ssh -l $USERNAME $DEST_HOST "chmod -R 755 $DEST_DIR" |
ramangrover29 | 116eb97 | 2013-02-20 20:47:35 +0000 | [diff] [blame] | 36 | fi |
| 37 | fi |
| 38 | fi |