-
Notifications
You must be signed in to change notification settings - Fork 0
/
install
executable file
·814 lines (796 loc) · 36.4 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
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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
#!/usr/bin/env bash
# get directory where this script lives
source_dir="$( cd "$( [[ -h "${BASH_SOURCE[0]}" ]] && dirname "$(readlink "${BASH_SOURCE[0]}")" || dirname "${BASH_SOURCE[0]}" )" && pwd )"
# source common defaults
source "${source_dir}/.defaults.sh"
# TODO add docker
section_profiles=(
act
alacritty
alacritty-terminfo
aws aws-cli
aws-sso aws-sso-cli
aws-sso-creds
bat
ble.sh blesh
delta
fzf
gh-cli
go
google-cloud-sdk
jd
jsonnet
jsonnet-lint
keybase
kubeval
most
muc
neovim
nmap
packages
packer
pre-commit
ssh-config
ssh-keys
terraform
terraform-docs
tfswitch
tmux
trash-cli
util-linux
vim
yank
yq
)
meta_profiles=(
all
home
work
local
remote
)
if [[ "$1" == "" || "$1" == "-h" || "$1" == "--help" || "$1" == "help" ]]; then
printf "section profiles:\n"
printf " %s\n" "${section_profiles[@]}" | sort | column
printf "meta profiles:\n"
printf " %s\n" "${meta_profiles[@]}" | sort | column
exit 2
fi
set -ex
declare -A dir
dir[base]="${HOME}/.local"
dir[bin]="${dir[base]}/bin"
dir[include]="${dir[base]}/include"
dir[lib]="${dir[base]}/lib"
dir[opt]="${dir[base]}/opt"
dir[share]="${dir[base]}/share"
dir[doc]="${dir[share]}/doc"
dir[man]="${dir[share]}/man"
dir[man1]="${dir[man]}/man1"
dir[xdg_data_home]="${XDG_DATA_HOME:-"${default[XDG_DATA_HOME]}"}"
dir[completions]="${dir[xdg_data_home]}/bash-completion/completions"
if [[ "${XDG_DATA_HOME}" == "${HOME}/.local/share" ]]; then
if [[ "${XDG_OVERRIDE}" != "true" ]]; then
echo "XDG_DATA_HOME is not set or is set to spec defaults"
echo "configure bash or run again with \"XDG_OVERRIDE=true\" in front"
exit 1
fi
fi
for key in "${!dir[@]}"; do mkdir -p "${dir[${key}]}"; done
# if "--install-pkgs" or "-p" arguments are given, enable package manager
if [[ "$1" == "--install-pkgs" || "$1" == "-p" ]]; then
if command -v apt-get &>/dev/null; then
family="deb"
pkg_mgr="sudo apt-get --ignore-missing"
elif command -v dnf &>/dev/null; then
family="rhel"
pkg_mgr="sudo dnf"
elif command -v yum &>/dev/null; then
family="rhel"
pkg_mgr="sudo yum"
else
echo "unknown linux family"
exit 1
fi
else
pkg_mgr=":"
fi
# make temp directory
dir[temp]="$(mktemp -d)"
chmod ugo+rx "${dir[temp]}"
cd "${dir[temp]}"
for profile in $@; do
case ${profile} in
act | all | home | work )
# install act
section="act"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
current_release="$(curl -sN https://api.github.com/repos/nektos/act/releases/latest | jq -r --arg kernel "$(uname -s)" --arg machine "$(uname -m)" '.assets[] | select(.name == "act_" + $kernel + "_" + $machine + ".tar.gz") | .browser_download_url')"
bin_name="act"
curl -fsLo "act.tar.gz" "${current_release}" && \
tar -x "${bin_name}" -f "act.tar.gz" && \
chmod u+x "${bin_name}" && \
mv -f "${bin_name}" "${dir[bin]}/${bin_name}"
cd "${dir[temp]}"
;;&
alacritty )
# install alacritty
section="alacritty"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
curl -sSfo "rust_install.sh" "https://sh.rustup.rs"
chmod u+x "rust_install.sh"
export CARGO_HOME="${PWD}/rust/.cargo"
export RUSTUP_HOME="${PWD}/rust/.rustup"
./rust_install.sh -q -y --no-modify-path --default-toolchain stable --profile minimal
prereqs_common=( cmake python3 )
prereqs_deb=( pkg-config libfreetype6-dev libfontconfig1-dev libxcb-xfixes0-dev )
prereqs_rpm=( freetype-devel fontconfig-devel libxcb-devel )
prereqs=( ${prereqs_common[@]} )
case ${family} in
deb) prereqs+=( ${prereqs_deb[@]} ) ;;
rhel) prereqs+=( ${prereqs_rpm[@]} ) ;;
esac
${pkg_mgr} install -y ${prereqs[@]}
latest_tarball="$(curl -sN "https://api.github.com/repos/alacritty/alacritty/releases/latest" | grep -Pom 1 '"tarball_url": "\K.*?(?=")')"
curl -sLo "${section}.tar.gz" "${latest_tarball}" && \
tar -xf "${section}.tar.gz" --strip 1 && \
"${PWD}/rust/.cargo/bin/cargo" build --release && \
mv -f "target/release/${section}" "${dir[bin]}/${section}" && \
mv -f "extra/alacritty.man" "${dir[man1]}/alacritty.1" && \
mv -f "extra/completions/alacritty.bash" "${dir[completions]}/alacritty" && \
tic -xe alacritty,alacritty-direct "extra/alacritty.info"
cd "${dir[temp]}"
;;&
alacritty-terminfo )
# install alacritty terminfo only
section="alacritty-terminfo"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
latest_tarball="$(curl -sN "https://api.github.com/repos/alacritty/alacritty/releases/latest" | grep -Pom 1 '"tarball_url": "\K.*?(?=")' | sed -E 's|(https://.*?/tarball/)(.*)|\1refs/tags/\2|')"
curl -sLo "${section}.tar.gz" "${latest_tarball}" && \
tar -xf "${section}.tar.gz" --strip 1 && \
tic -xe alacritty,alacritty-direct "extra/alacritty.info"
cd "${dir[temp]}"
;;&
aws | aws-cli | all | home | work )
# install aws cli v2
section="aws-cli"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
prereqs_common=()
prereqs_deb=( unzip )
prereqs_rpm=()
prereqs=( ${prereqs_common[@]} )
case ${family} in
deb) prereqs+=( ${prereqs_deb[@]} ) ;;
rhel) prereqs+=( ${prereqs_rpm[@]} ) ;;
esac
${pkg_mgr} install -y ${prereqs[@]}
curl -sLo "awscliv2.zip" "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip"
unzip awscliv2.zip
./aws/install --update --install-dir "${dir[opt]}/aws-cli" --bin-dir "${dir[bin]}"
cd "${dir[temp]}"
;;&
aws-sso | aws-sso-cli | all | home | work )
# install aws-sso cli
section="aws-sso"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
repo_name="synfinatic/${section}-cli"
system_type="$(uname -s)"
system_type="${system_type,,}"
machine_type="$(uname -m)"
if [[ "${machine_type}" == "x86_64" ]]; then machine_type="amd64"; fi
latest_release="$(curl -sN "https://api.github.com/repos/${repo_name}/releases/latest" | jq -r --arg system "${system_type}" --arg arch "${machine_type}" '.assets[] | select(.name | contains($system + "-" + $arch)) | .browser_download_url')"
curl -sLo "${section}" "${latest_release}" && \
cp -f "${section}" "${dir[bin]}/${section}" && \
chmod 755 "${dir[bin]}/${section}"
cd "${dir[temp]}"
;;&
aws-sso-creds | all | home | work )
# install aws-sso-creds
section="aws-sso-creds"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
repo_name="jaxxstorm/aws-sso-creds"
system_type="$(uname -s)"
system_type="${system_type,,}"
machine_type="$(uname -m)"
if [[ "${machine_type}" == "x86_64" ]]; then machine_type="amd64"; fi
latest_release="$(curl -sN "https://api.github.com/repos/${repo_name}/releases/latest" | jq -r --arg system "${system_type}" --arg arch "${machine_type}" '.assets[] | select(.name | contains($system + "-" + $arch)) | .browser_download_url')"
curl -sLo "${section}.tar.gz" "${latest_release}" && \
tar -xf "${section}.tar.gz" && \
cp -f "${section}" "${dir[bin]}/${section}" && \
chmod 755 "${dir[bin]}/${section}"
cd "${dir[temp]}"
;;&
bat | all | home | work )
# install bat
section="bat"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
curl -sSfo "rust_install.sh" "https://sh.rustup.rs"
chmod u+x "rust_install.sh"
export CARGO_HOME="${PWD}/rust/.cargo"
export RUSTUP_HOME="${PWD}/rust/.rustup"
./rust_install.sh -q -y --no-modify-path --default-toolchain stable --profile minimal
prereqs_common=( )
prereqs_deb=( )
prereqs_rpm=( )
prereqs=( ${prereqs_common[@]} )
case ${family} in
deb) prereqs+=( ${prereqs_deb[@]} ) ;;
rhel) prereqs+=( ${prereqs_rpm[@]} ) ;;
esac
if [[ ${#prereqs[@]} -gt 0 ]]; then
${pkg_mgr} install -y ${prereqs[@]}
fi
latest_tarball="$(curl -sN "https://api.github.com/repos/sharkdp/bat/releases/latest" | grep -Pom 1 '"tarball_url": "\K.*?(?=")')"
curl -sLo "${section}.tar.gz" "${latest_tarball}" && \
tar -xf "${section}.tar.gz" --strip 1 && \
"${PWD}/rust/.cargo/bin/cargo" build --release && \
mv -f "target/release/${section}" "${dir[bin]}/${section}" && \
sed -i "s/{{PROJECT_EXECUTABLE}}/${section}/g" "assets/completions/${section}.bash.in" "assets/manual/${section}.1.in" && \
sed -i "s/{{PROJECT_EXECUTABLE_UPPERCASE}}/${section^^}/g" "assets/manual/${section}.1.in" && \
mv -f "assets/completions/${section}.bash.in" "${dir[completions]}/${section}" && \
mv -f "assets/manual/${section}.1.in" "${dir[man1]}/${section}.1"
cd "${dir[temp]}"
;;&
ble.sh | blesh | all | home | work | remote | local )
# install blesh
section="ble.sh"
section_actual="blesh"
repo="akinomyoga/ble.sh"
echo "installing ${section}..."
mkdir "${section_actual}" && cd "${section_actual}"
prereqs_common=( git make gawk )
prereqs_deb=()
prereqs_rpm=()
prereqs=( ${prereqs_common[@]} )
case ${family} in
deb) prereqs+=( ${prereqs_deb[@]} ) ;;
rhel) prereqs+=( ${prereqs_rpm[@]} ) ;;
esac
${pkg_mgr} install -y ${prereqs[@]}
git clone --recursive https://github.com/${repo}.git ${PWD}
make all && \
make INSDIR="${dir[xdg_data_home]}/${section_actual}" install
sed -i "s|${dir[temp]}/${section_actual}|release:master|" "${dir[xdg_data_home]}/${section_actual}/ble.sh"
cd "${dir[temp]}"
;;&
delta | all | home | work )
# install delta
section="delta"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
curl -sSfo "rust_install.sh" "https://sh.rustup.rs"
chmod u+x "rust_install.sh"
export CARGO_HOME="${PWD}/rust/.cargo"
export RUSTUP_HOME="${PWD}/rust/.rustup"
./rust_install.sh -q -y --no-modify-path --default-toolchain stable --profile minimal
prereqs_common=( )
prereqs_deb=( )
prereqs_rpm=( )
prereqs=( ${prereqs_common[@]} )
case ${family} in
deb) prereqs+=( ${prereqs_deb[@]} ) ;;
rhel) prereqs+=( ${prereqs_rpm[@]} ) ;;
esac
if [[ ${#prereqs[@]} -gt 0 ]]; then
${pkg_mgr} install -y ${prereqs[@]}
fi
latest_tarball="$(curl -sN "https://api.github.com/repos/dandavison/delta/releases/latest" | grep -Pom 1 '"tarball_url": "\K.*?(?=")')"
curl -sLo "${section}.tar.gz" "${latest_tarball}" && \
tar -xf "${section}.tar.gz" --strip 1 && \
"${PWD}/rust/.cargo/bin/cargo" build --release && \
mv -f "target/release/${section}" "${dir[bin]}/${section}" && \
mv -f "etc/completion/completion.bash" "${dir[completions]}/delta"
cd "${dir[temp]}"
;;&
fzf | all | home | work )
# install fzf
section="fzf"
repo="junegunn/fzf"
version="0.28.0"
echo "installing ${section} v${version}..."
mkdir "${section}" && cd "${section}"
[[ -z ${latest_go} ]] && latest_go=$(git ls-remote --tags "https://github.com/golang/go" refs/tags/go* | awk -F '/' '{print $NF}' | sort -V | tail -n 1)
export GOPATH="${PWD}"
export GOBIN="${GOPATH}/bin"
curl -sLo "go.tar.gz" "https://dl.google.com/go/${latest_go}.linux-amd64.tar.gz" && \
tar -xf "go.tar.gz" && \
go/bin/go install "github.com/${repo}@${version}" && \
cp -f "bin/${section}" "${dir[bin]}/${section}" && \
rm -rf "${dir[xdg_data_home]}/fzf/fzf" && \
mkdir -p "${dir[xdg_data_home]}/fzf" && \
cp -a "$(find "pkg/mod/github.com" -type d -name "${section}*")" "${dir[xdg_data_home]}/fzf/fzf" && \
chmod -R u+w "${dir[xdg_data_home]}/fzf"
mkdir -p "${dir[man1]}" && \
cp -r "${dir[xdg_data_home]}/fzf/fzf/man/man1" "${dir[man]}"
cd "${dir[temp]}"
;;&
gh-cli | all | home | work )
# install github cli
section="gh-cli"
repo="cli/cli"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
release_file="${section}-linux-amd64.tar.gz"
latest_release="$(curl -sN "https://api.github.com/repos/${repo}/releases/latest" | jq -r '.assets[] | select(.name | test("gh_[0-9.]+_linux_amd64\\.tar\\.gz")).browser_download_url')"
curl -sL "${latest_release}" -o "${release_file}" && \
tar -xf "${release_file}" --strip 1 && \
mv -f bin/* "${dir[bin]}/" && \
mv -f share/man/man1/* "${dir[man1]}/"
cd "${dir[temp]}"
;;&
go | all | home | work )
# install go
section="go"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
[[ -z ${latest_go} ]] && latest_go=$(git ls-remote --tags https://github.com/golang/go refs/tags/go* | awk -F '/' '{print $NF}' | sort -V | tail -n 1)
curl -sLo "go.tar.gz" "https://dl.google.com/go/${latest_go}.linux-amd64.tar.gz"
tar -xf "go.tar.gz"
mkdir -p "${dir[opt]}/golang"
mv "go" "${dir[opt]}/golang/${latest_go}"
ln -fs "${dir[opt]}/golang/${latest_go}/bin/go" "${dir[bin]}/go"
ln -fs "${dir[opt]}/golang/${latest_go}/bin/gofmt" "${dir[bin]}/gofmt"
cd "${dir[temp]}"
;;&
google-cloud-sdk | all | work )
# install google-cloud-sdk
section="google-cloud-sdk"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
curl -sLo "gcloud_install.sh" "https://sdk.cloud.google.com/"
chmod u+x "gcloud_install.sh"
./gcloud_install.sh --disable-prompts --install-dir="${dir[opt]}"
${dir[opt]}/google-cloud-sdk/bin/gcloud -q components install alpha beta cloud_sql_proxy kubectl
ln -sf "${dir[opt]}/google-cloud-sdk/bin/cloud_sql_proxy" "${dir[bin]}/cloud_sql_proxy"
ln -sf "${dir[opt]}/google-cloud-sdk/bin/docker-credential-gcloud" "${dir[bin]}/docker-credential-gcloud"
ln -sf "${dir[opt]}/google-cloud-sdk/bin/gcloud" "${dir[bin]}/gcloud"
ln -sf "${dir[opt]}/google-cloud-sdk/bin/git-credential-gcloud.sh" "${dir[bin]}/git-credential-gcloud.sh"
ln -sf "${dir[opt]}/google-cloud-sdk/bin/gsutil" "${dir[bin]}/gsutil"
ln -sf "${dir[opt]}/google-cloud-sdk/bin/kubectl" "${dir[bin]}/kubectl"
ln -sf "${dir[opt]}/google-cloud-sdk/completion.bash.inc" "${dir[completions]}/google-cloud-sdk"
"${dir[bin]}/kubectl" completion bash >"${dir[completions]}/kubectl"
cd "${dir[temp]}"
;;&
jd | all | home | work )
# install jd
section="jd"
repo="josephburnett/jd"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
[[ -z ${latest_go} ]] && latest_go=$(git ls-remote --tags https://github.com/golang/go refs/tags/go* | awk -F '/' '{print $NF}' | sort -V | tail -n 1)
export GOPATH="${PWD}"
export GOBIN="${GOPATH}/bin"
curl -sLo "go.tar.gz" "https://dl.google.com/go/${latest_go}.linux-amd64.tar.gz" && \
tar -xf "go.tar.gz" && \
go/bin/go install "github.com/${repo}@latest" && \
mv -f "bin/${section}" "${dir[bin]}/${section}"
cd "${dir[temp]}"
;;&
jsonnet | all | home | work )
# install jsonnet
section="jsonnet"
repo="google/jsonnet"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
prereqs_common=( make g++ )
prereqs_deb=()
prereqs_rpm=()
prereqs=( ${prereqs_common[@]} )
case ${family} in
deb) prereqs+=( ${prereqs_deb[@]} ) ;;
rhel) prereqs+=( ${prereqs_rpm[@]} ) ;;
esac
${pkg_mgr} install -y ${prereqs[@]}
latest_tarball="$(curl -sN "https://api.github.com/repos/${repo}/releases/latest" | grep -Pom 1 '"tarball_url": "\K.*?(?=")')"
curl -sLo "${section}.tar.gz" "${latest_tarball}" && \
tar -xf "${section}.tar.gz" --strip 1 && \
make && \
PREFIX=${dir[base]} make install
cd "${dir[temp]}"
;;&
jsonnet-lint | all | home | work )
# install jsonnet-lint
section="jsonnet-lint"
repo="google/go-jsonnet/linter/jsonnet-lint"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
[[ -z ${latest_go} ]] && latest_go=$(git ls-remote --tags https://github.com/golang/go refs/tags/go* | awk -F '/' '{print $NF}' | sort -V | tail -n 1)
export GOPATH="${PWD}"
export GOBIN="${GOPATH}/bin"
curl -sLo "go.tar.gz" "https://dl.google.com/go/${latest_go}.linux-amd64.tar.gz" && \
tar -xf "go.tar.gz" && \
go/bin/go install "github.com/${repo}@latest" && \
mv -f "bin/${section}" "${dir[bin]}/${section}"
cd "${dir[temp]}"
;;&
keybase | all | home | work )
# install keybase
echo "installing keybase..."
mkdir "keybase" && cd "keybase"
if ! command -v keybase &>/dev/null; then
case ${family} in
deb) keybase_file="keybase_amd64.deb" ;;
rhel) keybase_file="keybase_amd64.rpm" ;;
esac
curl -sO "https://prerelease.keybase.io/${keybase_file}"
chmod ugo+r "${keybase_file}"
${pkg_mgr} install -y "./${keybase_file}"
fi
run_keybase -g
cd "${dir[temp]}"
;;&
kubeval | all | work | remote | local )
# install kubeval
section="kubeval"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
release_file="${section}-linux-amd64.tar.gz"
latest_release="https://github.com/instrumenta/${section}/releases/latest/download/${release_file}"
curl -sLO "${latest_release}" && \
tar -xf "${release_file}" && \
mv -f "${section}" "${dir[bin]}/${section}"
cd "${dir[temp]}"
;;&
most )
# install most
section="most"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
prereqs_common=( make gcc )
prereqs_deb=( libpcre3-dev libonig-dev libpng-dev zlib1g-dev )
prereqs_rpm=( pcre-devel onigurama-devel libpng-devel zlib-devel )
prereqs=( ${prereqs_common[@]} )
case ${family} in
deb) prereqs+=( ${prereqs_deb[@]} ) ;;
rhel) prereqs+=( ${prereqs_rpm[@]} ) ;;
esac
${pkg_mgr} install -y ${prereqs[@]}
git clone "git://git.jedsoft.org/git/slang.git" "./repo-slang"
git clone "git://git.jedsoft.org/git/most.git" "./repo-most"
slang_commit="a0f675ffdd5ac07789ee65900b4f88a9ba60e67c" # 2.3.3 (2022-08-05)
cd "./repo-slang"
git checkout "${slang_commit}"
./configure --prefix="${dir[base]}"
make install
make install-static
most_commit="8fd49788d22ef3733b4a78e7c2f752c656695af8" # 5.2.0 (2022-08-04)
cd "../repo-most"
git checkout "${most_commit}"
./configure --prefix="${dir[base]}"
make install
cd "${dir[temp]}"
;;&
muc )
# install muc
section="muc"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
curl -sSfo "rust_install.sh" "https://sh.rustup.rs"
chmod u+x "rust_install.sh"
export CARGO_HOME="${PWD}/rust/.cargo"
export RUSTUP_HOME="${PWD}/rust/.rustup"
./rust_install.sh -q -y --no-modify-path --default-toolchain stable --profile minimal
prereqs_common=( )
prereqs_deb=( )
prereqs_rpm=( )
prereqs=( ${prereqs_common[@]} )
case ${family} in
deb) prereqs+=( ${prereqs_deb[@]} ) ;;
rhel) prereqs+=( ${prereqs_rpm[@]} ) ;;
esac
if [[ ${#prereqs[@]} -gt 0 ]]; then
${pkg_mgr} install -y ${prereqs[@]}
fi
"${PWD}/rust/.cargo/bin/cargo" install --git=https://github.com/nate-sys/muc && \
mv -f "${PWD}/rust/.cargo/bin/${section}" "${dir[bin]}/${section}"
cd "${dir[temp]}"
;;&
neovim | all | home | work | remote | local )
# install neovim
section="neovim"
repo="neovim/neovim"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
prereqs_common=( ninja-build autoconf libtool automake cmake unzip )
prereqs_deb=( gettext libtool-bin g++ pkg-config )
prereqs_rpm=( gcc gcc-c++ pkgconfig patch make )
prereqs=( ${prereqs_common[@]} )
case ${family} in
deb) prereqs+=( ${prereqs_deb[@]} ) ;;
rhel) prereqs+=( ${prereqs_rpm[@]} ) ;;
esac
${pkg_mgr} install -y ${prereqs[@]}
latest_tarball="$(curl -sN "https://api.github.com/repos/${repo}/releases/latest" | grep -Pom 1 '"tarball_url": "\K.*?(?=")')"
curl -sLo "${section}.tar.gz" "${latest_tarball}" && \
tar -xf "${section}.tar.gz" --strip 1 && \
make \
CMAKE_BUILD_TYPE=Release \
CMAKE_INSTALL_PREFIX="${dir[base]}" \
install
cd "${dir[temp]}"
;;&
nmap | all | home | work )
# install nmap
section="nmap"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
prereqs_common=( ca-certificates subversion gcc python3 make g++ autoconf )
prereqs_deb=( libssh2-1-dev libssl-dev )
prereqs_rpm=( libssh2-devel openssl-devel )
prereqs=( ${prereqs_common[@]} )
case ${family} in
deb) prereqs+=( ${prereqs_deb[@]} ) ;;
rhel) prereqs+=( ${prereqs_rpm[@]} ) ;;
esac
${pkg_mgr} install -y ${prereqs[@]}
svn checkout https://svn.nmap.org/nmap/ . && \
mkdir -p install/local/share && \
./configure --prefix "${PWD}/install" --exec-prefix "${PWD}/install/local" --datarootdir "${PWD}/install/local/share" && \
make && \
make install && \
cp -r "install/local/bin/"* "${dir[bin]}" && \
cp -r "install/local/lib/"* "${dir[lib]}" && \
cp -r "install/local/share/"* "${dir[share]}"
cd "${dir[temp]}"
;;&
packages | all | home | work )
# install packages
echo "installing packages..."
mkdir "packages" && cd "packages"
case ${family} in
deb) ${pkg_mgr} update ;;
rhel) ${pkg_mgr} makecache ;;
esac
packages_common=( git vim curl wget python3 python3-pip unzip sysstat pkg-config htop bash-completion )
packages_deb=( apt-file python3-venv )
packages_rpm=()
packages=( ${packages_common[@]} )
case ${family} in
deb) packages+=( ${packages_deb[@]} ) ;;
rhel) packages+=( ${packages_rpm[@]} ) ;;
esac
${pkg_mgr} install -y ${packages[@]}
cd "${dir[temp]}"
;;&
packer | all | home | work )
# install packer
section="packer"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
# put version to be referred to as naked name last
versions=( "1.9.1" )
for version in "${versions[@]}"; do
curl -sO "https://releases.hashicorp.com/${section}/${version}/${section}_${version}_linux_amd64.zip"
unzip *
rm "${section}_${version}_linux_amd64.zip"
mv ${section} "${dir[bin]}/${section}-${version}"
done
ln -sf "${dir[bin]}/${section}-${version}" "${dir[bin]}/${section}"
cd "${dir[temp]}"
;;&
pre-commit | all | home | work )
# install pre-commit
echo "installing pre-commit..."
mkdir "pre-commit" && cd "pre-commit"
python3 -m pip install --user pre-commit
cd "${dir[temp]}"
;;&
ssh-config | all | home | work )
# install basic ssh-config
echo "installing basic ssh config..."
mkdir "ssh-config" && cd "ssh-config"
if [[ ! -d "${HOME}/.ssh" ]]; then
mkdir -p "${HOME}/.ssh"
chmod 700 "${HOME}/.ssh"
fi
if [[ ! -f "${HOME}/.ssh/config" ]]; then
cat >"${HOME}/.ssh/config" << EOL
Host *
CanonicalizeHostname yes
PreferredAuthentications publickey
ServerAliveInterval 60
Host github.com
IdentityFile ~/.ssh/${HOSTNAME}-to-github
User rux616
EOL
chmod 644 "${HOME}/.ssh/config"
fi
cd "${dir[temp]}"
;;&
ssh-keys | all | home | work )
# create some basic ssh keys
echo "creating basic ssh keys..."
mkdir "ssh-keys" && cd "ssh-keys"
names=( "${HOSTNAME}-to-github" )
types=( "ed25519" )
for ((i=0; i<${#names[@]}; i++)); do
if [[ ! -f "${HOME}/.ssh/${names[$i]}" ]]; then
ssh-keygen -q -t ${types[$i]} -C "${USER}@${names[$i]}" -N "" -f "${HOME}/.ssh/${names[$i]}"
fi
done
cd "${dir[temp]}"
;;&
terraform | all | work )
# install terraform
section="terraform"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
# put version to be referred to as naked name last
versions=( "0.11.14" "0.12.29" "0.12.30" "0.13.6" "0.14.9" )
for version in "${versions[@]}"; do
curl -sO "https://releases.hashicorp.com/${section}/${version}/${section}_${version}_linux_amd64.zip"
unzip *
rm "${section}_${version}_linux_amd64.zip"
mv ${section} "${dir[bin]}/${section}-${version}"
ln -sf "${dir[bin]}/${section}-${version}" "${dir[bin]}/${section}-${version%.*}"
done
ln -sf "${dir[bin]}/${section}-${version}" "${dir[bin]}/${section}"
cd "${dir[temp]}"
;;&
terraform-docs | all | work )
# install terraform-docs
section="terraform-docs"
repo="terraform-docs/terraform-docs"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
version="$(curl -sS "https://api.github.com/repos/${repo}/releases?per_page=1" | jq -r '.[].tag_name')"
curl -sLo "terraform-docs.tar.gz" "https://github.com/${repo}/releases/download/${version}/terraform-docs-${version}-$(uname)-amd64.tar.gz" && \
tar -xzf "terraform-docs.tar.gz" && \
chmod +x "terraform-docs" && \
mv -f "terraform-docs" "${dir[bin]}/terraform-docs"
cd "${dir[temp]}"
;;&
tfswitch | all | home | work )
# install terraform-switcher
section="terraform-switcher"
repo="warrensbox/terraform-switcher"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
[[ -z ${latest_go} ]] && latest_go=$(git ls-remote --tags https://github.com/golang/go refs/tags/go* | awk -F '/' '{print $NF}' | sort -V | tail -n 1)
export GOPATH="${PWD}"
export GOBIN="${GOPATH}/bin"
curl -sLo "go.tar.gz" "https://dl.google.com/go/${latest_go}.linux-amd64.tar.gz" && \
tar -xf "go.tar.gz" && \
go/bin/go install "github.com/${repo}@$(curl -sS "https://api.github.com/repos/${repo}/releases?per_page=1" | jq -r '.[].tag_name')" && \
mv -f "bin/${section}" "${dir[bin]}/tfswitch"
cd "${dir[temp]}"
;;&
tmux | all | home | work )
# install tmux
section="tmux"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
prereqs_common=( autoconf bison libtool automake )
prereqs_deb=( autopoint gettext libncurses-dev libevent-dev )
prereqs_rpm=( gettext-devel ncurses-devel libevent-devel )
prereqs=( ${prereqs_common[@]} )
case ${family} in
deb) prereqs+=( ${prereqs_deb[@]} ) ;;
rhel) prereqs+=( ${prereqs_rpm[@]} ) ;;
esac
${pkg_mgr} install -y ${prereqs[@]}
latest_tarball="$(curl -sN "https://api.github.com/repos/tmux/tmux/releases/latest" | grep -Pom 1 '"tarball_url": "\K.*?(?=")')"
curl -sLo "${section}.tar.gz" "${latest_tarball}" && \
tar -xf "${section}.tar.gz" --strip 1 && \
./autogen.sh && \
./configure --prefix="${dir[base]}" && \
make && \
make install
cd "${dir[temp]}"
;;&
trash-cli | all | home | work | remote | local )
# install trash-cli
section="trash-cli"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
prereqs_common=( python3-pip )
prereqs_deb=()
prereqs_rpm=()
prereqs=( ${prereqs_common[@]} )
case ${family} in
deb) prereqs+=( ${prereqs_deb[@]} ) ;;
rhel) prereqs+=( ${prereqs_rpm[@]} ) ;;
esac
${pkg_mgr} install -y ${prereqs[@]}
latest_tarball="$(curl -sN "https://api.github.com/repos/andreafrancia/trash-cli/tags" | grep -Pom 1 '"tarball_url": "\K.*?(?=")')"
curl -sLo "${section}.tar.gz" "${latest_tarball}" && \
tar -xf "${section}.tar.gz" --strip 1 && \
python3 setup.py install --user
mkdir -p "${dir[xdg_data_home]}/Trash"
cd "${dir[temp]}"
;;&
util-linux | all | home | work )
# install the *full* util-linux, which some distros don't seem to have
section="util-linux"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
prereqs_common=( autoconf bison libtool automake )
prereqs_deb=( autopoint gettext libncurses-dev libpam0g-dev libcap-ng-dev )
prereqs_rpm=( gettext-devel ncurses-devel pam-devel libcap-ng-devel )
prereqs=( ${prereqs_common[@]} )
case ${family} in
deb) prereqs+=( ${prereqs_deb[@]} ) ;;
rhel) prereqs+=( ${prereqs_rpm[@]} ) ;;
esac
${pkg_mgr} install -y ${prereqs[@]}
latest_tarball="$(curl -sN "https://api.github.com/repos/util-linux/util-linux/tags" | grep -Pom 1 '"tarball_url": "\K.*?(?=")')"
curl -sLo "${section}.tar.gz" "${latest_tarball}" && \
tar -xf "${section}.tar.gz" --strip 1 && \
./autogen.sh && \
./configure --prefix="${dir[base]}" && \
make && \
sudo make install && \
sudo chown -R ${USER}:${USER} "${dir[base]}"
cd "${dir[temp]}"
;;&
vim | all | home | work | remote | local )
# install vim
section="vim"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
# TODO --BEGIN--
# TODO check what the actual prereqs are
# TODO for now, run after installing tmux and/or util-linux
#prereqs_common=( autoconf bison libtool automake python3 python3-dev )
#prereqs_deb=( autopoint gettext libncurses-dev libncurses5-dev libevent-dev )
#prereqs_rpm=( gettext-devel ncurses-devel libevent-devel )
#prereqs=( ${prereqs_common[@]} )
#case ${family} in
# deb) prereqs+=( ${prereqs_deb[@]} ) ;;
# rhel) prereqs+=( ${prereqs_rpm[@]} ) ;;
#esac
#${pkg_mgr} install -y ${prereqs[@]}
# TODO --END--
latest_tarball="$(curl -sN "https://api.github.com/repos/vim/vim/tags" | grep -Pom 1 '"tarball_url": "\K.*?(?=")')"
curl -sLo "${section}.tar.gz" "${latest_tarball}" && \
tar -xf "${section}.tar.gz" --strip 1 && \
./configure \
--with-features=huge \
--enable-python3interp=yes \
--with-python3-config-dir="$(python3-config --configdir)" \
--prefix="${dir[base]}" && \
make && \
make install
cd "${dir[temp]}"
;;&
yank | all | home | work )
# install 'yank' script
section="yank"
echo "installing ${section}..."
mkdir "${section}" && cd "${section}"
curl -sLo "${section}" "https://github.com/sunaku/home/raw/master/bin/yank" && \
chmod u+x "${section}" && \
mv -f "${section}" "${dir[bin]}/${section}"
cd "${dir[temp]}"
;;&
yq | all | home | work )
# install yq
section="yq"
echo "Installing ${section}..."
mkdir "${section}" && cd "${section}"
system_type="$(uname -s)"
system_type="${system_type,,}"
machine_type="$(uname -m)"
if [[ "${machine_type}" == "x86_64" ]]; then machine_type="amd64"; fi
release_name="${section}_${system_type}_${machine_type}"
release_file_type=".tar.gz"
release_file="${release_name}${release_file_type}"
curl -sLo "${release_file}" "https://github.com/mikefarah/${section}/releases/latest/download/${release_file}" && \
tar -xf "${release_file}" && \
cp -f "${section}.1" "${dir[man1]}" && \
cp -f "${release_name}" "${dir[bin]}/${section}"
cd "${dir[temp]}"
;;&
esac
done
# cleanup
find "${dir[temp]}" -type d -print0 | xargs -0 chmod u+w
rm -rf "${dir[temp]}"
unset dir key family pkg_mgr packages_common packages_deb packages_rpm packages versions names types section section_actual prereqs_common prereqs_deb prereqs_rpm prereqs latest_tarball latest_version keybase_file CARGO_HOME RUSTUP_HOME repo latest_go