-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.sh
executable file
·49 lines (45 loc) · 967 Bytes
/
util.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
fileCount()
{
fileName=$1
fileCount=`wc -l $fileName | cut -d" " -f1`
}
freshFile()
{
fileName=$1
rm -rf $fileName
touch $fileName
}
scpFiles()
{
instance=$1
baseDir=$2
privateKey=$3
declare -a files=("${!4}")
echo "SCPing files to $instance"
for file in "${files[@]}"
do
`echo "mkdir $baseDir" | ssh -o "StrictHostKeyChecking no" -i $privateKey $instance /bin/sh`
scpCmd="scp -i $privateKey $file $instance:$baseDir/`basename $file`"
echo $scpCmd
`$scpCmd`
done
}
runCommand()
{
instance=$1
privateKey=$2
cmd=$3
echo "Executing command on $instance:$cmd"
`echo "$cmd" | ssh -o "StrictHostKeyChecking no" -i $privateKey $instance /bin/bash`
}
runScreen()
{
instance=$1
privateKey=$2
screenName=$3
screenScript=$4
cmd=$5
screenCmd="$screenScript $screenName \"$cmd\""
echo "Screen command:$screenCmd"
`echo "$screenCmd" | ssh -o "StrictHostKeyChecking no" -i $privateKey $instance /bin/bash`
}