Created
May 12, 2025 07:55
-
-
Save anoduck/e550043126876f2c7db0df2fb8588fae to your computer and use it in GitHub Desktop.
update godns: Script to check if godns version is the same as the newest release, if not, then download and install the release.
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
#!/usr/bin/env bash | |
function upgrade_godns() { | |
PROFILE="TimothyYe" | |
PROJECT="godns" | |
OUTFILE="godns.tar.gz" | |
ENDFILE="godns" | |
VERSION=$(curl -s "https://api.github.com/repos/$PROFILE/$PROJECT/releases/latest" | \grep -Po '"tag_name": *"v\K[^"]*') | |
GDNSVERS=$(godns -h 2>/dev/null) | |
LOVERS=$(echo "$GDNSVERS" | grep GoDNS | cut -d ' ' -f 2 | cut -c 2-) | |
if [[ "$VERSION" != "$LOVERS" ]]; then | |
DFILE="${PROJECT}_${VERSION}_linux_amd64.tar.gz" | |
TMPDIR=$(mktemp -d) | |
cd "$TMPDIR" || exit | |
curl -Lo "$OUTFILE" "https://github.com/$PROFILE/$PROJECT/releases/download/v$VERSION/$DFILE" | |
tar xf $OUTFILE $ENDFILE | |
sudo install $ENDFILE -D -t /usr/local/bin/ | |
else | |
echo "GoDNS versions are the same." | |
fi | |
} | |
upgrade_godns |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment