mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-11 18:31:02 +01:00
clean
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
### 3.16 (06-07-2023)
|
||||
- Minor bugs fixed
|
||||
## 3.15
|
||||
- Apply github_tagfilter to dockerhub
|
||||
|
||||
## 3.10
|
||||
- Add dry run mode (test but does not commit)
|
||||
|
||||
## 3.9.9
|
||||
- Add mode
|
||||
- WARNING : update to supervisor 2022.11 before installing
|
||||
- Fix : dockerhub_list_size corrected
|
||||
- New dockerhub_list_size tag for dockerhub
|
||||
- Look for last 100 elements instead of 10
|
||||
- New dockerhub_by_date tag for dockerhub
|
||||
- Nightly tag only for beta
|
||||
- Use latest lastversion & base images
|
||||
- Feat: "pause: true" pauses the updates for a specific addon
|
||||
|
||||
## 3.*
|
||||
- Breaking change : new logic. Please read Readme.
|
||||
- Supports sources from : dockerhub/github,gitlab,bitbucket,pip,hg,sf,website-feed,local,helm_chart,wiki,system,wp
|
||||
|
||||
## 2.*
|
||||
- Add codenotary sign
|
||||
- Initial build
|
||||
110
test/Dockerfile
110
test/Dockerfile
@@ -1,110 +0,0 @@
|
||||
#============================#
|
||||
# ALEXBELGIUM'S DOCKERFILE #
|
||||
#============================#
|
||||
# _.------.
|
||||
# _.-` ('>.-`"""-.
|
||||
# '.--'` _'` _ .--.)
|
||||
# -' '-.-';` `
|
||||
# ' - _.' ``'--.
|
||||
# '---` .-'""`
|
||||
# /`
|
||||
#=== Home Assistant Addon ===#
|
||||
|
||||
#################
|
||||
# 1 Build Image #
|
||||
#################
|
||||
|
||||
ARG BUILD_FROM
|
||||
FROM $BUILD_FROM
|
||||
VOLUME [ "/data" ]
|
||||
|
||||
##################
|
||||
# 2 Modify Image #
|
||||
##################
|
||||
|
||||
# Set S6 wait time
|
||||
ENV S6_CMD_WAIT_FOR_SERVICES=1 \
|
||||
S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \
|
||||
S6_SERVICES_GRACETIME=0
|
||||
|
||||
|
||||
##################
|
||||
# 3 Install apps #
|
||||
##################
|
||||
|
||||
# Add rootfs
|
||||
COPY rootfs/ /
|
||||
|
||||
# Corrects permissions for s6 v3
|
||||
RUN if [ -d /etc/cont-init.d ]; then chmod -R 755 /etc/cont-init.d; fi && \
|
||||
if [ -d /etc/services.d ]; then chmod -R 755 /etc/services.d; fi && \
|
||||
if [ -f /entrypoint.sh ]; then chmod 755 /entrypoint.sh; fi
|
||||
|
||||
# Modules
|
||||
ARG MODULES="00-banner.sh 01-custom_script.sh"
|
||||
|
||||
# Automatic modules download
|
||||
RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
|
||||
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
|
||||
&& apt-get update && apt-get install -yqq --no-install-recommends ca-certificates || apk add --no-cache ca-certificates >/dev/null || true \
|
||||
&& mkdir -p /etc/cont-init.d \
|
||||
&& for scripts in $MODULES; do echo "$scripts" && curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/$scripts" -o /etc/cont-init.d/"$scripts" && [ "$(sed -n '/\/bin/p;q' /etc/cont-init.d/"$scripts")" != "" ] || (echo "script failed to install $scripts" && exit 1); done \
|
||||
&& chmod -R 755 /etc/cont-init.d
|
||||
|
||||
# Manual apps
|
||||
ENV PACKAGES=""
|
||||
|
||||
# Automatic apps & bashio
|
||||
# hadolint ignore=SC2015
|
||||
RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash) >/dev/null; fi \
|
||||
&& if ! command -v curl >/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends curl || apk add --no-cache curl) >/dev/null; fi \
|
||||
&& curl -f -L -s -S "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/automatic_packages.sh" --output /automatic_packages.sh \
|
||||
&& chmod 777 /automatic_packages.sh \
|
||||
&& eval /./automatic_packages.sh "${PACKAGES:-}" \
|
||||
&& rm /automatic_packages.sh
|
||||
|
||||
################
|
||||
# 4 Entrypoint #
|
||||
################
|
||||
|
||||
# Entrypoint logic
|
||||
RUN chmod 777 /entrypoint.sh
|
||||
#WORKDIR /
|
||||
ENTRYPOINT [ "/usr/bin/env" ]
|
||||
CMD [ "/entrypoint.sh" ]
|
||||
# Set shell
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
############
|
||||
# 5 Labels #
|
||||
############
|
||||
|
||||
ARG BUILD_ARCH
|
||||
ARG BUILD_DATE
|
||||
ARG BUILD_DESCRIPTION
|
||||
ARG BUILD_NAME
|
||||
ARG BUILD_REF
|
||||
ARG BUILD_REPOSITORY
|
||||
ARG BUILD_VERSION
|
||||
LABEL \
|
||||
io.hass.name="${BUILD_NAME}" \
|
||||
io.hass.description="${BUILD_DESCRIPTION}" \
|
||||
io.hass.arch="${BUILD_ARCH}" \
|
||||
io.hass.type="addon" \
|
||||
io.hass.version=${BUILD_VERSION} \
|
||||
maintainer="alexbelgium (https://github.com/alexbelgium)" \
|
||||
org.opencontainers.image.title="${BUILD_NAME}" \
|
||||
org.opencontainers.image.description="${BUILD_DESCRIPTION}" \
|
||||
org.opencontainers.image.vendor="Home Assistant Add-ons" \
|
||||
org.opencontainers.image.authors="alexbelgium (https://github.com/alexbelgium)" \
|
||||
org.opencontainers.image.licenses="MIT" \
|
||||
org.opencontainers.image.url="https://github.com/alexbelgium" \
|
||||
org.opencontainers.image.source="https://github.com/${BUILD_REPOSITORY}" \
|
||||
org.opencontainers.image.documentation="https://github.com/${BUILD_REPOSITORY}/blob/main/README.md" \
|
||||
org.opencontainers.image.created=${BUILD_DATE} \
|
||||
org.opencontainers.image.revision=${BUILD_REF} \
|
||||
org.opencontainers.image.version=${BUILD_VERSION}
|
||||
|
||||
####################
|
||||
# 6 HealthcheckNOT #
|
||||
####################
|
||||
@@ -1,87 +0,0 @@
|
||||
# Home assistant add-on: addons updater
|
||||
|
||||
[![Donate][donation-badge]](https://www.buymeacoffee.com/alexbelgium)
|
||||
|
||||

|
||||

|
||||

|
||||
|
||||
[](https://www.codacy.com/gh/alexbelgium/hassio-addons/dashboard?utm_source=github.com&utm_medium=referral&utm_content=alexbelgium/hassio-addons&utm_campaign=Badge_Grade)
|
||||
[](https://github.com/marketplace/actions/super-linter)
|
||||
[](https://github.com/alexbelgium/hassio-addons/actions/workflows/builder.yaml)
|
||||
|
||||
[donation-badge]: https://img.shields.io/badge/Buy%20me%20a%20coffee-%23d32f2f?logo=buy-me-a-coffee&style=flat&logoColor=white
|
||||
|
||||
_Thanks to everyone having starred my repo! To star it click on the image below, then it will be on top right. Thanks!_
|
||||
|
||||
[](https://github.com/alexbelgium/hassio-addons/stargazers)
|
||||
|
||||

|
||||
|
||||
## About
|
||||
|
||||
This script allows to automatically update addons based on upstream new releases. This is only an helper tool for developers. End users don’t need that to update their addons - they are automatically alerted by HA when an update is available
|
||||
|
||||
## Installation
|
||||
|
||||
The installation of this add-on is pretty straightforward and not different in
|
||||
comparison to installing any other Hass.io add-on.
|
||||
|
||||
1. [Add my Hass.io add-ons repository][repository] to your Hass.io instance.
|
||||
1. Install this add-on.
|
||||
1. Configure the add-on to your preferences, see below
|
||||
1. Click the `Save` button to store your configuration.
|
||||
1. Start the add-on.
|
||||
1. Check the logs of the add-on to see if everything went well.
|
||||
|
||||
## Configuration
|
||||
|
||||
No webUI. Configuration is set in 2 ways.
|
||||
|
||||
### Updater.json
|
||||
|
||||
In the addon folder of your repository (where is located you config.json), create a "updater.json" file.
|
||||
This file will be used by the addon to fetch the addon upstream informations.
|
||||
Only addons with an updater.json file will be updated.
|
||||
Here is [an example](https://github.com/alexbelgium/hassio-addons/blob/master/arpspoof/updater.json).
|
||||
|
||||
You can add the following tags in the file :
|
||||
|
||||
- fulltag: true is for example "v3.0.1-ls67" false is "3.0.1"
|
||||
- github_beta: true/false ; should it look only for releases or prereleases ok
|
||||
- github_havingasset : true if there is a requirement that a release has binaries and not just source
|
||||
- github_tagfilter: filter a text in the release name
|
||||
- last_update: automatically populated, date of last upstream update
|
||||
- repository: 'name/repo' coming from github
|
||||
- paused: true # Pauses the updates
|
||||
- slug: the slug name from your addon
|
||||
- source: dockerhub/github,gitlab,bitbucket,pip,hg,sf,website-feed,local,helm_chart,wiki,system,wp
|
||||
- upstream_repo: name/repo, example is 'linuxserver/docker-emby'
|
||||
- upstream_version: automatically populated, corresponds to the current upstream version referenced in the addon
|
||||
- dockerhub_by_date: in dockerhub, uses the last_update date instead of the version
|
||||
- dockerhub_list_size: in dockerhub, how many containers to consider for latest version
|
||||
|
||||
### Addon configuration
|
||||
|
||||
Here you define the values that will allow the addon to connect to your repository.
|
||||
|
||||
```yaml
|
||||
repository: 'name/repo' coming from github
|
||||
gituser: your github username
|
||||
gitpass: your github password
|
||||
gitmail: your github email
|
||||
verbose: 'false'
|
||||
gitapi: optional, it is the API key from your github repo
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```yaml
|
||||
repository: alexbelgium/hassio-addons
|
||||
gituser: your github username
|
||||
gitpass: your github password
|
||||
gitmail: your github email
|
||||
verbose: "false"
|
||||
```
|
||||
|
||||
[repository]: https://github.com/alexbelgium/hassio-addons
|
||||
@@ -1,58 +0,0 @@
|
||||
#include <tunables/global>
|
||||
|
||||
profile addon_updater flags=(attach_disconnected,mediate_deleted) {
|
||||
#include <abstractions/base>
|
||||
|
||||
# Capabilities
|
||||
file,
|
||||
signal,
|
||||
network udp,
|
||||
network tcp,
|
||||
network dgram,
|
||||
network stream,
|
||||
network inet,
|
||||
network inet6,
|
||||
network netlink raw,
|
||||
network unix dgram,
|
||||
|
||||
# S6-Overlay
|
||||
/init ix,
|
||||
/run/{s6,s6-rc*,service}/** ix,
|
||||
/package/** ix,
|
||||
/command/** ix,
|
||||
/run/{,**} rwk,
|
||||
/dev/tty rw,
|
||||
/init rix,
|
||||
/bin/** ix,
|
||||
/usr/bin/** ix,
|
||||
/etc/s6/** rix,
|
||||
/run/s6/** rwix,
|
||||
/etc/services.d/** rwix,
|
||||
/etc/cont-init.d/** rwix,
|
||||
/etc/cont-finish.d/** rwix,
|
||||
/run/** rwk,
|
||||
/dev/fuse mrwkl,
|
||||
/dev/sda1 mrwkl,
|
||||
/dev/sdb1 mrwkl,
|
||||
/dev/nvme0 mrwkl,
|
||||
/dev/nvme1 mrwkl,
|
||||
/dev/mmcblk0p1 mrwkl,
|
||||
|
||||
# bashio
|
||||
/usr/lib/bashio/** ix,
|
||||
/tmp/** rw,
|
||||
|
||||
# Access to Options.json and other files within your addon
|
||||
/data/** rw,
|
||||
|
||||
# Start new profile for service
|
||||
/usr/bin/myprogram cx,
|
||||
|
||||
profile usr/bin/myprogram flags=(attach_disconnected,mediate_deleted) {
|
||||
#include <abstractions/base>
|
||||
|
||||
# Receive signals from S6-Overlay
|
||||
signal receive,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"build_from": {
|
||||
"aarch64": "ghcr.io/hassio-addons/base-python/aarch64:stable"
|
||||
},
|
||||
"codenotary": {
|
||||
"signer": "alexandrep.github@gmail.com"
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"arch": [
|
||||
"aarch64"
|
||||
],
|
||||
"codenotary": "alexandrep.github@gmail.com",
|
||||
"description": "Do not use",
|
||||
"image": "ghcr.io/alexbelgium/test-{arch}",
|
||||
"name": "Do not use",
|
||||
"slug": "test",
|
||||
"startup": "once",
|
||||
"url": "https://github.com/alexbelgium/hassio-addons/tree/master/addons_updater",
|
||||
"version": "3.16"
|
||||
}
|
||||
BIN
test/icon.png
BIN
test/icon.png
Binary file not shown.
|
Before Width: | Height: | Size: 31 KiB |
BIN
test/logo.png
BIN
test/logo.png
Binary file not shown.
|
Before Width: | Height: | Size: 31 KiB |
@@ -1,16 +0,0 @@
|
||||
#!/bin/bash
|
||||
echo "Starting..."
|
||||
|
||||
####################
|
||||
# Starting scripts #
|
||||
####################
|
||||
|
||||
for SCRIPTS in /etc/cont-init.d/*; do
|
||||
[ -e "$SCRIPTS" ] || continue
|
||||
echo "$SCRIPTS: executing"
|
||||
chown "$(id -u)":"$(id -g)" "$SCRIPTS"
|
||||
chmod a+x "$SCRIPTS"
|
||||
# Change shebang if no s6 supervision
|
||||
sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' "$SCRIPTS"
|
||||
/."$SCRIPTS" || echo "$SCRIPTS: exiting $?"
|
||||
done
|
||||
@@ -1,253 +0,0 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
|
||||
##########
|
||||
# UPDATE #
|
||||
##########
|
||||
|
||||
bashio::log.info "Starting $(lastversion --version)"
|
||||
|
||||
if bashio::config.true "dry_run"; then
|
||||
bashio::log.warning "Dry run mode : on"
|
||||
fi
|
||||
|
||||
bashio::log.info "Checking status of referenced repositoriess..."
|
||||
VERBOSE=$(bashio::config 'verbose')
|
||||
|
||||
#Defining github value
|
||||
LOGINFO="... github authentification" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
|
||||
GITUSER=$(bashio::config 'gituser')
|
||||
GITPASS=$(bashio::config 'gitpass')
|
||||
GITMAIL=$(bashio::config 'gitmail')
|
||||
git config --system http.sslVerify false
|
||||
git config --system credential.helper 'cache --timeout 7200'
|
||||
git config --system user.name "${GITUSER}"
|
||||
git config --system user.password "${GITPASS}"
|
||||
if [[ "$GITMAIL" != "null" ]]; then git config --system user.email "${GITMAIL}"; fi
|
||||
|
||||
if bashio::config.has_value 'gitapi'; then
|
||||
LOGINFO="... setting github API" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
GITHUB_API_TOKEN=$(bashio::config 'gitapi')
|
||||
export GITHUB_API_TOKEN
|
||||
fi
|
||||
|
||||
#Create or update local version
|
||||
REPOSITORY=$(bashio::config 'repository')
|
||||
BASENAME=$(basename "https://github.com/$REPOSITORY")
|
||||
|
||||
if [ ! -d "/data/$BASENAME" ]; then
|
||||
LOGINFO="... cloning ${REPOSITORY}" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
cd /data/ || exit
|
||||
git clone "https://github.com/${REPOSITORY}"
|
||||
else
|
||||
LOGINFO="... updating ${REPOSITORY}" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
cd "/data/$BASENAME" || exit
|
||||
git pull --rebase origin >/dev/null || git reset --hard origin/master >/dev/null
|
||||
git pull --rebase origin >/dev/null
|
||||
fi
|
||||
|
||||
LOGINFO="... parse addons" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
|
||||
# Go through all folders, add to filters if not existing
|
||||
|
||||
cd /data/"$BASENAME" || exit
|
||||
for f in */; do
|
||||
|
||||
if [ -f /data/"$BASENAME"/"$f"/updater.json ]; then
|
||||
SLUG=${f//\/}
|
||||
|
||||
# Rebase
|
||||
LOGINFO="... updating ${REPOSITORY}" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
cd "/data/$BASENAME" || exit
|
||||
git pull --rebase &>/dev/null || git reset --hard &>/dev/null
|
||||
git pull --rebase &>/dev/null
|
||||
|
||||
#Define the folder addon
|
||||
LOGINFO="... $SLUG : checking slug exists in repo" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
cd /data/"${BASENAME}"/"${SLUG}" || { bashio::log.error "$SLUG addon not found in this repository. Exiting."; continue; }
|
||||
|
||||
# Get variables
|
||||
UPSTREAM=$(jq -r .upstream_repo updater.json)
|
||||
BETA=$(jq -r .github_beta updater.json)
|
||||
FULLTAG=$(jq -r .github_fulltag updater.json)
|
||||
HAVINGASSET=$(jq -r .github_havingasset updater.json)
|
||||
SOURCE=$(jq -r .source updater.json)
|
||||
FILTER_TEXT=$(jq -r .github_tagfilter updater.json)
|
||||
PAUSED=$(jq -r .paused updater.json)
|
||||
DATE="$(date '+%d-%m-%Y')"
|
||||
BYDATE=$(jq -r .dockerhub_by_date updater.json)
|
||||
|
||||
# Number of elements to check in dockerhub
|
||||
if grep -q "dockerhub_list_size" updater.json; then
|
||||
LISTSIZE=$(jq -r .dockerhub_list_size updater.json)
|
||||
else
|
||||
LISTSIZE=100
|
||||
fi
|
||||
|
||||
#Skip if paused
|
||||
if [[ "$PAUSED" = true ]]; then bashio::log.magenta "... $SLUG addon updates are paused, skipping"; continue; fi
|
||||
|
||||
#Find current version
|
||||
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; }
|
||||
|
||||
if [[ "$SOURCE" = dockerhub ]]; then
|
||||
# Use dockerhub as upstream
|
||||
# shellcheck disable=SC2116
|
||||
LOGINFO="... Source is dockerhub" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
|
||||
#Prepare tag flag
|
||||
if [ "${FILTER_TEXT}" = "null" ] || [ "${FILTER_TEXT}" = "" ]; then
|
||||
FILTER_TEXT=""
|
||||
else
|
||||
LOGINFO="... $SLUG : filter_text is on" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
FILTER_TEXT="&name=5.3"
|
||||
fi
|
||||
|
||||
DOCKERHUB_REPO="${UPSTREAM%%/*}"
|
||||
DOCKERHUB_IMAGE=$(echo "$UPSTREAM" | cut -d "/" -f2)
|
||||
LASTVERSION=$(
|
||||
curl -f -L -s --fail "https://hub.docker.com/v2/repositories/${DOCKERHUB_REPO}/${DOCKERHUB_IMAGE}/tags?page_size=$LISTSIZE$FILTER_TEXT" |
|
||||
jq '.results | .[] | .name' -r |
|
||||
sed -e '/.*latest.*/d' |
|
||||
sed -e '/.*dev.*/d' |
|
||||
sed -e '/.*nightly.*/d' |
|
||||
sort -V |
|
||||
tail -n 1
|
||||
)
|
||||
|
||||
[ "${BETA}" = true ] && \
|
||||
LASTVERSION=$(
|
||||
curl -f -L -s --fail "https://hub.docker.com/v2/repositories/${DOCKERHUB_REPO}/${DOCKERHUB_IMAGE}/tags?page_size=$LISTSIZE$FILTER_TEXT" |
|
||||
jq '.results | .[] | .name' -r |
|
||||
sed -e '/.*latest.*/d' |
|
||||
sed -e '/.*dev.*/!d' |
|
||||
sort -V |
|
||||
tail -n 1
|
||||
)
|
||||
|
||||
[ "${BYDATE}" = true ] && \
|
||||
LASTVERSION=$(curl -f -L -s --fail "https://hub.docker.com/v2/repositories/${DOCKERHUB_REPO}/${DOCKERHUB_IMAGE}/tags?page_size=${LISTSIZE}&ordering=last_updated$FILTER_TEXT" |
|
||||
jq '.results | .[] | .name' -r |
|
||||
sed -e '/.*latest.*/d' |
|
||||
sed -e '/.*dev.*/d' |
|
||||
sed -e '/.*nightly.*/d' |
|
||||
sort -V |
|
||||
tail -n 1
|
||||
) && \
|
||||
DATE=$(curl -f -L -s --fail "https://hub.docker.com/v2/repositories/${DOCKERHUB_REPO}/${DOCKERHUB_IMAGE}/tags/?page_size=${LISTSIZE}&ordering=last_updated$FILTER_TEXT" |
|
||||
jq '.results[] | select(.name==$LASTVERSION) | .last_updated' -r --arg LASTVERSION "$LASTVERSION"
|
||||
) && \
|
||||
DATE="${DATE%T*}" && \
|
||||
LASTVERSION="$LASTVERSION-$DATE"
|
||||
LOGINFO="... $SLUG : bydate is true, version is $LASTVERSION" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
|
||||
else
|
||||
|
||||
# Use source as upstream
|
||||
ARGUMENTS="--at $SOURCE"
|
||||
LOGINFO="... $SLUG : source is $SOURCE" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
|
||||
#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
|
||||
if [ "${HAVINGASSET}" = true ]; then
|
||||
LOGINFO="... $SLUG : asset_only tag is on" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
ARGUMENTS="$ARGUMENTS --having-asset"
|
||||
else
|
||||
LOGINFO="... $SLUG : asset_only is off" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
fi
|
||||
|
||||
#Prepare tag flag
|
||||
if [ "${FILTER_TEXT}" = "null" ] || [ "${FILTER_TEXT}" = "" ]; then
|
||||
FILTER_TEXT=""
|
||||
else
|
||||
LOGINFO="... $SLUG : filter_text is on" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
ARGUMENTS="$ARGUMENTS --only $FILTER_TEXT"
|
||||
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
|
||||
ARGUMENTS="$ARGUMENTS --pre"
|
||||
else
|
||||
LOGINFO="... $SLUG : beta is off" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
fi
|
||||
|
||||
#Execute version search
|
||||
# shellcheck disable=SC2086
|
||||
LASTVERSION=$(lastversion "$UPSTREAM" $ARGUMENTS) || continue
|
||||
fi
|
||||
|
||||
|
||||
# Add brackets
|
||||
LASTVERSION='"'${LASTVERSION}'"'
|
||||
|
||||
# Do not compare with ls tag for linuxserver images (to avoid updating only for dependencies)
|
||||
#LASTVERSION2=${LASTVERSION%-ls*}
|
||||
#CURRENT2=${CURRENT%-ls*}
|
||||
LASTVERSION2=${LASTVERSION}
|
||||
CURRENT2=${CURRENT}
|
||||
|
||||
# Update if needed
|
||||
if [ "${CURRENT2}" != "${LASTVERSION2}" ]; then
|
||||
LOGINFO="... $SLUG : update from ${CURRENT} to ${LASTVERSION}" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
|
||||
#Change all instances of version
|
||||
LOGINFO="... $SLUG : updating files" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
for files in "config.json" "config.yaml" "Dockerfile" "build.json" "build.yaml";do
|
||||
if [ -f /data/"${BASENAME}"/"${SLUG}"/$files ]; then
|
||||
sed -i "s/${CURRENT}/${LASTVERSION}/g" /data/"${BASENAME}"/"${SLUG}"/"$files"
|
||||
fi
|
||||
done
|
||||
|
||||
# Remove " and modify version
|
||||
LASTVERSION=${LASTVERSION//\"/}
|
||||
CURRENT=${CURRENT//\"/}
|
||||
jq --arg variable "$LASTVERSION" '.version = $variable' /data/"${BASENAME}"/"${SLUG}"/config.json | sponge /data/"${BASENAME}"/"${SLUG}"/config.json # Replace version tag
|
||||
jq --arg variable "$LASTVERSION" '.upstream_version = $variable' /data/"${BASENAME}"/"${SLUG}"/updater.json | sponge /data/"${BASENAME}"/"${SLUG}"/updater.json # Replace upstream tag
|
||||
jq --arg variable "$DATE" '.last_update = $variable' /data/"${BASENAME}"/"${SLUG}"/updater.json | sponge /data/"${BASENAME}"/"${SLUG}"/updater.json # Replace date tag
|
||||
|
||||
#Update changelog
|
||||
touch "/data/${BASENAME}/${SLUG}/CHANGELOG.md"
|
||||
sed -i "1i - Update to latest version from $UPSTREAM" "/data/${BASENAME}/${SLUG}/CHANGELOG.md"
|
||||
sed -i "1i ## ${LASTVERSION} (${DATE})" "/data/${BASENAME}/${SLUG}/CHANGELOG.md"
|
||||
sed -i "1i " "/data/${BASENAME}/${SLUG}/CHANGELOG.md"
|
||||
LOGINFO="... $SLUG : files updated" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
|
||||
#Git commit and push
|
||||
git add -A # add all modified files
|
||||
|
||||
git commit -m "Updater bot : $SLUG updated to ${LASTVERSION}" >/dev/null
|
||||
|
||||
LOGINFO="... $SLUG : push to github" && if [ "$VERBOSE" = true ]; then bashio::log.info "$LOGINFO"; fi
|
||||
|
||||
# if API is set
|
||||
if bashio::config.has_value 'gitapi'; then
|
||||
git remote set-url origin "https://${GITUSER}:${GITHUB_API_TOKEN}@github.com/${REPOSITORY}" &>/dev/null
|
||||
else
|
||||
git remote set-url origin "https://${GITUSER}:${GITPASS}@github.com/${REPOSITORY}" &>/dev/null
|
||||
fi
|
||||
|
||||
# Push
|
||||
if ! bashio::config.true "dry_run"; then
|
||||
git push &>/dev/null
|
||||
fi
|
||||
|
||||
#Log
|
||||
bashio::log.yellow "... $SLUG updated from ${CURRENT} to ${LASTVERSION}"
|
||||
|
||||
else
|
||||
bashio::log.green "... $SLUG is up-to-date ${CURRENT}"
|
||||
fi
|
||||
fi
|
||||
done || true # Continue even if issue
|
||||
|
||||
bashio::log.info "Addons update completed"
|
||||
BIN
test/stats.png
BIN
test/stats.png
Binary file not shown.
|
Before Width: | Height: | Size: 1.7 KiB |
Reference in New Issue
Block a user