updated to only run if version doesn't match

This commit is contained in:
2023-01-01 18:57:40 -05:00
parent a54bb216b7
commit ef5f6eea1a

View File

@@ -1,16 +1,22 @@
#!/bin/sh
# CyberChef web directory
CYBERCHEF_DIRECTORY="/var/www/public/cyberchef"
# download srouce code of latest releases page
HTML_SOURCE=$(wget -O - https://api.github.com/repos/gchq/CyberChef/releases/latest)
# version
VERSION=$(echo ${HTML_SOURCE} | jq -r .tag_name)
# get download url
DOWNLOAD_URL=$(echo ${HTML_SOURCE} | jq -r .assets[].browser_download_url)
# get filename
FILENAME=$(echo ${HTML_SOURCE} | jq -r .assets[].name)
# test if version is already downloaded
if [ $(ls ${CYBERCHEF_DIRECTORY}/*${VERSION}* | wc -l) -gt 0 ]; then
echo "Version is already downloaded"
exit
fi
# download file
wget -P ${CYBERCHEF_DIRECTORY} ${DOWNLOAD_URL}