chimney (nix old logs)
[webi-installers/.git] / caddy / caddy.bash
1 # title: Caddy
2 # homepage: https://github.com/caddyserver/caddy
3 # tagline: Fast, multi-platform web server with automatic HTTPS
4 # description: |
5 # Caddy is an extensible server platform that uses TLS by default.
6 # examples: |
7 #   ```bash
8 #   caddy start
9 #   ```
10
11 set -e
12 set -u
13
14 #################
15 # Install caddy #
16 #################
17
18 new_caddy="${HOME}/.local/bin/caddy"
19
20 # Test for existing version
21 set +e
22 cur_caddy="$(command -v caddy)"
23 set -e
24 if [ -n "$cur_caddy" ]; then
25   cur_ver=$(caddy version | head -n 1 | cut -d ' ' -f 2)
26   if [ "$cur_ver" == "$WEBI_VERSION" ]; then
27     echo "caddy v$WEBI_VERSION already installed at $cur_caddy"
28     exit 0
29   elif [ "$cur_caddy" != "$new_caddy" ]; then
30     echo "WARN: possible conflict with caddy v$WEBI_VERSION at $cur_caddy"
31   fi
32 fi
33
34 # Note: this file is `source`d by the true installer and hence will have the webi functions
35
36 # because we created releases.js we can use webi_download()
37 # downloads caddy to ~/Downloads
38 webi_download
39
40 # because this is tar or zip, we can webi_extract()
41 # extracts to the WEBI_TMP directory, raw (no --strip-prefix)
42 webi_extract
43
44 pushd "$WEBI_TMP" 2>&1 >/dev/null
45         echo Installing caddy v${WEBI_VERSION} as "$new_caddy"
46         mv ./caddy "$HOME/.local/bin/"
47 popd 2>&1 >/dev/null
48
49 ###################
50 #   Update PATH   #
51 ###################
52
53 # TODO get better output from pathman / output the path to add as return to webi bootstrap
54 webi_path_add "$HOME/.local/bin"
55
56 echo "Installed 'caddy'"
57 echo ""