blob: b7dd5f7d5df112dabc59972bc7924f4b10242955 [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#*/
Ian Maxond8071ee2015-06-24 17:39:05 -070016
17
ramangrover29116eb972013-02-20 20:47:35 +000018USERNAME=$1
19FILE_TO_TRANSFER=$2
20DEST_HOST=$3
21DEST_DIR=$4
22POST_ACTION=$5
23ssh -l $USERNAME $DEST_HOST "mkdir -p $DEST_DIR"
24echo "scp $FILE_TO_TRANSFER $USERNAME@$DEST_HOST:$DEST_DIR/"
25scp $FILE_TO_TRANSFER $USERNAME@$DEST_HOST:$DEST_DIR/
26if [ $POST_ACTION == "unpack" ]
27 then
28 filename=`echo ${FILE_TO_TRANSFER##*/}`
29 fileType=`echo ${FILE_TO_TRANSFER##*.}`
30 if [ $fileType == "tar" ]
31 then
32 echo "ssh -l $USERNAME $DEST_HOST cd $DEST_DIR && tar xf $filename"
33 ssh -l $USERNAME $DEST_HOST "cd $DEST_DIR && tar xf $filename"
34 else if [ $fileType == "zip" ]
35 then
36 echo "ssh -l $USERNAME $DEST_HOST unzip -o -q -d $DEST_DIR $DEST_DIR/$filename"
37 ssh -l $USERNAME $DEST_HOST "unzip -o -q -d $DEST_DIR $DEST_DIR/$filename"
ramangrover29@gmail.com4ba21522013-02-27 23:35:42 +000038 ssh -l $USERNAME $DEST_HOST "chmod -R 755 $DEST_DIR"
ramangrover29116eb972013-02-20 20:47:35 +000039 fi
40 fi
41fi