You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.0 KiB
Plaintext
49 lines
1.0 KiB
Plaintext
4 years ago
|
#!/usr/bin/env bash
|
||
|
|
||
2 years ago
|
set -euo pipefail
|
||
4 years ago
|
|
||
2 years ago
|
# shellcheck disable=SC1091
|
||
|
source "${XDG_DATA_HOME}/buddy-up/includes/utils.sh"
|
||
4 years ago
|
|
||
|
APP=gitea
|
||
2 years ago
|
DEST=/usr/local/apps/${APP}
|
||
|
CURRENT=${DEST}/current
|
||
2 years ago
|
VERSION=${VERSION:-1.19.0}
|
||
4 years ago
|
BIN_DIR=/usr/local/bin
|
||
|
|
||
2 years ago
|
main() (
|
||
|
URL=https://dl.gitea.io/gitea/${VERSION}/gitea-${VERSION}-$(get_os)-$(get_arch).xz
|
||
|
|
||
|
if [ ! -d "${DEST}/${VERSION}" ]; then
|
||
|
tmp_dir="$(mktemp -d)"
|
||
|
file=${tmp_dir}/gitea
|
||
|
curl --silent --retry 10 --location --output "${file}.xz" "${URL}"
|
||
|
xz --decompress "${file}.xz"
|
||
|
chmod 755 "${file}"
|
||
|
sudo chown root:root "${file}"
|
||
|
sudo mkdir -p "${DEST}/${VERSION}"
|
||
|
sudo mv "${file}" "${DEST}/${VERSION}/${APP}"
|
||
|
|
||
|
rm -rf "${tmp_dir}"
|
||
|
fi
|
||
|
set_current_link "${DEST}" "${VERSION}" "sudo"
|
||
|
|
||
|
unlink_if_set "${BIN_DIR}/${APP}" "sudo"
|
||
|
cd "${BIN_DIR}" || exit 1
|
||
|
sudo ln -s "$(relative_path "${BIN_DIR}" "${CURRENT}/${APP}")" "${APP}"
|
||
|
cd - &>/dev/null || exit 1
|
||
|
)
|
||
|
|
||
|
get_os() (
|
||
|
case $(uname -s) in
|
||
|
Linux*) echo linux ;;
|
||
|
Darwin*) echo darwin-10.12 ;;
|
||
|
*)
|
||
|
echo >&2 "unsupported os: $(uname -s)"
|
||
|
exit 1
|
||
|
;;
|
||
|
esac
|
||
|
)
|
||
|
|
||
|
main "${@}"
|