Created
March 28, 2019 09:23
-
-
Save iiidefix/bb0d56d6fa652423f0ad3411e475ee35 to your computer and use it in GitHub Desktop.
script to update gitea
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
v=$(wget -qO- https://api.github.com/repos/go-gitea/gitea/releases/latest | jq --raw-output '.tag_name') | |
readonly VER="${v#v}" | |
readonly BIN="gitea-${VER}-linux-amd64" | |
readonly SIG="${BIN}.asc" | |
readonly URL="https://dl.gitea.io/gitea/${VER}/" | |
verify_signature() { | |
local file=$1 sig=$2 out= | |
if out=$(gpg --status-fd 1 --verify "$sig" "$file" 2>/dev/null) && | |
echo "$out" | grep -qs "^\[GNUPG:\] GOODSIG 5FC346329753F4B0 Teabot <[email protected]>" && | |
echo "$out" | grep -qs "^\[GNUPG:\] VALIDSIG "; then | |
return 0 | |
else | |
echo "$out" >&2 | |
return 1 | |
fi | |
} | |
[[ -f "${BIN}" ]] && { | |
echo "${BIN} is already there" | |
exit 1 | |
} | |
wget -q --show-progress "${URL}${BIN}" | |
wget -q --show-progress "${URL}${SIG}" | |
verify_signature "${BIN}" "${SIG}" \ | |
&& echo "sig ok" \ | |
|| { | |
echo "sig err" | |
exit 1 | |
} | |
rm "${SIG}" | |
chown gitea:gitea "${BIN}" | |
chmod +x "${BIN}" | |
[[ -L gitea ]] \ | |
&& rm gitea | |
ln -s "${BIN}" gitea | |
service gitea restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment