refactor: finish moving ssh-* scripts to own installers
[webi-installers/.git] / gitea / install.sh
1 #!/bin/bash
2 set -e
3 set -u
4
5 pkg_cmd_name="gitea"
6 pkg_src_cmd="$HOME/.local/opt/gitea-v$WEBI_VERSION/gitea"
7 pkg_dst_cmd="$HOME/.local/opt/gitea/gitea"
8
9 function pkg_get_current_version() {
10     # 'gitea version' has output in this format:
11     #       v2.1.0 h1:pQSaIJGFluFvu8KDGDODV8u4/QRED/OPyIR+MWYYse8=
12     # This trims it down to just the version number:
13     #       2.0.0
14     echo "$(gitea --version 2> /dev/null | head -n 1 | cut -d' ' -f3)"
15 }
16
17 function pkg_link() {
18     # although gitea is a single command it must be put in its own directory
19     # because it will always resolve its working path to its location,
20     # regardless of where it was started, where its config file lives, etc.
21     rm -rf "$pkg_dst_cmd"
22     mkdir -p "$pkg_dst_bin/custom"
23     chmod a+x "$pkg_src_cmd"
24     ln -s "$pkg_src_cmd" "$pkg_dst_cmd"
25 }
26
27 # For installing from the extracted package tmp directory
28 function pkg_install() {
29     # remove the versioned folder, just in case it's there with junk
30     rm -rf "$pkg_src_bin"
31     mkdir -p "$pkg_src_bin"
32
33     # rename the entire extracted folder to the new location
34     # (this will be "$HOME/.local/opt/xmpl-v$WEBI_VERSION" by default)
35     mv ./"$pkg_cmd_name"* "$pkg_src_cmd"
36 }