-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall
executable file
·123 lines (98 loc) · 2.97 KB
/
install
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
#!/bin/bash
# This script installs the new Bedrock CLI:
#
# curl https://get.bedrock.io | bash
#
# Note: this script is inspired by: https://sandstorm.io/news/2015-09-24-is-curl-bash-insecure-pgp-verified-install
#
if test -z "$BASH_VERSION"; then
echo "Please run this script using bash, not sh or any other shell." >&2
exit 1
fi
# We wrap the entire script in a big function which we only call at the very end, in order to
# protect against the possibility of the connection dying mid-script. This protects us against
# the problem described in this blog post:
# http://blog.existentialize.com/dont-pipe-to-your-shell.html
_() {
DIR=~/.bedrock
YELLOW="\033[0;33m"
NC='\033[0m'
cleanup () {
# Cleanup previous versions.
rm -rf $DIR
}
check() {
if ! [ -x "$(command -v git)" ]; then
echo 'Error: Git is not installed (https://git-scm.com/)' >&2
exit 1
fi
if [ "$(command -v yarn)" ]; then
PKG_CMD="yarn"
elif [ "$(command -v npm)" ]; then
PKG_CMD="npm"
else
echo 'Error: Either yarn or npm must be installed (https://www.npmjs.com/)' >&2
exit 1
fi
if ! [ -x "$(command -v gcloud)" ]; then
echo 'Error: Google Cloud SDK (gcloud) is not installed (https://cloud.google.com/sdk/docs/install)' >&2
exit 1
fi
if ! [ -x "$(command -v kubectl)" ]; then
echo 'Error: Kubernetes CLI (kubectl) is not installed (https://kubernetes.io/docs/tasks/tools/install-kubectl/)' >&2
exit 1
fi
}
install () {
git clone --quiet https://github.com/bedrockio/bedrock-cli.git $DIR > /dev/null
pushd $DIR > /dev/null
$PKG_CMD install > /dev/null 2>&1
popd
}
PROFILE_PATH=""
try_profile()
{
if [ -f "$1" ]; then
grep -qxF 'export PATH="$HOME/.bedrock/bin:$PATH"' $1 || echo 'export PATH="$HOME/.bedrock/bin:$PATH"' >> $1
PROFILE_PATH=$1
fi
}
try_fish_profile()
{
if [ -f "$1" ]; then
grep -qxF 'set -gx PATH $PATH ~/.bedrock/bin' $1 || echo 'set -gx PATH $PATH ~/.bedrock/bin' >> $1
PROFILE_PATH=$1
fi
}
link () {
# Attempt to add to the following shell profiles
# if the files exist and are not already linked.
try_profile $HOME/.bashrc
try_profile $HOME/.bash_profile
try_profile $HOME/.zshenv
try_profile $HOME/.zshrc
try_fish_profile $HOME/.config/fish/config.fish
}
echo -e "${YELLOW}Installing Bedrock...${NC}"
cleanup
check
install
link
if [ -f /System/Library/Sounds/Glass.aiff ]; then
afplay /System/Library/Sounds/Glass.aiff 2> /dev/null
fi
echo ""
echo ""
echo " ______ _______ ______ ______ _____ _______ _ _ "
echo " |_____] |______ | \ |_____/ | | | |____/ "
echo " |_____] |______ |_____/ | \_ |_____| |_____ | \_ "
echo ""
echo ""
cat <<-EOM
Installation completed. In order to update your \$PATH open a new shell or run:
. $PROFILE_PATH
Then, to create a new Bedrock project run:
bedrock create
EOM
}
_ "$0" "$@"