-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabcd-kwyker_local.sh
More file actions
executable file
·79 lines (61 loc) · 2.92 KB
/
Copy pathabcd-kwyker_local.sh
File metadata and controls
executable file
·79 lines (61 loc) · 2.92 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
set -eu
echo "abcd-kwyker_awslocal: Running kwyk container on EC2 resource on ABCD S3 file on aws - local controller"
# This is the main script, for local management of the analysis process, that, given
# the S3 path to an anatomic case, manages its fetch, kwyk run, and 'post' to
# the named ReproNim S3 results location
# At the moment it is expecting to run via the AWS-RunShellScript System
# Management functions, as user = root
# Check usage, 2 argument expected.
if [ "$#" -ne 2 ]; then
echo "Illegal number of parameters provided"
echo "Expected usage: abcd-kwyker_local.sh S3_file_name outputdirectoryname"
exit 10
fi
# setup variables
s3filenam=$1
basenam=$2
# Identify AWS EC2 instance ID
IID=i-0e8750dd1c7e02355
remotescript=abcd-kwyker_aws.sh
#localscriptpath=~/bin
localscriptpath=~/GitHub/CloudComputeExample
remotescriptpath=~ubuntu/bin
# We are using aws 'profile' for credential management.
# We expect the .aws/configuration file to be pushed from your local system (i.e. here)
# TODO insert a checker to see if you have a valid and currently active
# session token, and to provide appropriate instructions if you don't...
# There are two points here: 1) we want the 'on aws' activities to be completly
# 'hands-off' for efficiency purposes; and 2) we'd like to not have the user
# entering their NDA authorization very often.
# IF creds fail, then do the following:
#PrepCreds (if needed) will result in an .aws/credentials file
#Get token content into /Users/davidkennedy/downloadmanager/tempcred.txt
#docker run -it --rm -v $NDAdir:/data debian /data/debian_generate_token.sh $NDAuser $NDApasswd
#Patch AWS Creds
#~/bin/prep_creds.sh $NDAuser
# Start Instance
echo "Launching and waiting"
echo "IID = $IID"
aws ec2 start-instances --instance-ids $IID --profile reprodnk
aws ec2 wait instance-status-ok --instance-ids $IID --profile reprodnk
#Get ip, $IP and instanceID
echo "Get ip of instance"
IP=`aws ec2 describe-instances --instance-ids $IID --query 'Reservations[*].Instances[*].PublicIpAddress' --output text --profile reprodnk`
echo "Found IP as $IP"
# Push stuff to instance
# Push Creds to instance
scp -o StrictHostKeyChecking=no -i ~/DNK_CRNC.pem ~/.aws/credentials ubuntu@${IP}:~/.aws/.
# Push script to instance
scp -i ~/DNK_CRNC.pem ${localscriptpath}/$remotescript ubuntu@${IP}:${remotescriptpath}/.
# Launch process on instance
echo "commands=${remotescriptpath}/$remotescript $s3filenam $basenam"
aws ssm send-command --document-name "AWS-RunShellScript" --document-version "1" \
--instance-ids "$IID" --parameters "commands=${remotescriptpath}/$remotescript $s3filenam $basenam" \
--timeout-seconds "600" --max-concurrency "50" --max-errors "0" \
--output-s3-bucket-name "kwyktest" --region us-east-1 --profile reprodnk
# the end
echo "Your process has been launched. The instance will stop itself upon "
echo "completion. But, make sure to check in on it as needed to make sure!"
echo "Done, thanks!"
exit