Skip to content

Instantly share code, notes, and snippets.

@iiidefix
Created March 28, 2019 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iiidefix/bb0d56d6fa652423f0ad3411e475ee35 to your computer and use it in GitHub Desktop.
Save iiidefix/bb0d56d6fa652423f0ad3411e475ee35 to your computer and use it in GitHub Desktop.
script to update gitea
#!/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 <teabot@gitea.io>" &&
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