mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-17 06:11:49 +02:00
Allow multiple sources
This commit is contained in:
@@ -76,69 +76,70 @@ if [ -f /data/"$BASENAME"/"$f"/updater.json ]; then
|
|||||||
LOGINFO="... $SLUG : get current version" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
LOGINFO="... $SLUG : get current version" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||||
CURRENT=$(jq .upstream_version updater.json) || { bashio::log.error "$SLUG addon upstream tag not found in updater.json. Exiting."; continue; }
|
CURRENT=$(jq .upstream_version updater.json) || { bashio::log.error "$SLUG addon upstream tag not found in updater.json. Exiting."; continue; }
|
||||||
|
|
||||||
if [ "$SOURCE" = "dockerhub" ]; then
|
if [[ "$SOURCE" = dockerhub ]]; then
|
||||||
# Use dockerhub as upstream
|
# Use dockerhub as upstream
|
||||||
# shellcheck disable=SC2116
|
# shellcheck disable=SC2116
|
||||||
DOCKERHUB_REPO=$(echo "${UPSTREAM%%/*}")
|
DOCKERHUB_REPO=$(echo "${UPSTREAM%%/*}")
|
||||||
DOCKERHUB_IMAGE=$(echo "$UPSTREAM" | cut -d "/" -f2)
|
DOCKERHUB_IMAGE=$(echo "$UPSTREAM" | cut -d "/" -f2)
|
||||||
LASTVERSION=$(
|
LASTVERSION=$(
|
||||||
curl -f -L -s --fail "https://hub.docker.com/v2/repositories/${DOCKERHUB_REPO}/${DOCKERHUB_IMAGE}/tags/?page_size=10" |
|
curl -f -L -s --fail "https://hub.docker.com/v2/repositories/${DOCKERHUB_REPO}/${DOCKERHUB_IMAGE}/tags/?page_size=10" |
|
||||||
jq '.results | .[] | .name' -r |
|
jq '.results | .[] | .name' -r |
|
||||||
sed -e '/.*latest.*/d' |
|
sed -e '/.*latest.*/d' |
|
||||||
sed -e '/.*dev.*/d' |
|
sed -e '/.*dev.*/d' |
|
||||||
sort -V |
|
sort -V |
|
||||||
tail -n 1
|
tail -n 1
|
||||||
)
|
)
|
||||||
[ "${BETA}" = true ] &&
|
[ "${BETA}" = true ] &&
|
||||||
LASTVERSION=$(
|
LASTVERSION=$(
|
||||||
curl -f -L -s --fail "https://hub.docker.com/v2/repositories/${DOCKERHUB_REPO}/${DOCKERHUB_IMAGE}/tags/?page_size=10" |
|
curl -f -L -s --fail "https://hub.docker.com/v2/repositories/${DOCKERHUB_REPO}/${DOCKERHUB_IMAGE}/tags/?page_size=10" |
|
||||||
jq '.results | .[] | .name' -r |
|
jq '.results | .[] | .name' -r |
|
||||||
sed -e '/.*latest.*/d' |
|
sed -e '/.*latest.*/d' |
|
||||||
sed -e '/.*dev.*/!d' |
|
sed -e '/.*dev.*/!d' |
|
||||||
sort -V |
|
sort -V |
|
||||||
tail -n 1
|
tail -n 1
|
||||||
)
|
)
|
||||||
|
|
||||||
else
|
else
|
||||||
# Use github as upstream
|
|
||||||
ARGUMENTS=""
|
|
||||||
#Prepare tag flag
|
|
||||||
if [ "${FULLTAG}" = true ]; then
|
|
||||||
LOGINFO="... $SLUG : fulltag is on" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
|
||||||
ARGUMENTS="$ARGUMENTS --format tag"
|
|
||||||
else
|
|
||||||
LOGINFO="... $SLUG : fulltag is off" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#Prepare tag flag
|
# Use source as upstream
|
||||||
if [ "${HAVINGASSET}" = true ]; then
|
ARGUMENTS="--at $SOURCE"
|
||||||
LOGINFO="... $SLUG : asset_only tag is on" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
|
||||||
ARGUMENTS="$ARGUMENTS --having-asset"
|
#Prepare tag flag
|
||||||
else
|
if [ "${FULLTAG}" = true ]; then
|
||||||
LOGINFO="... $SLUG : asset_only is off" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
LOGINFO="... $SLUG : fulltag is on" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||||
fi
|
ARGUMENTS="$ARGUMENTS --format tag"
|
||||||
|
else
|
||||||
|
LOGINFO="... $SLUG : fulltag is off" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||||
|
fi
|
||||||
|
|
||||||
#Prepare tag flag
|
#Prepare tag flag
|
||||||
if [ "${FILTER_TEXT}" = "null" ] || [ "${FILTER_TEXT}" = "" ]; then
|
if [ "${HAVINGASSET}" = true ]; then
|
||||||
FILTER_TEXT=""
|
LOGINFO="... $SLUG : asset_only tag is on" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||||
else
|
ARGUMENTS="$ARGUMENTS --having-asset"
|
||||||
LOGINFO="... $SLUG : filter_text is on" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
else
|
||||||
ARGUMENTS="$ARGUMENTS --only $FILTER_TEXT"
|
LOGINFO="... $SLUG : asset_only is off" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#If beta flag, select beta version
|
#Prepare tag flag
|
||||||
if [ "${BETA}" = true ]; then
|
if [ "${FILTER_TEXT}" = "null" ] || [ "${FILTER_TEXT}" = "" ]; then
|
||||||
LOGINFO="... $SLUG : beta is on" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
FILTER_TEXT=""
|
||||||
# shellcheck disable=SC2086
|
else
|
||||||
LASTVERSION=$(lastversion --pre "https://github.com/$UPSTREAM" $ARGUMENTS) || continue
|
LOGINFO="... $SLUG : filter_text is on" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||||
else
|
ARGUMENTS="$ARGUMENTS --only $FILTER_TEXT"
|
||||||
LOGINFO="... $SLUG : beta is off" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
fi
|
||||||
# shellcheck disable=SC2086
|
|
||||||
LASTVERSION=$(lastversion "https://github.com/$UPSTREAM" $ARGUMENTS) || continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
#If beta flag, select beta version
|
||||||
|
if [ "${BETA}" = true ]; then
|
||||||
|
LOGINFO="... $SLUG : beta is on" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
LASTVERSION=$(lastversion --pre "$UPSTREAM" $ARGUMENTS) || continue
|
||||||
|
else
|
||||||
|
LOGINFO="... $SLUG : beta is off" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
LASTVERSION=$(lastversion "$UPSTREAM" $ARGUMENTS) || continue
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# Add brackets
|
# Add brackets
|
||||||
LASTVERSION='"'${LASTVERSION}'"'
|
LASTVERSION='"'${LASTVERSION}'"'
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user