-
Notifications
You must be signed in to change notification settings - Fork 0
/
ecsrun.sh
111 lines (107 loc) · 4.22 KB
/
ecsrun.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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/bash
PROJNAME=$1
PROJURL=$2
CISTAGE=$3
echo "Starting with project $PROJNAME as $PROJURL on stage: $CISTAGE"
ECSDIR=aws-settings/ecs/projects
PROJSCRIPTSDIR=$ECSDIR/common/scripts
PROJCOMMSETTDIR=$ECSDIR/common/settings
PROJCOMMSETTFILE=$PROJCOMMSETTDIR/$CISTAGE.sh
PROJSETTDIR=$ECSDIR/$PROJNAME
PROJDOCKERFILE=$PROJSETTDIR/Dockerfile
PROJSETTFILE=$PROJSETTDIR/$CISTAGE.conf
PROJTASKDEF=$PROJSETTDIR/taskdef.json
PROJBULDPUSH=$PROJSCRIPTSDIR/ecsbuildpush.sh
PROJECSDEPLOY=$PROJSCRIPTSDIR/ecsdeploy.sh
PROJECSSTOP=$PROJSCRIPTSDIR/ecsstop.sh
PROJCISETT=$PROJSETTDIR/ci.settings.php
mkdir ~/.ssh/
# Add access to repo
echo "-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEA0ep1SBD5rNqB5MvD7gen7PKdwwxw+VwSZgGvl6JgQtat6S3/
B49jUePRR5orcGnCdP5hD1fzc7L2pmFmNPpAJUCRTodbk3HNOX5qIDPRYqEzeLZa
qaG+UbBUtKuwjQpt56BLoAfvCzk/JmdUPI9T4eMdt/TEMz0UH+ot0lnGGQopuMt1
4YGnXr9uUea1qEJcR0b1PFoY/A02gqfZ5pYrT53PTGCl8zIrfhaikzgdYNZqD5JD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7oK4n7zVYHkcb1wn36ISd/+s7GX/HqzfC/n
mYgUQH5Pct7/4bVH8PdTi0hi7X88dB/IvBSKFYC8byqTwa+zfVmT2pQKLZxaRykZ
Uk06/KkCgYEAnI4Pk5AEYKYSnMMtpCbdWNLADskCm81fXaqc9tDR2fO0D2mp6tRP
dF9RNyPumxguer/29+ZTMoEo2Tyi3c6tsF4B0ZZ+7mI5M72dzR+XurLX6igerBDk
4MwFmFCjVqPJai8t/uG53x+WHbPrTVJAssr4+v+XgYkzcnS2VDMI9uA=
-----END RSA PRIVATE KEY-----" > /root/.ssh/ec2instance
chmod 600 /root/.ssh/ec2instance
echo "Host gitlab-ffw
HostName gitlab.workingpropeople.com
User git
StrictHostKeyChecking no
#RSAAuthentication yes
IdentityFile /root/.ssh/ec2instance
" >> /root/.ssh/config
# Clone repo locally
git clone git@gitlab-ffw:FFW-CSO/INFRASTRUCTURE/aws-settings.git
if [ ! -f $PROJCOMMSETTFILE ]; then
echo "No common settings file found for $CISTAGE! Creating empty one."
echo "#!/bin/bash" > commonsettings.sh
else
cp $PROJCOMMSETTFILE commonsettings.sh
fi
if [ ! -f $PROJSETTFILE ]; then
echo "No PROJECT settings file found for $CISTAGE! Creating empty one."
echo "#!/bin/bash" > projectsettings.sh
else
cp $PROJSETTFILE projectsettings.sh
fi
chmod +x commonsettings.sh
chmod +x projectsettings.sh
if [[ $CISTAGE == "build" ]] ; then
cp $PROJDOCKERFILE ./Dockerfile
cp $PROJBULDPUSH ./ecsbuildpush.sh
if [ -f $PROJCOMMSETTFILE ]; then
cp $PROJCISETT ./ci.settings.php
else
echo "No ci.settings.php file for overwriting. Relying on the one in DOCROOT/sites/default/"
fi
rm -rf aws-settings
chmod +x ecsbuildpush.sh
./ecsbuildpush.sh $PROJNAME $PROJURL
echo "Image pushed to repo for $PROJNAME on $PROJURL"
elif [[ $CISTAGE == "deploydev" ]]; then
cp $PROJTASKDEF ./taskdef.json
cp $PROJECSDEPLOY ./ecsdeploy.sh
rm -rf aws-settings
chmod +x ecsdeploy.sh
./ecsdeploy.sh $PROJNAME $PROJURL $CISTAGE
echo "Develop deployed for $PROJNAME on $PROJURL"
elif [[ $CISTAGE == "deployfeat" ]]; then
cp $PROJTASKDEF ./taskdef.json
cp $PROJECSDEPLOY ./ecsdeploy.sh
rm -rf aws-settings
chmod +x ecsdeploy.sh
./ecsdeploy.sh $PROJNAME $PROJURL $CISTAGE
echo "Feature deployed for $PROJNAME on $PROJURL"
elif [[ $CISTAGE == "stopfeat" ]]; then
cp $PROJTASKDEF ./taskdef.json
cp $PROJECSSTOP ./ecsstop.sh
rm -rf aws-settings
chmod +x ecsstop.sh
./ecsstop.sh $PROJNAME $PROJURL
echo "Feature stopped for $PROJNAME on $PROJURL"
else
echo "Please use appropriate stage, and not: $CISTAGE"
fi
echo "ALL DONE! $CISTAGE completed!"