bugfix(vim-shfmt): fix package name
[webi-installers/.git] / serviceman / install.sh
1 #!/bin/bash
2
3 function __init_serviceman() {
4     set -e
5     set -u
6
7     ######################
8     # Install serviceman #
9     ######################
10
11     # Every package should define these 6 variables
12     pkg_cmd_name="serviceman"
13
14     pkg_dst_cmd="$HOME/.local/bin/serviceman"
15     pkg_dst="$pkg_dst_cmd"
16
17     pkg_src_cmd="$HOME/.local/opt/serviceman-v$WEBI_VERSION/bin/serviceman"
18     pkg_src_dir="$HOME/.local/opt/serviceman-v$WEBI_VERSION"
19     pkg_src="$pkg_src_cmd"
20
21     pkg_install() {
22         # $HOME/.local/opt/serviceman-v0.8.0/bin
23         mkdir -p "$pkg_src_bin"
24
25         # mv ./serviceman* "$HOME/.local/opt/serviceman-v0.8.0/bin/serviceman"
26         mv ./"$pkg_cmd_name"* "$pkg_src_cmd"
27
28         # chmod a+x "$HOME/.local/opt/serviceman-v0.8.0/bin/serviceman"
29         chmod a+x "$pkg_src_cmd"
30     }
31
32     pkg_get_current_version() {
33         # 'serviceman version' has output in this format:
34         #       serviceman v0.8.0 (f3ab547) 2020-12-02T16:19:10-07:00
35         # This trims it down to just the version number:
36         #       0.8.0
37         echo "$(serviceman --version 2> /dev/null | head -n 1 | cut -d' ' -f2 | sed 's:^v::')"
38     }
39
40 }
41
42 __init_serviceman