From 1f18cb1bfa16548c2fa10855e9ab218f9bf46521 Mon Sep 17 00:00:00 2001 From: baldarn Date: Mon, 12 Sep 2022 22:00:55 +0200 Subject: [PATCH 01/22] adding options for better customization of add on --- gitea/Dockerfile | 32 +++++++++--- gitea/config.json | 17 ++++--- gitea/rootfs/entrypoint.sh | 27 ++++++++++ .../cont-init.d/00-aaa_dockerfile_backup.sh | 50 +++++++++++++++++++ gitea/rootfs/etc/cont-init.d/99-run.sh | 16 ++++++ 5 files changed, 130 insertions(+), 12 deletions(-) create mode 100644 gitea/rootfs/entrypoint.sh create mode 100644 gitea/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh create mode 100644 gitea/rootfs/etc/cont-init.d/99-run.sh diff --git a/gitea/Dockerfile b/gitea/Dockerfile index 985a2b5fe..d2121fca8 100644 --- a/gitea/Dockerfile +++ b/gitea/Dockerfile @@ -31,17 +31,37 @@ ENV S6_CMD_WAIT_FOR_SERVICES=1 \ # 3 Install apps # ################## +# Add rootfs +COPY rootfs/ / + +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 || printf '%s\n' "${MODULES}" >/MODULESFILE + +# Manual apps +ENV PACKAGES="" + +# Automatic apps & bashio +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 || (printf '%s\n' "${PACKAGES:-}" > /ENVFILE; \ + if [ -f /etc/s6-overlay/s6-rc.d/init-migrations/run ]; then chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh && sed -i "1a /./etc/cont-init.d/00-aaa_dockerfile_backup.sh" /etc/s6-overlay/s6-rc.d/init-migrations/run;fi) + + EXPOSE 22 3000 ################ # 4 Entrypoint # ################ -#RUN chmod 777 /entrypoint.sh -#WORKDIR / -#ENTRYPOINT [ "/usr/bin/env" ] -#CMD [ "/entrypoint.sh" ] -#SHELL ["/bin/bash", "-o", "pipefail", "-c"] +RUN chmod 777 /entrypoint.sh +ENTRYPOINT [ "/entrypoint.sh" ] ############ # 5 Labels # @@ -71,4 +91,4 @@ LABEL \ 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} \ No newline at end of file + org.opencontainers.image.version=${BUILD_VERSION} diff --git a/gitea/config.json b/gitea/config.json index 6cb635402..d9730f44e 100644 --- a/gitea/config.json +++ b/gitea/config.json @@ -5,7 +5,6 @@ ], "codenotary": "alexandrep.github@gmail.com", "description": "Gitea for Home Assistant", - "image": "ghcr.io/alexbelgium/gitea-{arch}", "init": false, "map": [ "share:rw", @@ -15,7 +14,10 @@ "options": { "certfile": "fullchain.pem", "keyfile": "privkey.pem", - "ssl": false + "ssl": false, + "SITE_TITLE": "Gitea: Git with a cup of tea", + "SERVER_DOMAIN": "localhost", + "BASE_URL": "http://localhost:3000/" }, "ports": { "22/tcp": 2222, @@ -23,15 +25,18 @@ }, "ports_description": { "22/tcp": "Ssh", - "3000/tcp": "Http web interface" + "3000/tcp": "Web interface" }, "schema": { "certfile": "str", "keyfile": "str", - "ssl": "bool" + "ssl": "bool", + "SITE_TITLE": "str", + "SERVER_DOMAIN": "str", + "BASE_URL": "str" }, "slug": "gitea", - "url": "https://github.com/alexbelgium/hassio-addons/tree/master/gitea", - "version": "1.17.2", + "url": "https://github.com/baldarn/hassio-addons/tree/master/gitea", + "version": "1.17.2-1", "webui": "[PROTO:ssl]://[HOST]:[PORT:3000]" } diff --git a/gitea/rootfs/entrypoint.sh b/gitea/rootfs/entrypoint.sh new file mode 100644 index 000000000..85d8a9212 --- /dev/null +++ b/gitea/rootfs/entrypoint.sh @@ -0,0 +1,27 @@ +#!/bin/bash +echo "Starting..." + +############################ +# Backup Dockerfile Script # +############################ + +if [ -f /etc/cont-init.d/00-aaa_dockerfile_backup.sh ]; then + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/00-aaa_dockerfile_backup.sh + chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh + /./etc/cont-init.d/00-aaa_dockerfile_backup.sh + rm /etc/cont-init.d/00-aaa_dockerfile_backup.sh +fi + +#################### +# 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 diff --git a/gitea/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/gitea/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..b983e4efc --- /dev/null +++ b/gitea/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# If dockerfile failed install manually + +############################## +# Automatic modules download # +############################## +if [ -e "/MODULESFILE" ]; then + MODULES=$(/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 +fi + +####################### +# Automatic installer # +####################### +if [ -e "/ENVFILE" ]; then + PACKAGES=$(/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 +fi + +if [ -e "/MODULESFILE" ] && [ ! -f /entrypoint.sh ]; then + for scripts in $MODULES; do + echo "$scripts : executing" + chown "$(id -u)":"$(id -g)" /etc/cont-init.d/"$scripts" + chmod a+x /etc/cont-init.d/"$scripts" + /./etc/cont-init.d/"$scripts" || echo "/etc/cont-init.d/$scripts: exiting $?" + rm /etc/cont-init.d/"$scripts" + done | tac +fi + +####################### +# Correct permissions # +####################### +[ -d /etc/services.d ] && chmod -R 777 /etc/services.d +[ -d /etc/cont-init.d ] && chmod -R 777 /etc/cont-init.d diff --git a/gitea/rootfs/etc/cont-init.d/99-run.sh b/gitea/rootfs/etc/cont-init.d/99-run.sh new file mode 100644 index 000000000..9aaa4e3bc --- /dev/null +++ b/gitea/rootfs/etc/cont-init.d/99-run.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bashio +# shellcheck shell=bash + +SITE_TITLE=$(bashio::config 'SITE_TITLE') +SERVER_DOMAIN=$(bashio::config 'SERVER_DOMAIN') +BASE_URL=$(bashio::config 'BASE_URL') + +echo "site tile $SITE_TITLE" +echo "server domain $SERVER_DOMAIN" +echo "base url $BASE_URL" + +# sed "s/^APP.*/APP = $SITE_TITLE/" /data/gitea/conf/app.ini +# sed "s/^DOMAIN.*/DOMAIN = $SERVER_DOMAIN/" /data/gitea/conf/app.ini +# sed "s/^ROOT_URL.*/ROOT_URL = $BASE_URL/" /data/gitea/conf/app.ini + +exec "$@" From 1ce8971e09a42e024dd741189c6ddd7a4c4c56f0 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 18 Sep 2022 13:54:54 +0200 Subject: [PATCH 02/22] Uses official entrypoint --- gitea/rootfs/etc/cont-init.d/99-run.sh | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gitea/rootfs/etc/cont-init.d/99-run.sh b/gitea/rootfs/etc/cont-init.d/99-run.sh index 9aaa4e3bc..d9c4eb2b7 100644 --- a/gitea/rootfs/etc/cont-init.d/99-run.sh +++ b/gitea/rootfs/etc/cont-init.d/99-run.sh @@ -13,4 +13,19 @@ echo "base url $BASE_URL" # sed "s/^DOMAIN.*/DOMAIN = $SERVER_DOMAIN/" /data/gitea/conf/app.ini # sed "s/^ROOT_URL.*/ROOT_URL = $BASE_URL/" /data/gitea/conf/app.ini -exec "$@" +############## +# SSL CONFIG # +############## + +bashio::config.require.ssl +if bashio::config.true 'ssl'; then +bashio::log.info "Ssl is enabled" +fi + +############## +# LAUNCH APP # +############## + +bashio::log.info "Please wait while the app is loading !" + +/./usr/bin/entrypoint From 31b442e42f6679d8fe66de877368fd391c34e387 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 18 Sep 2022 13:56:04 +0200 Subject: [PATCH 03/22] Add banner --- gitea/Dockerfile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gitea/Dockerfile b/gitea/Dockerfile index d2121fca8..2655f3979 100644 --- a/gitea/Dockerfile +++ b/gitea/Dockerfile @@ -34,6 +34,15 @@ ENV S6_CMD_WAIT_FOR_SERVICES=1 \ # 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" + +# 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 \ @@ -53,7 +62,6 @@ RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get && rm /automatic_packages.sh || (printf '%s\n' "${PACKAGES:-}" > /ENVFILE; \ if [ -f /etc/s6-overlay/s6-rc.d/init-migrations/run ]; then chmod +x /etc/cont-init.d/00-aaa_dockerfile_backup.sh && sed -i "1a /./etc/cont-init.d/00-aaa_dockerfile_backup.sh" /etc/s6-overlay/s6-rc.d/init-migrations/run;fi) - EXPOSE 22 3000 ################ From 66668a1fcade70727c4d0cbf98a6621f693e261b Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 18 Sep 2022 14:06:27 +0200 Subject: [PATCH 04/22] Update 99-run.sh --- gitea/rootfs/etc/cont-init.d/99-run.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gitea/rootfs/etc/cont-init.d/99-run.sh b/gitea/rootfs/etc/cont-init.d/99-run.sh index d9c4eb2b7..4b91a3259 100644 --- a/gitea/rootfs/etc/cont-init.d/99-run.sh +++ b/gitea/rootfs/etc/cont-init.d/99-run.sh @@ -1,6 +1,10 @@ #!/usr/bin/env bashio # shellcheck shell=bash +for file in /data/gitea/conf/app.ini /etc/templates/app.ini; do +PROTOCOL = http +done + SITE_TITLE=$(bashio::config 'SITE_TITLE') SERVER_DOMAIN=$(bashio::config 'SERVER_DOMAIN') BASE_URL=$(bashio::config 'BASE_URL') @@ -13,15 +17,27 @@ echo "base url $BASE_URL" # sed "s/^DOMAIN.*/DOMAIN = $SERVER_DOMAIN/" /data/gitea/conf/app.ini # sed "s/^ROOT_URL.*/ROOT_URL = $BASE_URL/" /data/gitea/conf/app.ini + +for file in /data/gitea/conf/app.ini /etc/templates/app.ini; do + ############## # SSL CONFIG # ############## +# Clean values +sed -i "/PROTOCOL/d" + +# Add ssl bashio::config.require.ssl if bashio::config.true 'ssl'; then bashio::log.info "Ssl is enabled" +sed -i "/server/a PROTOCOL = https" "$file" +else +sed -i "/server/a PROTOCOL = http" "$file" fi +done + ############## # LAUNCH APP # ############## From 7f6f13d4ad0ff795fe116fd4fb545096e74743c1 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 18 Sep 2022 15:31:21 +0200 Subject: [PATCH 05/22] Adap app.ini --- gitea/rootfs/etc/cont-init.d/99-run.sh | 35 +++++++++++++------------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/gitea/rootfs/etc/cont-init.d/99-run.sh b/gitea/rootfs/etc/cont-init.d/99-run.sh index 4b91a3259..d9e662f65 100644 --- a/gitea/rootfs/etc/cont-init.d/99-run.sh +++ b/gitea/rootfs/etc/cont-init.d/99-run.sh @@ -2,36 +2,35 @@ # shellcheck shell=bash for file in /data/gitea/conf/app.ini /etc/templates/app.ini; do -PROTOCOL = http + +############## +# OTHER CONF # +############## + +for param in APP_NAME DOMAIN ROOT_URL; do + if bashio::config.has_value "$param"; then + echo "parameter set : $param=$(bashio::config '$param')" + sed -i "/$param/d" "$file" + sed -i "/server/a $param = $(bashio::config '$param')" "$file" + fi done -SITE_TITLE=$(bashio::config 'SITE_TITLE') -SERVER_DOMAIN=$(bashio::config 'SERVER_DOMAIN') -BASE_URL=$(bashio::config 'BASE_URL') - -echo "site tile $SITE_TITLE" -echo "server domain $SERVER_DOMAIN" -echo "base url $BASE_URL" - -# sed "s/^APP.*/APP = $SITE_TITLE/" /data/gitea/conf/app.ini -# sed "s/^DOMAIN.*/DOMAIN = $SERVER_DOMAIN/" /data/gitea/conf/app.ini -# sed "s/^ROOT_URL.*/ROOT_URL = $BASE_URL/" /data/gitea/conf/app.ini - - -for file in /data/gitea/conf/app.ini /etc/templates/app.ini; do - ############## # SSL CONFIG # ############## # Clean values -sed -i "/PROTOCOL/d" +sed -i "/PROTOCOL/d" "$file" +sed -i "/CERT_FILE/d" "$file" +sed -i "/KEY_FILE/d" "$file" # Add ssl bashio::config.require.ssl if bashio::config.true 'ssl'; then -bashio::log.info "Ssl is enabled" +bashio::log.info "ssl is enabled" sed -i "/server/a PROTOCOL = https" "$file" +sed -i "/server/a CERT_FILE = /ssl/$(bashio::config 'certfile'" "$file" +sed -i "/server/a KEY_FILE = /ssl/$(bashio::config 'keyfile'" "$file" else sed -i "/server/a PROTOCOL = http" "$file" fi From 0bd29df0408ba85851739ab314c13d28fe2c8d4b Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 18 Sep 2022 15:32:36 +0200 Subject: [PATCH 06/22] Adapt config --- gitea/config.json | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/gitea/config.json b/gitea/config.json index d9730f44e..04e687b99 100644 --- a/gitea/config.json +++ b/gitea/config.json @@ -14,10 +14,7 @@ "options": { "certfile": "fullchain.pem", "keyfile": "privkey.pem", - "ssl": false, - "SITE_TITLE": "Gitea: Git with a cup of tea", - "SERVER_DOMAIN": "localhost", - "BASE_URL": "http://localhost:3000/" + "ssl": false }, "ports": { "22/tcp": 2222, @@ -31,9 +28,9 @@ "certfile": "str", "keyfile": "str", "ssl": "bool", - "SITE_TITLE": "str", - "SERVER_DOMAIN": "str", - "BASE_URL": "str" + "APP_NAME": "str?", + "DOMAIN": "str?", + "ROOT_URL": "str?" }, "slug": "gitea", "url": "https://github.com/baldarn/hassio-addons/tree/master/gitea", From cf0a96049f4c1ff7a906b3d1159ed6c52cee4438 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Sun, 18 Sep 2022 17:55:15 +0200 Subject: [PATCH 07/22] Correction --- gitea/rootfs/etc/cont-init.d/99-run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitea/rootfs/etc/cont-init.d/99-run.sh b/gitea/rootfs/etc/cont-init.d/99-run.sh index d9e662f65..c1e0f04f0 100644 --- a/gitea/rootfs/etc/cont-init.d/99-run.sh +++ b/gitea/rootfs/etc/cont-init.d/99-run.sh @@ -29,8 +29,8 @@ bashio::config.require.ssl if bashio::config.true 'ssl'; then bashio::log.info "ssl is enabled" sed -i "/server/a PROTOCOL = https" "$file" -sed -i "/server/a CERT_FILE = /ssl/$(bashio::config 'certfile'" "$file" -sed -i "/server/a KEY_FILE = /ssl/$(bashio::config 'keyfile'" "$file" +sed -i "/server/a CERT_FILE = /ssl/$(bashio::config 'certfile')" "$file" +sed -i "/server/a KEY_FILE = /ssl/$(bashio::config 'keyfile')" "$file" else sed -i "/server/a PROTOCOL = http" "$file" fi From 826ff85ca88235e6df9f8e24263e40e38e4fc40b Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 19 Sep 2022 06:59:35 +0200 Subject: [PATCH 08/22] Avoid error if file doesnt exist --- gitea/rootfs/etc/cont-init.d/99-run.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gitea/rootfs/etc/cont-init.d/99-run.sh b/gitea/rootfs/etc/cont-init.d/99-run.sh index c1e0f04f0..059c27027 100644 --- a/gitea/rootfs/etc/cont-init.d/99-run.sh +++ b/gitea/rootfs/etc/cont-init.d/99-run.sh @@ -3,6 +3,10 @@ for file in /data/gitea/conf/app.ini /etc/templates/app.ini; do +if [ ! -f "$file" ]; then +continue +fi + ############## # OTHER CONF # ############## From 8acf27d2fa9e69f02d024b25b27c79c389a22737 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 19 Sep 2022 10:38:29 +0200 Subject: [PATCH 09/22] Update 99-run.sh --- gitea/rootfs/etc/cont-init.d/99-run.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gitea/rootfs/etc/cont-init.d/99-run.sh b/gitea/rootfs/etc/cont-init.d/99-run.sh index 059c27027..c3bc57920 100644 --- a/gitea/rootfs/etc/cont-init.d/99-run.sh +++ b/gitea/rootfs/etc/cont-init.d/99-run.sh @@ -12,9 +12,12 @@ fi ############## for param in APP_NAME DOMAIN ROOT_URL; do + # Remove parameter + sed -i "/$param/d" "$file" + + # Define parameter if bashio::config.has_value "$param"; then echo "parameter set : $param=$(bashio::config '$param')" - sed -i "/$param/d" "$file" sed -i "/server/a $param = $(bashio::config '$param')" "$file" fi done From 470a20e0869fe1d7e3dd07d5dcb8ca92c065eeec Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 19 Sep 2022 10:48:07 +0200 Subject: [PATCH 10/22] Automatically adapt port --- gitea/rootfs/etc/cont-init.d/99-run.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gitea/rootfs/etc/cont-init.d/99-run.sh b/gitea/rootfs/etc/cont-init.d/99-run.sh index c3bc57920..7db6492fd 100644 --- a/gitea/rootfs/etc/cont-init.d/99-run.sh +++ b/gitea/rootfs/etc/cont-init.d/99-run.sh @@ -7,6 +7,13 @@ if [ ! -f "$file" ]; then continue fi +############## +# ADAPT PORT # +############## + +sed -i "/HTTP_PORT/d" "$file" +sed -i "/server/a HTTP_PORT = $(bashio::addon.port 3000)" "$file" + ############## # OTHER CONF # ############## From 805acd4e16fa351ba994f212ecd2cb0002595897 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 19 Sep 2022 10:50:44 +0200 Subject: [PATCH 11/22] Adapt default domain --- gitea/config.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gitea/config.json b/gitea/config.json index 04e687b99..7d5ebf17a 100644 --- a/gitea/config.json +++ b/gitea/config.json @@ -14,7 +14,8 @@ "options": { "certfile": "fullchain.pem", "keyfile": "privkey.pem", - "ssl": false + "ssl": false, + "DOMAIN": "homeassistant.local" }, "ports": { "22/tcp": 2222, @@ -29,7 +30,7 @@ "keyfile": "str", "ssl": "bool", "APP_NAME": "str?", - "DOMAIN": "str?", + "DOMAIN": "str", "ROOT_URL": "str?" }, "slug": "gitea", From 8d6cad5bb0aa3b9c784b0026ff8461ed9719afd5 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 19 Sep 2022 10:52:49 +0200 Subject: [PATCH 12/22] Update README.md --- gitea/README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gitea/README.md b/gitea/README.md index 53c1fc08b..12d7311b5 100644 --- a/gitea/README.md +++ b/gitea/README.md @@ -25,6 +25,10 @@ This addon is based on the [docker image](https://hub.docker.com/r/gitea/gitea). ```yaml certfile: fullchain.pem #ssl certificate, must be located in /ssl keyfile: privkey.pem #sslkeyfile, must be located in /ssl +ssl: should the app use https or not +APP_NAME: name of the app +DOMAIN: domain to be reached # default : homeassistant.local +ROOT_URL: customize root_url, should not be needed unless specific needs ``` Webui can be found at `:port`. From f1bfc36ef95accc6e243249de5e9fd925db8c3e7 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 19 Sep 2022 15:47:47 +0200 Subject: [PATCH 13/22] Allowing changing ssl permissions --- gitea/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitea/config.json b/gitea/config.json index 7d5ebf17a..4f7847c51 100644 --- a/gitea/config.json +++ b/gitea/config.json @@ -8,7 +8,7 @@ "init": false, "map": [ "share:rw", - "ssl:ro" + "ssl:rw" ], "name": "Gitea", "options": { From 1d5765215d4fb58d98e49a402f9ab4ba78c06f7d Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 19 Sep 2022 15:48:09 +0200 Subject: [PATCH 14/22] User root --- gitea/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gitea/Dockerfile b/gitea/Dockerfile index 2655f3979..2dab99601 100644 --- a/gitea/Dockerfile +++ b/gitea/Dockerfile @@ -26,6 +26,8 @@ FROM ${BUILD_FROM} ENV S6_CMD_WAIT_FOR_SERVICES=1 \ S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0 \ S6_SERVICES_GRACETIME=0 + +USER root ################## # 3 Install apps # From 7d9d2fdc48fe3b6c35d02de0a0af97ca17a386ea Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 19 Sep 2022 15:50:43 +0200 Subject: [PATCH 15/22] Allow ssl usage by user git --- gitea/rootfs/etc/cont-init.d/99-run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/gitea/rootfs/etc/cont-init.d/99-run.sh b/gitea/rootfs/etc/cont-init.d/99-run.sh index 7db6492fd..262e799d0 100644 --- a/gitea/rootfs/etc/cont-init.d/99-run.sh +++ b/gitea/rootfs/etc/cont-init.d/99-run.sh @@ -45,6 +45,7 @@ bashio::log.info "ssl is enabled" sed -i "/server/a PROTOCOL = https" "$file" sed -i "/server/a CERT_FILE = /ssl/$(bashio::config 'certfile')" "$file" sed -i "/server/a KEY_FILE = /ssl/$(bashio::config 'keyfile')" "$file" +chmod 744 /ssl/* else sed -i "/server/a PROTOCOL = http" "$file" fi From 5af40d6e333d98d412857a671eb217afa942d084 Mon Sep 17 00:00:00 2001 From: baldarn Date: Mon, 26 Sep 2022 14:50:42 +0200 Subject: [PATCH 16/22] removed confs --- gitea/config.json | 10 +++------- gitea/rootfs/etc/cont-init.d/99-run.sh | 15 --------------- 2 files changed, 3 insertions(+), 22 deletions(-) diff --git a/gitea/config.json b/gitea/config.json index 4f7847c51..ae1d659be 100644 --- a/gitea/config.json +++ b/gitea/config.json @@ -14,8 +14,7 @@ "options": { "certfile": "fullchain.pem", "keyfile": "privkey.pem", - "ssl": false, - "DOMAIN": "homeassistant.local" + "ssl": false }, "ports": { "22/tcp": 2222, @@ -28,13 +27,10 @@ "schema": { "certfile": "str", "keyfile": "str", - "ssl": "bool", - "APP_NAME": "str?", - "DOMAIN": "str", - "ROOT_URL": "str?" + "ssl": "bool" }, "slug": "gitea", - "url": "https://github.com/baldarn/hassio-addons/tree/master/gitea", + "url": "https://github.com/alexbelgium/hassio-addons/tree/master/gitea", "version": "1.17.2-1", "webui": "[PROTO:ssl]://[HOST]:[PORT:3000]" } diff --git a/gitea/rootfs/etc/cont-init.d/99-run.sh b/gitea/rootfs/etc/cont-init.d/99-run.sh index 262e799d0..8b563918f 100644 --- a/gitea/rootfs/etc/cont-init.d/99-run.sh +++ b/gitea/rootfs/etc/cont-init.d/99-run.sh @@ -13,21 +13,6 @@ fi sed -i "/HTTP_PORT/d" "$file" sed -i "/server/a HTTP_PORT = $(bashio::addon.port 3000)" "$file" - -############## -# OTHER CONF # -############## - -for param in APP_NAME DOMAIN ROOT_URL; do - # Remove parameter - sed -i "/$param/d" "$file" - - # Define parameter - if bashio::config.has_value "$param"; then - echo "parameter set : $param=$(bashio::config '$param')" - sed -i "/server/a $param = $(bashio::config '$param')" "$file" - fi -done ############## # SSL CONFIG # From 2a04b88a2d43e26873f515e404ec0ecfabfb9385 Mon Sep 17 00:00:00 2001 From: baldarn Date: Mon, 26 Sep 2022 15:04:36 +0200 Subject: [PATCH 17/22] added changelog --- gitea/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gitea/CHANGELOG.md b/gitea/CHANGELOG.md index 9d8161ee2..0fb028fd7 100644 --- a/gitea/CHANGELOG.md +++ b/gitea/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.17.2-1 (26-09-2022) +- fixed error with ssl + ## 1.17.2 (07-09-2022) - Update to version 1.17.2 from go-gitea/gitea From efdf491145d99bfbcc3146e69f841c9b5b089d4a Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 26 Sep 2022 15:07:46 +0200 Subject: [PATCH 18/22] Add parameters --- gitea/rootfs/etc/cont-init.d/99-run.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gitea/rootfs/etc/cont-init.d/99-run.sh b/gitea/rootfs/etc/cont-init.d/99-run.sh index 8b563918f..065e76622 100644 --- a/gitea/rootfs/etc/cont-init.d/99-run.sh +++ b/gitea/rootfs/etc/cont-init.d/99-run.sh @@ -37,6 +37,25 @@ fi done +#################### +# ADAPT PARAMETERS # +#################### + +for param in APP_NAME DOMAIN ROOT_URL; do + # Remove parameter + sed -i "/$param/d" "$file" + + # Define parameter + if bashio::config.has_value "$param"; then + echo "parameter set : $param=$(bashio::config '$param')" + sed -i "/server/a $param = $(bashio::config '$param')" "$file" + fi + + # Allow at setup + sed -i "1a $param = $(bashio::config '$param')" /etc/s6/gitea/setup + +done + ############## # LAUNCH APP # ############## From 22684e810029c47c2a4c39ebe302a1c7c37716bb Mon Sep 17 00:00:00 2001 From: baldarn Date: Mon, 26 Sep 2022 15:11:15 +0200 Subject: [PATCH 19/22] test changelog with other version number --- gitea/CHANGELOG.md | 2 +- gitea/config.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gitea/CHANGELOG.md b/gitea/CHANGELOG.md index 0fb028fd7..5a98a3eb9 100644 --- a/gitea/CHANGELOG.md +++ b/gitea/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.17.2-1 (26-09-2022) +## 1.17.2.1 (26-09-2022) - fixed error with ssl ## 1.17.2 (07-09-2022) diff --git a/gitea/config.json b/gitea/config.json index ae1d659be..a3b313ebd 100644 --- a/gitea/config.json +++ b/gitea/config.json @@ -31,6 +31,6 @@ }, "slug": "gitea", "url": "https://github.com/alexbelgium/hassio-addons/tree/master/gitea", - "version": "1.17.2-1", + "version": "1.17.2.1", "webui": "[PROTO:ssl]://[HOST]:[PORT:3000]" } From c89892e4bc6761e9964411a79c9f2826038b4566 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 26 Sep 2022 15:26:05 +0200 Subject: [PATCH 20/22] Readd parameters to config --- gitea/config.json | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gitea/config.json b/gitea/config.json index a3b313ebd..bf6d09e4e 100644 --- a/gitea/config.json +++ b/gitea/config.json @@ -14,7 +14,9 @@ "options": { "certfile": "fullchain.pem", "keyfile": "privkey.pem", - "ssl": false + "ssl": false, + "APP_NAME": "Gitea for Homeassistant", + "DOMAIN": "homeassistant.local" }, "ports": { "22/tcp": 2222, @@ -27,7 +29,10 @@ "schema": { "certfile": "str", "keyfile": "str", - "ssl": "bool" + "ssl": "bool", + "APP_NAME": "str?", + "DOMAIN": "str", + "ROOT_URL": "str?" }, "slug": "gitea", "url": "https://github.com/alexbelgium/hassio-addons/tree/master/gitea", From c5d90d076b1d7d68b676add0eb14e4c7510447a0 Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 26 Sep 2022 15:27:13 +0200 Subject: [PATCH 21/22] Readd image --- gitea/config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/gitea/config.json b/gitea/config.json index bf6d09e4e..1560d815d 100644 --- a/gitea/config.json +++ b/gitea/config.json @@ -5,6 +5,7 @@ ], "codenotary": "alexandrep.github@gmail.com", "description": "Gitea for Home Assistant", + "image": "ghcr.io/alexbelgium/gitea-{arch}", "init": false, "map": [ "share:rw", From 0a15f5d387560b259373ab618d090526e629666b Mon Sep 17 00:00:00 2001 From: Alexandre <44178713+alexbelgium@users.noreply.github.com> Date: Mon, 26 Sep 2022 15:29:55 +0200 Subject: [PATCH 22/22] Attach env variables --- gitea/rootfs/etc/cont-init.d/99-run.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gitea/rootfs/etc/cont-init.d/99-run.sh b/gitea/rootfs/etc/cont-init.d/99-run.sh index 065e76622..be1738d01 100644 --- a/gitea/rootfs/etc/cont-init.d/99-run.sh +++ b/gitea/rootfs/etc/cont-init.d/99-run.sh @@ -12,7 +12,7 @@ fi ############## sed -i "/HTTP_PORT/d" "$file" -sed -i "/server/a HTTP_PORT = $(bashio::addon.port 3000)" "$file" +sed -i "/server/a HTTP_PORT=$(bashio::addon.port 3000)" "$file" ############## # SSL CONFIG # @@ -27,12 +27,12 @@ sed -i "/KEY_FILE/d" "$file" bashio::config.require.ssl if bashio::config.true 'ssl'; then bashio::log.info "ssl is enabled" -sed -i "/server/a PROTOCOL = https" "$file" -sed -i "/server/a CERT_FILE = /ssl/$(bashio::config 'certfile')" "$file" -sed -i "/server/a KEY_FILE = /ssl/$(bashio::config 'keyfile')" "$file" +sed -i "/server/a PROTOCOL=https" "$file" +sed -i "/server/a CERT_FILE=/ssl/$(bashio::config 'certfile')" "$file" +sed -i "/server/a KEY_FILE=/ssl/$(bashio::config 'keyfile')" "$file" chmod 744 /ssl/* else -sed -i "/server/a PROTOCOL = http" "$file" +sed -i "/server/a PROTOCOL=http" "$file" fi done @@ -48,7 +48,7 @@ for param in APP_NAME DOMAIN ROOT_URL; do # Define parameter if bashio::config.has_value "$param"; then echo "parameter set : $param=$(bashio::config '$param')" - sed -i "/server/a $param = $(bashio::config '$param')" "$file" + sed -i "/server/a $param=$(bashio::config '$param')" "$file" fi # Allow at setup