-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeployFiles.sh
More file actions
29 lines (24 loc) · 780 Bytes
/
Copy pathdeployFiles.sh
File metadata and controls
29 lines (24 loc) · 780 Bytes
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
#!/bin/bash
while getopts k:h:s: flag
do
case "${flag}" in
k) key=${OPTARG};;
h) hostname=${OPTARG};;
s) service=${OPTARG};;
esac
done
if [[ -z "$key" || -z "$hostname" || -z "$service" ]]; then
printf "\nMissing required parameter.\n"
printf " syntax: deployFiles.sh -k <pem key file> -h <hostname> -s <service>\n\n"
exit 1
fi
printf "\n----> Deploying files for $service to $hostname with $key\n"
# Step 1
printf "\n----> Clear out the previous distribution on the target.\n"
ssh -i "$key" ubuntu@$hostname << ENDSSH
rm -rf services/${service}/public
mkdir -p services/${service}/public
ENDSSH
# Step 2
printf "\n----> Copy the distribution package to the target.\n"
scp -r -i "$key" * ubuntu@$hostname:services/$service/public