Created
August 1, 2023 17:46
-
-
Save jwmann/3352799f33e69863a27da9992ed24c28 to your computer and use it in GitHub Desktop.
Automatically download latest ExifTool and add it to the PATH on DSM
This file contains 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
#!/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