-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdev.sh
136 lines (116 loc) · 3.01 KB
/
dev.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
function FONCYES ()
{
[ "$1" = "y" ] || [ "$1" = "Y" ]
}
function ASK()
{
if [ "$yesToAll" = "1" ]; then
return 0
fi
echo "$1 ? [y/n]"
read -r RESPONSE
FONCYES "$RESPONSE"
}
function FUNC_INSTALL_DOCKER ()
{
curl -sSL https://get.docker.com/ | sh
# now install docker-compose
curl -L https://github.com/docker/compose/releases/download/1.7.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
}
function FONC_INSTALL ()
{
RESULT=""
apt-get update
if ! hash curl 2>/dev/null; then
if ASK "Install curl"; then
apt-get install -y curl
fi
fi
if ! hash git 2>/dev/null; then
if ASK "Install git"; then
apt install -y git
fi
fi
if ! hash docker 2>/dev/null; then
if ASK "Install docker"; then
FUNC_INSTALL_DOCKER
fi
fi
if ! hash java 2>/dev/null; then
if ASK "Install openjdk8 and maven"; then
apt install -y maven default-jdk
fi
fi
if ! hash npm 2>/dev/null; then
if ASK "Install npm and node8"; then
apt install -y npm
# update npm
npm i -g npm
npm install -g n
n latest
fi
fi
if ! hash pip 2>/dev/null; then
if ASK "Install pip (required for aws-sam-cli, ..)"; then
apt install -y python-pip
# update to the last version (bad idea)
# keep 9.0.1-2 : https://github.com/pypa/pip/issues/5240
# pip install --upgrade pip
RESULT="$RESULT\n export PATH=~/.local/bin:\$PATH"
fi
fi
if ! hash aws 2>/dev/null; then
if ASK "Install awscli"; then
# apt install -y awscli
pip install awscli --upgrade --user
RESULT="$RESULT\n aws --version"
fi
fi
if ! hash sam 2>/dev/null; then
if ASK "Install aws-sam-local"; then
pip install --user aws-sam-cli
sam --version
pip install --user --upgrade aws-sam-cli
fi
fi
if ! hash localstack 2>/dev/null; then
if ASK "Install localstack"; then
pip install --user localstack
RESULT="$RESULT\n localstack start --docker"
fi
fi
# echo \n doesn't print a newline
# printf has more consistent behavior than echo. The behavior of echo varies greatly between different versions.
printf $RESULT
}
usage()
{
echo "usage: dev.sh [[[-y] [-i] [-v]] | [-h]]"
}
interactive=
yesToAll=
validate=
while [ "$1" != "" ]; do
case $1 in
-y | --yesToAll ) yesToAll=1
;;
-i | --interactive ) interactive=1
;;
-v | --validate ) validate=1
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
# Shift all the parameters down by one
shift
done
FONC_INSTALL
if [ "$validate" = "1" ]; then
curl -sSL https://raw.githubusercontent.com/tmieulet/script/master/validate-sam.sh | sh
fi