refactor: finish moving ssh-* scripts to own installers
[webi-installers/.git] / caddy / install.sh
1 #!/bin/bash
2
3 # "This is too simple" you say! "Where is the magic!?" you ask.
4 # There is no magic!
5 # The custom functions for Caddy are here.
6 # The generic functions - version checks, download, extract, etc - are here:
7 #   - https://github.com/webinstall/packages/branches/master/_webi/template.sh
8
9 set -e
10 set -u
11
12 pkg_cmd_name="caddy"
13
14 # IMPORTANT: this let's other functions know to expect this to be a single file
15 WEBI_SINGLE=true
16
17 function pkg_get_current_version() {
18     # 'caddy version' has output in this format:
19     #       v2.1.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=
20     # This trims it down to just the version number:
21     #       2.1.0
22     echo "$(caddy version 2> /dev/null | head -n 1 | cut -d' ' -f1 | sed 's:^v::')"
23 }
24
25 function pkg_install() {
26     # $HOME/.local/opt/caddy-v2.1.0/bin
27     mkdir -p "$pkg_src_bin"
28
29     # mv ./caddy* "$HOME/.local/opt/caddy-v2.1.0/bin/caddy"
30     mv ./"$pkg_cmd_name"* "$pkg_src_cmd"
31
32     # chmod a+x "$HOME/.local/opt/caddy-v2.1.0/bin/caddy"
33     chmod a+x "$pkg_src_cmd"
34 }
35
36 function pkg_link() {
37     # rm -f "$HOME/.local/bin/caddy"
38     rm -f "$pkg_dst_cmd"
39
40     # ln -s "$HOME/.local/opt/caddy-v2.1.0/bin/caddy" "$HOME/.local/bin/caddy"
41     ln -s "$pkg_src_cmd" "$pkg_dst_cmd"
42 }