forked from nuvolaris/nuvolaris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.source
173 lines (146 loc) · 3.98 KB
/
setup.source
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
## NOTE! This script should be sourced, not executed.
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
if test -z "$BASH"
then echo "Please, source me using bash." ; kill -INT $$
fi
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]
then echo "You must source this script with bash, not execute it." ; kill -INT $$
fi
# versions
export PS1="[\W]\$ "
export NODENV_VERSION=16.13.0
export PYENV_VERSION=3.9.9
export GOENV_VERSION=1.17.3
# env roots
export PYENV_ROOT="$HOME/.pyenv"
export NODENV_ROOT="$HOME/.nodenv"
export GOENV_ROOT="$HOME/.goenv"
# Preflight checks
die() {
echo ERROR: "$@"
kill -INT $$
}
ok() {
echo OK: "$@"
}
if ! which gcc >/dev/null
then die "Please install development tools"
else ok gcc
fi
if ! which git >/dev/null
then die "Please install git"
else ok git
fi
if ! which docker >/dev/null
then die "Please install docker and assign access to this user"
else ok docker
fi
if ! which kubectl >/dev/null
then die "Please install kubectl"
else ok kubectl
fi
if ! which wsk >/dev/null
then die "Please install wsk"
else ok wsk
fi
# Install
if ! test -d $GOENV_ROOT
then git clone https://github.com/syndbg/goenv.git $GOENV_ROOT
else ok goenv
fi
if ! test -e $NODENV_ROOT
then git clone https://github.com/nodenv/nodenv.git $NODENV_ROOT
mkdir "$NODENV_ROOT/plugins"
git clone https://github.com/nodenv/node-build.git "$NODENV_ROOT"/plugins/node-build
else ok nodenv
fi
if ! test -e $PYENV_ROOT
then git clone https://github.com/pyenv/pyenv.git $PYENV_ROOT
else ok pyenv
fi
export GOBIN="$HOME/.local/bin"
export PATH="$GOBIN:$GOENV_ROOT/bin:$NODENV_ROOT/bin:$PYENV_ROOT/bin:$PATH"
eval "$(nodenv init -)"
nodenv install $NODENV_VERSION -s
echo $NODENV_VERSION >.node-version
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
pyenv install $PYENV_VERSION -s
echo $PYENV_VERSION >.python-version
eval "$(goenv init -)"
goenv install $GOENV_VERSION -s
echo $GOENV_VERSION >.go-version
# install task
if ! which task >/dev/null
then go install github.com/go-task/task/v3/cmd/task@latest
else ok task
fi
# install ansible
if ! which ansible >/dev/null
then pip install ansible
else ok ansible
fi
# install httpie
if ! which http >/dev/null
then pip install httpie
else ok httpie
fi
# install addlicense
if ! which license-eye >/dev/null
then go install github.com/apache/skywalking-eyes/cmd/license-eye@latest
else ok license-eye
fi
# install poetry
if ! which poetry >/dev/null
then curl -sSL https://install.python-poetry.org | python3 -
else ok poetry
fi
# install jest
if ! nodenv which jest >/dev/null
then npm install -g jest
else ok jest
fi
export PATH="$(nodenv prefix)/bin:$PATH"
# install coursier - disabled for now as not (yet) needed
#if ! which cs >/dev/null
#then curl -sfLo $HOME/.local/bin/cs https://git.io/coursier-cli-"$(uname | tr LD ld)"
# chmod +x $HOME/.local/bin/cs
#else ok coursier
#fi
#eval "$(cs setup --env 2>/dev/null)"
# extra
if test -e ~/.localrc
then source ~/.localrc
fi
# if there is a kubeconfig configuration, use it
if test -e kubeconfig
then export KUBECONFIG=$PWD/kubeconfig
fi
# a few aliases
alias l=l
alias ll="ls -l"
alias k="kubectl"
alias ka="kubectl apply"
alias kg="kubectl get"
alias kd="kubectl delete"
alias kns="kubectl config set-context --current --namespace"
# local setup
if test -e Taskfile.yml
then task setup
fi