-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtools_to_update.sh
executable file
·303 lines (277 loc) · 9.28 KB
/
tools_to_update.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
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
#!/bin/bash
DOTFILEDIR="${HOME}/dotfiles"
DESKTOPBIN="${HOME}/desktop_bin"
LOCALBIN="${DOTFILEDIR}/local/bin"
# zsh-git-prompt
zsh-git-prompt() {
echo "+++++++ Installing / Updating zsh-git-prompt +++++++"
local git_prompt_dir
git_prompt_dir="$(mktemp -d git_prompt.XXXXXXXXX)"
git clone "https://github.com/starcraftman/zsh-git-prompt.git" "${git_prompt_dir}"
cp "${git_prompt_dir}/zshrc.sh" "${DOTFILEDIR}/local/lib/git_prompt/zshrc.sh"
cp "${git_prompt_dir}/gitstatus.py" "${DOTFILEDIR}/local/lib/git_prompt/gitstatus.py"
rm -rf "${git_prompt_dir}"
}
# Tools needed for reducing go binary sizes
go_tools() {
if [[ -n "${go_tools_installed}" ]]; then
return 0
fi
go install github.com/pwaller/goupx@latest
go_tools_installed=1
}
# peco
peco() {
echo "+++++++ Installing / Updating peco +++++++"
go_tools
if [[ ! -d "${GOPATH}/src/github.com/peco/peco" ]]; then
mkdir -p "${GOPATH}/src/github.com/peco"
pushd "${GOPATH}/src/github.com/peco" &>/dev/null || return
git clone "https://github.com/peco/peco"
popd &>/dev/null || return
fi
pushd "${GOPATH}/src/github.com/peco/peco" &>/dev/null || return
git pull
#make build
GO111MODULE=on go build -ldflags="-s -w" cmd/peco/peco.go
~/go-workspace/bin/goupx peco
cp peco "${LOCALBIN}/peco"
setfattr -n user.pax.flags -v m "${LOCALBIN}/peco"
popd &>/dev/null || return
}
# Technically fasd too, but it hasn't been updated in forever
# https://github.com/clvv/fasd
# Gron
gron() {
echo "+++++++ Installing / Updating gron +++++++"
go_tools
if [[ ! -d "${GOPATH}/src/github.com/tomnomnom/gron" ]]; then
mkdir -p "${GOPATH}/src/github.com/tomnomnom"
pushd "${GOPATH}/src/github.com/tomnomnom" &>/dev/null || return
git clone "https://github.com/tomnomnom/gron"
popd &>/dev/null || return
fi
pushd "${GOPATH}/src/github.com/tomnomnom/gron" &>/dev/null || return
git pull
CGO_ENABLED=0 go build -ldflags="-s -w"
~/go-workspace/bin/goupx gron
cp gron "${LOCALBIN}/gron"
setfattr -n user.pax.flags -v m "${LOCALBIN}/gron"
popd &>/dev/null || return
}
# the_silver_searcher
silver-search() {
echo "+++++++ Installing / Updating silver-searcher +++++++"
local silver_search
silver_search="$(mktemp -d silver_search.XXXXXXXXX)"
git clone "https://github.com/ggreer/the_silver_searcher.git" "${silver_search}"
pushd "${silver_search}" &>/dev/null || return
./build.sh
cp ag "${LOCALBIN}/ag"
popd &>/dev/null || return
rm -rf "${silver_search}"
}
# Rust
rust() {
if [[ -n "${rust_installed}" ]]; then
return 0
fi
echo "+++++++ Installing / Updating rust +++++++"
if ! command -v rustup &>/dev/null; then
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
fi
rustup target add x86_64-unknown-linux-musl
rustup update
rust_installed=1
}
# ripgrep
ripgrep() {
rust
# shellcheck disable=SC1091
source "$HOME/.cargo/env"
echo "+++++++ Installing / Updating ripgrep +++++++"
local rg
echo "If this doesn't work, you may have to run the instructions here: https://github.com/BurntSushi/ripgrep#building"
rg="$(mktemp -d ripgrep.XXXXXXXXX)"
git clone "https://github.com/BurntSushi/ripgrep" "${rg}"
pushd "${rg}" &>/dev/null || return
sed -i '/^\[profile.release]$/a opt-level = "z"' Cargo.toml
sed -i '/^\[profile.release]$/a lto = true' Cargo.toml
sed -i '/^\[profile.release]$/a codegen-units = 1' Cargo.toml
PCRE2_SYS_STATIC=1 cargo build --release --target x86_64-unknown-linux-musl --features 'pcre2'
strip target/x86_64-unknown-linux-musl/release/rg
cp target/x86_64-unknown-linux-musl/release/rg "${LOCALBIN}/rg"
popd &>/dev/null || return
rm -rf "${rg}"
}
# bfs (breadth first search)
bfs() {
echo "+++++++ Installing / Updating bfs +++++++"
local bfs
bfs="$(mktemp -d bfs.XXXXXXXXX)"
git clone "https://github.com/tavianator/bfs.git" "${bfs}/bfs_build"
cp build/bfs/build_static_bfs.sh "${bfs}"
cp build/bfs/Dockerfile "${bfs}"
pushd "${bfs}" &>/dev/null || return
#make LDFLAGS="-static"
docker build -t bfs_builder:latest .
docker run -ti --rm -v "$(pwd):/output" bfs_builder:latest
cp bfs "${LOCALBIN}/bfs"
popd &>/dev/null || return
rm -rf "${bfs}"
}
# dive - now pulled with binman
dive() {
echo "+++++++ Installing / Updating dive +++++++"
local dive
prompt_for_release "https://github.com/wagoodman/dive/releases"
#dive_release="0.9.2"
dive="$(mktemp -d dive.XXXXXXXXX)"
pushd "${dive}" &>/dev/null || return
wget "https://github.com/wagoodman/dive/releases/download/v${release}/dive_${release}_linux_amd64.tar.gz"
tar xf "dive_${release}_linux_amd64.tar.gz"
cp dive "${DESKTOPBIN}/dive"
popd &>/dev/null || return
rm -rf "${dive}"
}
# Reg - Not really updated any longer
reg() {
echo "+++++++ Installing / Updating reg +++++++"
go get -v github.com/genuinetools/reg
cp "${GOPATH}/bin/reg" "${DESKTOPBIN}/reg"
}
# Lab
lab() {
echo "+++++++ Installing / Updating lab +++++++"
local lab
lab="$(mktemp -d lab.XXXXXXXXX)"
git clone "https://github.com/zaquestion/lab.git" "${lab}"
pushd "${lab}" &>/dev/null || return
make
cp lab "${DESKTOPBIN}/lab"
popd &>/dev/null || return
rm -rf "${lab}"
}
# Helm & Tiller - now pulled with binman
helm() {
echo "+++++++ Installing / Updating helm +++++++"
prompt_for_release "https://github.com/helm/helm/releases"
wget -O "${HOME}/Downloads/helm.tar.gz" "https://get.helm.sh/helm-v${release}-linux-amd64.tar.gz"
tar -xC "${DESKTOPBIN}" -f ~/Downloads/helm.tar.gz --strip-components=1 linux-amd64/helm
}
# kubectl - now pulled with binman
kubectl() {
echo "+++++++ Installing / Updating kubectl +++++++"
local kube
kube="$(mktemp -d kubectl.XXXXXXXXX)"
pushd "${kube}" &>/dev/null || return
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod 755 kubectl
cp kubectl "${DESKTOPBIN}/kubectl"
popd &>/dev/null || return
rm -rf "${kube}"
}
# kubectx - now pulled with binman
kubectx() {
echo "+++++++ Installing / Updating kubectx +++++++"
prompt_for_release "https://github.com/ahmetb/kubectx/releases"
#kubectx_release="0.9.4"
wget -O "${HOME}/Downloads/kubectx.tar.gz" "https://github.com/ahmetb/kubectx/releases/download/v${release}/kubectx_v${release}_linux_x86_64.tar.gz"
tar -xC "${DESKTOPBIN}" -f ~/Downloads/kubectx.tar.gz kubectx
}
# aws - Adds the AWS CLI
aws_cli() {
echo "+++++++ Installing / Updating aws_cli +++++++"
local aws_cli
aws_cli="$(mktemp -d aws_cli.XXXXXXXXX)"
pushd "${aws_cli}" &>/dev/null || return
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
./aws/install -i "${HOME}/.aws-cli" -b "${DESKTOPBIN}" --update
popd &>/dev/null || return
rm -rf "${aws_cli}"
}
# Installs haskall stack for installing other haskall programs
haskell_stack() {
if [[ -n "${haskell_stack}" ]]; then
return 0
fi
echo "+++++++ Installing / Updating haskell stack +++++++"
if ! command -v stack &>/dev/null; then
curl -sSL https://get.haskellstack.org/ | sh
fi
stack upgrade
haskell_stack=1
}
# hadolint - now pulled with binman
hadolint() {
haskell_stack
echo "+++++++ Installing / Updating hadolint +++++++"
# Requires: haskell-platform and haskell-stack in order to function
local hadolint
hadolint="$(mktemp -d hadolint.XXXXXXXXX)"
git clone "https://github.com/hadolint/hadolint" "${hadolint}"
pushd "${hadolint}" &>/dev/null || return
stack install
popd &>/dev/null || return
rm -rf "${hadolint}"
}
# rancher
rancher() {
echo "+++++++ Installing / Updating rancher +++++++"
prompt_for_release "https://github.com/rancher/cli/releases"
wget -O "${HOME}/Downloads/rancher.tar.gz" "https://github.com/rancher/cli/releases/download/v${release}/rancher-linux-amd64-v${release}.tar.xz"
tar -xC "${DESKTOPBIN}" --strip-components=2 -f ~/Downloads/rancher.tar.gz "./rancher-v${release}/rancher"
}
# socat - builds a statically linked socat binary
socat() {
echo "+++++++ Installing / Updating socat +++++++"
local socat_dir
socat_dir="$(mktemp -d socat.XXXXXXXXX)"
cp build/socat/build_static_socat.sh "${socat_dir}"
cp build/socat/Dockerfile "${socat_dir}"
cp -a build/socat/patches "${socat_dir}"
pushd "${socat_dir}" &>/dev/null || return
docker build -t socat_builder:latest .
docker run -ti --rm -v "$(pwd):/output" socat_builder:latest
cp socat "${LOCALBIN}/socat"
popd &>/dev/null || return
rm -rf "${socat_dir}"
}
prompt_for_release() {
printf "Need to find which release to use, go to %s and then return here and enter the version number.\n" "${1}"
printf "If your version has a 'v' in it, omit the 'v'\n"
printf "Version Number: "
read -r release
}
all() {
echo "+++++++ Before continuing make sure to install the following: +++++++"
printf "+++++++ apt-get install -y libonig-dev golang-go musl-dev musl-tools attr upx libacl1-dev libattr1-dev"
printf "libcap-dev skopeo dconf-editor yamllint liburing-dev +++++++\n"
printf "You must also install Docker, follow the instructions here: https://docs.docker.com/engine/install/ubuntu/\n"
read -r
zsh-git-prompt
peco
gron
ripgrep
bfs
aws_cli
rancher
socat
}
list() {
echo "zsh-git-prompt, peco, gron, silver-serach, ripgrep, bfs, dive, reg, lab, helm, kubectx, aws_cli, hadolint,"
echo "rancher, socat"
}
main() {
local rust_installed go_tools_installed haskell_stack
case "${1}" in
zsh-git-prompt|peco|gron|silver-search|ripgrep|bfs|dive|reg|lab|helm|kubectx|kubectl|aws_cli|hadolint|\
rancher|socat|list|all)
${1}
;;
*)
echo "that wasn't a command we recognize"
esac
}
main "${@}"