From 5805ab86c04b56039366b1856e437437427ee3fe Mon Sep 17 00:00:00 2001 From: Michael Parker Date: Sun, 29 Dec 2019 17:54:25 -0500 Subject: [PATCH] update scripts folder Change steamcmd recommended to debian-buster-slim Update release grabber with curly braces on variables (readability). Add script for validating that download links actually exist with no errors. update gitignore. --- .gitignore | 2 +- scripts/download_link_validator.sh | 11 +++++++++++ scripts/github_release_grabber.sh | 21 ++++++++++----------- scripts/steamcmd_installer.sh | 2 +- 4 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 scripts/download_link_validator.sh diff --git a/.gitignore b/.gitignore index 378f0ca5..615b2764 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ *.DS_Store node_modules/ -.vuepress/ \ No newline at end of file +.vuepress/* \ No newline at end of file diff --git a/scripts/download_link_validator.sh b/scripts/download_link_validator.sh new file mode 100644 index 00000000..10a6d69a --- /dev/null +++ b/scripts/download_link_validator.sh @@ -0,0 +1,11 @@ +## this is a simple script to validate a download url actaully exists + +if [ ! -z "${DOWNLOAD_URL}"]; then + if curl --output /dev/null --silent --head --fail ${DOWNLOAD_URL}; then + echo -e "link is valid. setting download link to ${DOWNLOAD_URL}" + DOWNLOAD_LINK=${DOWNLOAD_URL} + else + echo -e "link is invalid closing out" + exit 2 + fi +fi \ No newline at end of file diff --git a/scripts/github_release_grabber.sh b/scripts/github_release_grabber.sh index d05120c8..14d4e70e 100644 --- a/scripts/github_release_grabber.sh +++ b/scripts/github_release_grabber.sh @@ -3,26 +3,25 @@ ## this supports using oauth/personal access tokens via GITHUB_USER and GITHUB_OAUTH_TOKEN (both are required.) ## if you are getting hit with GitHub API limit issues then you need to have the user and token set. - -if [ -z "$GITHUB_USER" ] && [ -z "$GITHUB_OAUTH_TOKEN" ] ; then +if [ -z "${GITHUB_USER}" ] && [ -z "${GITHUB_OAUTH_TOKEN}" ] ; then echo -e "using anon api call" else echo -e "user and oauth token set" - alias curl='curl -u $GITHUB_USER:$GITHUB_OAUTH_TOKEN ' + alias curl='curl -u ${GITHUB_USER}:${GITHUB_OAUTH_TOKEN} ' fi ## get release info and download links -LATEST_JSON=$(curl --silent "https://api.github.com/repos/$GITHUB_PACKAGE/releases/latest") -RELEASES=$(curl --silent "https://api.github.com/repos/$GITHUB_PACKAGE/releases") +LATEST_JSON=$(curl --silent "https://api.github.com/repos/${GITHUB_PACKAGE}/releases/latest") +RELEASES=$(curl --silent "https://api.github.com/repos/${GITHUB_PACKAGE}/releases") -if [ -z "$VERSION" ] || [ "$VERSION" == "latest" ]; then - DOWNLOAD_LINK=$(echo $LATEST_JSON | jq .assets | jq -r .[].browser_download_url | grep -i ${MATCH}) +if [ -z "${VERSION}" ] || [ "${VERSION}" == "latest" ]; then + DOWNLOAD_LINK=$(echo ${LATEST_JSON} | jq .assets | jq -r .[].browser_download_url | grep -i ${MATCH}) else - VERSION_CHECK=$(echo $RELEASES | jq -r --arg VERSION "$VERSION" '.[] | select(.tag_name==$VERSION) | .tag_name') - if [ "$VERSION" == "$VERSION_CHECK" ]; then - DOWNLOAD_LINK=$(echo $RELEASES | jq -r --arg VERSION "$VERSION" '.[] | select(.tag_name==$VERSION) | .assets[].browser_download_url' | grep -i ${MATCH}) + VERSION_CHECK=$(echo ${RELEASES} | jq -r --arg VERSION "${VERSION}" '.[] | select(.tag_name==$VERSION) | .tag_name') + if [ "${VERSION}" == "${VERSION_CHECK}" ]; then + DOWNLOAD_LINK=$(echo ${RELEASES} | jq -r --arg VERSION "${VERSION}" '.[] | select(.tag_name==$VERSION) | .assets[].browser_download_url' | grep -i ${MATCH}) else echo -e "defaulting to latest release" - DOWNLOAD_LINK=$(echo $LATEST_JSON | jq .assets | jq -r .[].browser_download_url) + DOWNLOAD_LINK=$(echo ${LATEST_JSON} | jq .assets | jq -r .[].browser_download_url) fi fi \ No newline at end of file diff --git a/scripts/steamcmd_installer.sh b/scripts/steamcmd_installer.sh index eba1d2c2..c36fa040 100644 --- a/scripts/steamcmd_installer.sh +++ b/scripts/steamcmd_installer.sh @@ -2,7 +2,7 @@ # steamcmd Base Installation Script # # Server Files: /mnt/server -# Image to install with is 'ubuntu:18.04' +# Image to install with is 'debian:buster-slim' apt -y update apt -y --no-install-recommends install curl lib32gcc1 ca-certificates