This commit is contained in:
Alexandre
2023-09-09 19:33:00 +02:00
parent 195ba49217
commit 3dcae5f28f
11 changed files with 356 additions and 0 deletions

35
test/CHANGELOG.md Normal file
View File

@@ -0,0 +1,35 @@
## 3.18
- github_exclude: exclude a text in the release name
- Correct github_tagfilter usage in dockerhub
## 3.17
- Clean cache
## 3.16
- Removed git password option as it is no longer usable
## 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

109
test/Dockerfile Normal file
View File

@@ -0,0 +1,109 @@
#============================#
# 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/ /
# Modules
ARG MODULES="00-banner.sh 01-custom_script.sh"
# Automatic modules download
ADD --chmod=744 "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_modules.sh" "/ha_modules.sh"
RUN /ha_modules.sh "$MODULES" && rm /ha_modules.sh
# Manual apps
ENV PACKAGES=""
# Automatic apps & bashio
ADD --chmod=744 "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_modules.sh" "/ha_autoapps.sh"
RUN /ha_autoapps.sh "$PACKAGES" && rm /ha_autoapps.sh
################
# 4 Entrypoint #
################
# Add entrypoint
ENV S6_STAGE2_HOOK=/ha_entrypoint.sh
ADD --chmod=777 "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.templates/ha_entrypoint.sh" "/ha_entrypoint.sh"
# Entrypoint modifications
RUN \
# Corrects permissions for s6 v3
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 && \
#Correct shebang in entrypoint
for shebang in "/command/with-contenv bashio" "/usr/bin/env bashio" "/usr/bin/bashio" "/bin/bash" "/bin/sh"; do if [ -f "${shebang%% *}" ]; then break; fi; done; sed -i "s|/command/with-contenv bashio|$shebang|g" /ha_entrypoint.sh
# Entrypoint logic
#WORKDIR /
ENTRYPOINT [ "/usr/bin/env" ]
CMD [ "/ha_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 #
####################

87
test/README.md Normal file
View File

@@ -0,0 +1,87 @@
# Home assistant add-on: addons updater
[![Donate][donation-badge]](https://www.buymeacoffee.com/alexbelgium)
![Version](https://img.shields.io/badge/dynamic/json?label=Version&query=%24.version&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Faddons_updater%2Fconfig.json)
![Ingress](https://img.shields.io/badge/dynamic/json?label=Ingress&query=%24.ingress&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Faddons_updater%2Fconfig.json)
![Arch](https://img.shields.io/badge/dynamic/json?color=success&label=Arch&query=%24.arch&url=https%3A%2F%2Fraw.githubusercontent.com%2Falexbelgium%2Fhassio-addons%2Fmaster%2Faddons_updater%2Fconfig.json)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/9c6cf10bdbba45ecb202d7f579b5be0e)](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)
[![GitHub Super-Linter](https://github.com/alexbelgium/hassio-addons/workflows/Lint%20Code%20Base/badge.svg)](https://github.com/marketplace/actions/super-linter)
[![Builder](https://github.com/alexbelgium/hassio-addons/workflows/Builder/badge.svg)](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!_
[![Stargazers repo roster for @alexbelgium/hassio-addons](https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/.github/stars2.svg)](https://github.com/alexbelgium/hassio-addons/stargazers)
![downloads evolution](https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/addons_updater/stats.png)
## About
This script allows to automatically update addons based on upstream new releases. This is only an helper tool for developers. End users dont 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
- github_exclude: exclude 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
gitapi: your github api token(classic) https://github.com/settings/tokens
gitmail: your github email
verbose: 'false'
```
Example:
```yaml
repository: alexbelgium/hassio-addons
gituser: your github username
gitapi: your github api token
gitmail: your github email
verbose: "false"
```
[repository]: https://github.com/alexbelgium/hassio-addons

58
test/apparmor.txt Normal file
View File

@@ -0,0 +1,58 @@
#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,
}
}

10
test/build.json Normal file
View File

@@ -0,0 +1,10 @@
{
"build_from": {
"aarch64": "ghcr.io/hassio-addons/base-python/aarch64:stable",
"amd64": "ghcr.io/hassio-addons/base-python/amd64:stable",
"armv7": "ghcr.io/hassio-addons/base-python/armv7:stable"
},
"codenotary": {
"signer": "alexandrep.github@gmail.com"
}
}

35
test/config.json Normal file
View File

@@ -0,0 +1,35 @@
{
"arch": [
"aarch64",
"amd64",
"armv7"
],
"boot": "manual",
"codenotary": "alexandrep.github@gmail.com",
"description": "Automatic addons update by aligning version tag with upstream releases",
"environment": {
"GIT_DISCOVERY_ACROSS_FILESYSTEM": "1"
},
"image": "ghcr.io/alexbelgium/null-{arch}",
"init": false,
"map": [
"config:rw"
],
"name": "ZZ Fake addon, used to test my builds",
"options": {
"gitapi": "gitapi",
"gituser": "gituser",
"repository": "alexbelgium/hassio-addons"
},
"schema": {
"dry_run": "bool?",
"gitapi": "str",
"gitmail": "str?",
"gituser": "str",
"repository": "str",
"verbose": "bool?"
},
"slug": "test",
"url": "https://github.com/alexbelgium/hassio-addons/tree/master/addons_updater",
"version": "3.18.3"
}

BIN
test/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

BIN
test/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

View File

@@ -0,0 +1,6 @@
#!/usr/bin/with-contenv bashio
# shellcheck shell=bash
bashio::log.info "It's working"
sleep 10000

BIN
test/stats.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

16
test/template.json Normal file
View File

@@ -0,0 +1,16 @@
{
"dockerhub_by_date": "",
"dockerhub_list_size": "",
"fulltag": false,
"github_beta": false,
"github_exclude": "",
"github_havingasset": false,
"github_tagfilter": "",
"last_update": "",
"paused": false,
"repository": "",
"slug": "",
"source": "github",
"upstream_repo": "",
"upstream_version": ""
}