Skip to content

Instantly share code, notes, and snippets.

@jostyee
Created August 17, 2021 03:48
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 jostyee/6fa2b7caaaa3454c607fc61f7192f04f to your computer and use it in GitHub Desktop.
Save jostyee/6fa2b7caaaa3454c607fc61f7192f04f to your computer and use it in GitHub Desktop.
#!/bin/sh
INSTALL_DIR="/etc/dnscrypt-proxy"
LATEST_URL="https://api.github.com/repos/jedisct1/dnscrypt-proxy/releases/latest"
Update() {
workdir="$(mktemp -d)"
curl -sL $(curl -sL "$LATEST_URL" |
grep dnscrypt-proxy-linux_arm64- | grep browser_download_url | head -1 | cut -d \" -f 4) |
tar xz -C "$workdir" -f - linux-arm64/dnscrypt-proxy &&
[ -x linux-arm64/dnscrypt-proxy ] &&
mv -f "${INSTALL_DIR}/dnscrypt-proxy" "${INSTALL_DIR}/dnscrypt-proxy.old" || : &&
mv -f "${workdir}/linux-arm64/dnscrypt-proxy" "${INSTALL_DIR}/" &&
cd "$INSTALL_DIR" && rm -fr "$workdir" &&
./dnscrypt-proxy -check && ./dnscrypt-proxy -service install 2>/dev/null || : &&
./dnscrypt-proxy -service restart || ./dnscrypt-proxy -service start
}
lversion=$("${INSTALL_DIR}/dnscrypt-proxy" -version)
rmersion=$(curl -sL "$LATEST_URL" | grep "tag_name" | head -1 | cut -d \" -f 4)
[ -z "$lversion" ] && exit 1
[ -z "$rmersion" ] && exit 1
echo locally installed
echo "$lversion"
echo remote git version
echo "$rmersion"
if [ "$rmersion" != "$lversion" ]; then
echo "Updating" && Update
else
echo "No Update Needed"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment