mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-30 04:14:04 +02:00
Initial version of the automatic addon updater
This commit is contained in:
16
addons_updater/Dockerfile
Normal file
16
addons_updater/Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
ARG BUILD_FROM
|
||||||
|
FROM $BUILD_FROM
|
||||||
|
|
||||||
|
VOLUME [ "/data" ]
|
||||||
|
|
||||||
|
#Install last version https://github.com/dvershinin/lastversion
|
||||||
|
RUN \
|
||||||
|
apk add --no-cache git \
|
||||||
|
&& pip install --upgrade pip \
|
||||||
|
&& pip install lastversion
|
||||||
|
|
||||||
|
# Copy root filesystem
|
||||||
|
COPY rootfs /
|
||||||
|
|
||||||
|
# Set shell
|
||||||
|
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||||
42
addons_updater/README.md
Normal file
42
addons_updater/README.md
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
# Home assistant add-on: addon updated
|
||||||
|
![Supports aarch64 Architecture][aarch64-shield] ![Supports amd64 Architecture][amd64-shield] ![Supports armhf Architecture][armhf-shield] ![Supports armv7 Architecture][armv7-shield]
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
This script allows to automatically update addons based on upstream new releases
|
||||||
|
|
||||||
|
## 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. Click the `Save` button to store your configuration.
|
||||||
|
1. Make sure that the two ports are open on your router
|
||||||
|
1. Start the add-on.
|
||||||
|
1. Check the logs of the add-on to see if everything went well.
|
||||||
|
1. Carefully configure the add-on to your preferences, see the official documentation for for that.
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
No webUI. Set everything through configuration.
|
||||||
|
|
||||||
|
'''
|
||||||
|
- slug: the slug name from your repo
|
||||||
|
current: the initial version of your addon
|
||||||
|
beta: true/false ; should it look only for releases or prereleases ok
|
||||||
|
repository: 'name/repo' coming from github
|
||||||
|
upstream: name/repo, example is 'linuxserver/docker-emby'
|
||||||
|
- gituser: your github username
|
||||||
|
- gituser: your github email
|
||||||
|
- gitpass: add your github password here, or a specific key if you have two factor identification enabled
|
||||||
|
- frequency: placeholder for automatic update. Not used.
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
[repository]: https://github.com/alexbelgium/hassio-addons
|
||||||
|
[aarch64-shield]: https://img.shields.io/badge/aarch64-yes-green.svg
|
||||||
|
[amd64-shield]: https://img.shields.io/badge/amd64-yes-green.svg
|
||||||
|
[armhf-shield]: https://img.shields.io/badge/armhf-yes-green.svg
|
||||||
|
[armv7-shield]: https://img.shields.io/badge/armv7-yes-green.svg
|
||||||
8
addons_updater/build.json
Normal file
8
addons_updater/build.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"build_from": {
|
||||||
|
"aarch64": "homeassistant/aarch64-base-python:3.9-alpine3.13",
|
||||||
|
"armhf": "homeassistant/armhf-base-python:3.9-alpine3.13",
|
||||||
|
"armv7": "homeassistant/armv7-base-python:3.9-alpine3.13",
|
||||||
|
"amd64": "homeassistant/amd64-base-python:3.9-alpine3.13"
|
||||||
|
}
|
||||||
|
}
|
||||||
31
addons_updater/config.json
Normal file
31
addons_updater/config.json
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"name": "Addons_Updater",
|
||||||
|
"version": "1.0",
|
||||||
|
"slug": "updater",
|
||||||
|
"description": "Automatic addons update upon upstream new release",
|
||||||
|
"url": "https://github.com/alexbelgium/hassio-addons/tree/master/updater",
|
||||||
|
"arch": [
|
||||||
|
"aarch64",
|
||||||
|
"amd64",
|
||||||
|
"armv7",
|
||||||
|
"armhf"
|
||||||
|
],
|
||||||
|
"ports": {
|
||||||
|
},
|
||||||
|
"ports_description": {
|
||||||
|
},
|
||||||
|
"environment": {
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"addon": [{ "slug": "addon slug", "current": "1.1.1.1", "beta": false, "repository": "https://github.com/user/repo", "upstream": "github_user/repo_name" }],
|
||||||
|
"gituser": "gituser",
|
||||||
|
"gitpass": "gitpassword",
|
||||||
|
"frequency": 7
|
||||||
|
},
|
||||||
|
"schema": {
|
||||||
|
"addon": [{ "slug": "str", "current": "str", "beta": "bool" , "repository": "str", "upstream": "str"}],
|
||||||
|
"gituser": "str",
|
||||||
|
"gitpass": "str",
|
||||||
|
"frequency": "int"
|
||||||
|
}
|
||||||
|
}
|
||||||
70
addons_updater/rootfs/etc/cont-init.d/run
Normal file
70
addons_updater/rootfs/etc/cont-init.d/run
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
#!/usr/bin/env bashio
|
||||||
|
|
||||||
|
bashio::log.info "Checking status of referenced repositoriess..."
|
||||||
|
|
||||||
|
#Defining github values
|
||||||
|
bashio::log.info "... github authentification"
|
||||||
|
GITUSER=$(bashio::config 'gituser')
|
||||||
|
GITPASS=$(bashio::config 'gitpass')
|
||||||
|
GITMAIL=$(bashio::config 'gitemail')
|
||||||
|
git config --system http.sslVerify false
|
||||||
|
git config --global credential.helper 'cache --timeout 7200'
|
||||||
|
git config --global user.name ${GITUSER}
|
||||||
|
git config --global user.password ${GITPASS}
|
||||||
|
git config --global user.email ${GITMAIL}
|
||||||
|
|
||||||
|
bashio::log.info "... parse addons"
|
||||||
|
for addons in $(bashio::config "addon|keys"); do
|
||||||
|
SLUG=$(bashio::config "addon[${addons}].slug")
|
||||||
|
REPOSITORY=$(bashio::config "addon[${addons}].repository")
|
||||||
|
UPSTREAM=$(bashio::config "addon[${addons}].upstream")
|
||||||
|
CURRENT=$(bashio::config "addon[${addons}].current")
|
||||||
|
BETA=$(bashio::config "addon[${addons}].beta")
|
||||||
|
BASENAME=$(basename $REPOSITORY)
|
||||||
|
bashio::log.info "... $SLUG : check started"
|
||||||
|
|
||||||
|
git remote set-url origin https://${GITUSER}:${GITPASS}@github.com/${REPOSITORY}
|
||||||
|
|
||||||
|
#If beta flag, select beta version
|
||||||
|
if [ ${BETA} = true ]; then
|
||||||
|
bashio::log.info "... $SLUG : beta is on"
|
||||||
|
LASTVERSION=$(lastversion --pre $UPSTREAM)
|
||||||
|
else
|
||||||
|
bashio::log.info "... $SLUG : beta is off"
|
||||||
|
LASTVERSION=$(lastversion $UPSTREAM)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ${CURRENT} != ${LASTVERSION} ]; then
|
||||||
|
bashio::log.info "... $SLUG : update from $CURRENT to $LASTVERSION"
|
||||||
|
|
||||||
|
#Update local version
|
||||||
|
bashio::log.info "... $SLUG : cloning base repo"
|
||||||
|
cd /
|
||||||
|
git clone https://github.com/${REPOSITORY} || cd /${BASENAME} && git fetch --all && git reset --hard origin/master
|
||||||
|
|
||||||
|
#Define the folder addon
|
||||||
|
bashio::log.info "... $SLUG : checking exists in repo"
|
||||||
|
cd /${BASENAME}/${SLUG} || bashio::log.error "$SLUG addon not found in this repository. Exiting." exit
|
||||||
|
|
||||||
|
#Change all instances of version
|
||||||
|
bashio::log.info "... $SLUG : updating files"
|
||||||
|
|
||||||
|
files=$(grep -rl '"'${CURRENT}'"' /hassio-addons/emby) && echo $files | xargs sed -i 's/"'${CURRENT}'"/"'${LASTVERSION}'"/g'
|
||||||
|
git commit -m "Bot update" $files
|
||||||
|
|
||||||
|
#Git commit and push
|
||||||
|
bashio::log.info "... $SLUG : push to master"
|
||||||
|
git remote set-url origin https://${GITUSER}:${GITPASS}@github.com/${REPOSITORY}
|
||||||
|
git push
|
||||||
|
|
||||||
|
#Update the current flag
|
||||||
|
bashio::log.info "... $SLUG : updating current flag"
|
||||||
|
sed -i "s/${CURRENT}/${LASTVERSION}/g" /data/options.json
|
||||||
|
|
||||||
|
#Log
|
||||||
|
bashio::log.info "... $SLUG : updated and published"
|
||||||
|
|
||||||
|
else
|
||||||
|
bashio::log.info "Addon $SLUG is already up-to-date."
|
||||||
|
fi
|
||||||
|
done
|
||||||
Reference in New Issue
Block a user