forked from aws/aws-nitro-enclaves-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·66 lines (57 loc) · 1.36 KB
/
install.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
#!/bin/bash
set -e -u
#The package names work for Ubuntu, AL2, RedHat 8 and CentOS 7
PACKAGES="docker make gcc"
PREREQ_OPTIONS="-y"
install_prerequisites() {
if grep -qni "Amazon Linux\|CentOS\|RedHat" /etc/os-release
then
OPERATION="yum install"
elif grep -qni "Ubuntu" /etc/os-release
then
OPERATION="apt-get install"
else
#Try to continue, just in case the user has done that themselves
echo "Warning: prerequisite packages were not installed. Please manually install ${PACKAGES}."
return
fi
${OPERATION} ${PREREQ_OPTIONS} ${PACKAGES}
}
update_git() {
if [ -d .git ] || git rev-parse --git-dir > /dev/null 2>&1
then
git pull
git checkout "$2"
else
echo "You're trying to install nitro-cli outside of the git repository."
exit
fi
}
install_nitro_cli() {
make nitro-cli && make vsock-proxy && make install
source "${NITRO_CLI_INSTALL_DIR}"/etc/profile.d/nitro-cli-env.sh
echo "Nitro CLI is now installed. We recommend adding ${NITRO_CLI_INSTALL_DIR}/etc/profile.d/nitro-cli-env.sh in your .bashrc file"
}
show_usage() {
echo "Usage: $0 [--update <commit>] [--ask-for-confirmation] [--help]"
}
#Parse parameters
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-u|--update)
update_git "$2" || show_usage
shift 2
;;
-c|--ask-for-confirmation)
PREREQ_OPTIONS=""
shift
;;
-h|--help)
show_usage
exit
esac
done
install_prerequisites
install_nitro_cli