add xz support, add gitea
[webi-installers/.git] / gitea / install.bash
1 # title: Gitea
2 # homepage: https://github.com/go-gitea/gitea
3 # tagline: a modern drop-in grep replacement
4 # description: |
5 #   `gitea` is a clean, lightweight self-hosted Github alternative, forked from Gogs. Lighter and more user-friendly than Gitlab.
6 # examples: |
7 #
8 #   ```bash
9 #   gitea --version
10 #   ```
11
12 set -e
13 set -u
14
15 ###################
16 # Install gitea #
17 ###################
18
19 new_gitea="${HOME}/.local/bin/gitea"
20
21 # Test for existing version
22 set +e
23 cur_gitea="$(command -v gitea)"
24 set -e
25 if [ -n "$cur_gitea" ]; then
26   cur_ver=$(gitea --version | head -n 1 | cut -d ' ' -f 3)
27   if [ "$cur_ver" == "$WEBI_VERSION" ]; then
28     echo "gitea v$WEBI_VERSION already installed at $cur_gitea"
29     exit 0
30   elif [ "$cur_gitea" != "$new_gitea" ]; then
31     echo "WARN: possible conflict with gitea v$WEBI_VERSION at $cur_gitea"
32   fi
33 fi
34
35 # Note: this file is `source`d by the true installer and hence will have the webi functions
36
37 # because we created releases.js we can use webi_download()
38 # downloads gitea to ~/Downloads
39 webi_download
40
41 # because this is tar or zip, we can webi_extract()
42 # extracts to the WEBI_TMP directory, raw (no --strip-prefix)
43 webi_extract
44
45 pushd "$WEBI_TMP" 2>&1 >/dev/null
46         echo Installing gitea v${WEBI_VERSION} as "$new_gitea"
47         mv ./gitea-* "$HOME/.local/bin/gitea"
48         chmod a+x "$HOME/.local/bin/gitea"
49 popd 2>&1 >/dev/null
50
51 ###################
52 #   Update PATH   #
53 ###################
54
55 # TODO get better output from pathman / output the path to add as return to webi bootstrap
56 webi_path_add "$HOME/.local/bin"
57
58 echo "Installed 'gitea'"
59 echo ""