Manually checking for software updates is cumbersome, so here is another little script to check for a software update for Frigate, which runs inside a Docker Container.
Create Script
Create a file using your text editor, I use nano editor. Be sure to edit to match your setup in the Edit Area.
touch frigate_check nano -w frigate_check
#!/bin/bash
######################
## EDIT AREA ##
######################
# Optional: include [ test ] with call to script, i.e. ./frigate_check test
# Else Force Test API and return values only (0=TRUE;1=FALSE)
API_TEST=1
# Frigate IP and PORT
IPADDR="192.168.1.5"
IPPORT="5000"
# Frigate docker file location (docker-compose.yml)
FRIGATE_DOCKER="/srv/docker/Frigate"
# CURL timeout [seconds]
CURL_TIMEOUT=10
# Frigate REPO to Check
FRIGATE_REPO="blakeblackshear/frigate/releases/latest"
# Github API REPO
FRIGATE_GITHUB_API="https://api.github.com/repos/$FRIGATE_REPO"
# Frigate LOCAL to Check
FRIGATE_LOCAL_API="http://$IPADDR:$IPPORT/api/version"
######################
## EDIT END ##
######################
# Check cURL command if available (required), abort if does not exists
type curl >/dev/null 2>&1 || { echo -e >&2 "Requires 'curl' but it's not installed. Install with:\nsudo apt install curl\nAborting..."; exit 1; }
# Check jq command if available (required), abort if not installed
type jq >/dev/null 2>&1 || { echo -e >&2 "Requires 'jq' but it's not installed. Install with:\nsudo apt install jq\nAborting..."; exit 1; }
if [ -n "$1" ] && [ "$1" != "test" ]; then
{ echo -e >&2 "Unknown command '$1'\nAborting..."; exit 1; }
elif [ "$1" == "test" ]; then
echo
echo "-*- Testing API and Return Value -*-"
else
echo -n "Checking if there is an newer version of Frigate"
fi
while (( i++ < 4 )); do
echo -n " ."
sleep 1
done
echo
CURRENT_CONNECT=$(curl --connect-timeout $CURL_TIMEOUT --head --write-out "%{http_code}" --output /dev/null --silent "$FRIGATE_GITHUB_API" )
INSTALL_CONNECT=$(curl --connect-timeout $CURL_TIMEOUT --head --write-out "%{http_code}" --output /dev/null --silent "$FRIGATE_LOCAL_API" )
if [[ "$CURRENT_CONNECT" -ne 200 ]]; then
CURRENT="API unreachable, current version unavailable"
else
#CURRENT=$(curl --connect-timeout $CURL_TIMEOUT --silent --request GET "$FRIGATE_GITHUB_API" -H "Accept: application/json" | jq ".name" -r)
CURRENT=$(curl --silent --request GET "$FRIGATE_GITHUB_API" -H "Accept: application/json" | jq ".name" -r)
CURRENT_VERSION=$(echo "$CURRENT" | sed -n "s/[^0-9]\+\([0-9.]\+\).*/\1/p" | sed -e "s/^[[:space:]]*$//")
fi
if [[ "$INSTALL_CONNECT" -ne 200 ]]; then
INSTALL="API unreachable, installed version unavailable"
else
#INSTALL=$(curl --connect-timeout $CURL_TIMEOUT --silent --request GET "$FRIGATE_LOCAL_API")
INSTALL=$(curl --silent --request GET "$FRIGATE_LOCAL_API")
INSTALL_VERSION=$(echo "$INSTALL" | cut -d"-" -f 1 | sed -n "s/[^0-9]\+\([0-9.]\+\).*/\0/p" | sed -e "s/^[[:space:]]*$//")
fi
## TEST cURL API RETURN VALUE ##
if [[ $API_TEST -eq 0 ]] || [ "$1" == "test" ]; then
echo "CURRENT $CURRENT"
echo "INSTALL $INSTALL"
echo "*/* ## *//* ## */*"
echo "Current: $CURRENT_VERSION"
echo "Installed: $INSTALL_VERSION"
echo "*/* ## *//* ## */*"
echo "-*- Change API_TEST to quit test -*-"
echo
else
if [[ -z "$CURRENT_VERSION" ]] && [[ "$INSTALL_VERSION" ]]; then
echo "$CURRENT"
echo "Installed local version: $INSTALL_VERSION"
echo "Unable to determine if update is available"
elif [[ -z "$INSTALL_VERSION" ]] && [[ "$CURRENT_VERSION" ]]; then
echo "Current available version: $CURRENT_VERSION"
echo "$INSTALL"
echo "Unable to determine if update available"
elif [[ "$CURRENT_VERSION" ]] && [[ "$INSTALL_VERSION" ]]; then
if [ "$CURRENT_VERSION" != "$INSTALL_VERSION" ]; then
echo "There is a newer version of Frigate available"
echo "Update to Version: $CURRENT_VERSION"
echo "Installed Version: $INSTALL_VERSION"
read -p "Would you like to update now?(Y/n)" -n 1 -r UPDATE
update=${UPDATE,,}
if [[ "$update" =~ ^(y| ) ]] || [[ -z "$update" ]]; then
cd "$FRIGATE_DOCKER" || { echo -e >&2 "Unable to find Frigate docker file\nAborting..."; exit 1; }
docker compose pull
docker compose up -d --remove-orphans
else
echo
echo "Frigate not updated at this time"
echo "Frigate Running $INSTALL_VERSION"
fi
else
echo "Current available version: $CURRENT_VERSION"
echo "Installed local version: $INSTALL_VERSION"
echo "The most recent version of Frigate is installed ($INSTALL_VERSION)"
fi
else
echo "$CURRENT"
echo "$INSTALL"
echo "Try again later"
fi
fi
Save the file. Example in nano: ctrl+o
and ctrl+x
Then switch to a root shell to move the script file, set permissions, and set owner. Be sure to use your own location; I save mine in the docker folder for convenience.
sudo -s
mv frigate_check /srv/docker/
chmod +x /srv/docker/frigate_check
chmod 0750 /srv/docker/frigate_check
chown root:root /srv/docker/frigate_check
You can run manually or use cron to set a schedule to check automatically.