158316cc8b6269f086c655e0bf2ee7b79ee3284a
[webi-installers/.git] / k9s / install.sh
1 #!/bin/bash
2
3 function __init_k9s() {
4     set -e
5     set -u
6
7     ##################
8     # Install k9s #
9     ##################
10
11     # Every package should define these 6 variables
12     pkg_cmd_name="k9s"
13
14     pkg_dst_cmd="$HOME/.local/bin/k9s"
15     pkg_dst="$pkg_dst_cmd"
16
17     pkg_src_cmd="$HOME/.local/opt/k9s-v$WEBI_VERSION/bin/k9s"
18     pkg_src_dir="$HOME/.local/opt/k9s-v$WEBI_VERSION"
19     pkg_src="$pkg_src_cmd"
20
21     # pkg_install must be defined by every package
22     pkg_install() {
23         # ~/.local/opt/k9s-v0.99.9/bin
24         mkdir -p "$(dirname $pkg_src_cmd)"
25
26         # mv ./k9s-*/k9s ~/.local/opt/k9s-v0.99.9/bin/k9s
27         mv k9s "$pkg_src_cmd"
28     }
29
30     # pkg_get_current_version is recommended, but (soon) not required
31     pkg_get_current_version() {
32         # 'k9s version' has output in this format:
33
34         # Version:    v0.24.2
35         # Commit:     f929114ae4679c89ca06b2833d8a0fca5f1ec69d
36         # Date:       2020-12-04T17:42:10Z
37
38         # This trims it down to just the version number:
39         # 0.24.2
40         echo $(k9s version 2> /dev/null | grep Version: | cut -d 'v' -f 2)
41     }
42
43 }
44
45 __init_k9s