refactor: finish moving ssh-* scripts to own installers
[webi-installers/.git] / git-config-gpg / install.sh
1 #!/bin/bash
2 set -e
3 set -u
4
5 function __install_git_gpg_init() {
6     MY_CMD="git-config-gpg"
7
8     rm -f "$HOME/.local/bin/$MY_CMD"
9     webi_download "$WEBI_HOST/packages/$MY_CMD/$MY_CMD.sh" "$HOME/.local/bin/$MY_CMD"
10     chmod a+x "$HOME/.local/bin/$MY_CMD"
11 }
12
13 function __check_gpg_pubkey_exists() {
14     if ! command -v gpg; then
15         webi gpg-pubkey
16         export PATH="$HOME/.local/opt/gnupg/bin:$PATH"
17         export PATH="$HOME/.local/opt/gnupg/bin/pinentry-mac.app/Contents/MacOS:$PATH"
18     fi
19 }
20
21 function __check_gpg_exists() {
22     if ! command -v gpg; then
23         webi gpg
24         export PATH="$HOME/.local/opt/gnupg/bin:$PATH"
25         export PATH="$HOME/.local/opt/gnupg/bin/pinentry-mac.app/Contents/MacOS:$PATH"
26     fi
27 }
28
29 __install_git_gpg_init
30 __check_gpg_pubkey_exists
31 __check_gpg_exists
32
33 # run the command
34 "$HOME/.local/bin/$MY_CMD"