Skip to content

Instantly share code, notes, and snippets.

@jwmann
Created August 1, 2023 17:46
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 jwmann/3352799f33e69863a27da9992ed24c28 to your computer and use it in GitHub Desktop.
Save jwmann/3352799f33e69863a27da9992ed24c28 to your computer and use it in GitHub Desktop.
Automatically download latest ExifTool and add it to the PATH on DSM
#!/bin/bash
# Function to get the latest version from the ExifTool website
get_latest_version() {
local latest_version=$(curl -s "https://exiftool.org/history.html" | grep -m 1 -oP "<a name='v\K[.0-9]+?(?='>)")
echo "$latest_version"
}
# Get the latest version
LATEST_VERSION=$(get_latest_version)
if [ -z "$LATEST_VERSION" ]; then
echo "Error: Failed to get the latest version of ExifTool."
exit 1
fi
# Set the URL for the latest version of ExifTool
EXIFTOOL_URL="https://exiftool.org/Image-ExifTool-$LATEST_VERSION.tar.gz"
# Set the filename for the downloaded tar.gz file
IMAGE_NAME="Image-ExifTool-$LATEST_VERSION"
TAR_FILENAME="$IMAGE_NAME.tar.gz"
SHARE_PATH="/usr/share/applications"
# Download the latest version of ExifTool
echo "Downloading the latest version $LATEST_VERSION of ExifTool..."
wget "$EXIFTOOL_URL" -O "$TAR_FILENAME"
# Check if the download was successful
if [ $? -eq 0 ]; then
echo "Download completed successfully."
# Extract the tar.gz file
echo "Extracting the contents of $TAR_FILENAME..."
tar -xzf "$TAR_FILENAME"
# Clean up the downloaded tar.gz file
rm "$TAR_FILENAME"
mv $IMAGE_NAME ExifTool
mkdir -p "$SHARE_PATH"
mv ./ExifTool "$SHARE_PATH"
echo "export PATH=\$PATH:$SHARE_PATH/ExifTool" >> /etc/profile
echo "ExifTool $LATEST_VERSION has been downloaded and extracted to the $SHARE_PATH directory and added to the \$PATH."
else
echo "Error: Failed to download ExifTool."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment