diff --git a/addons_updater/Dockerfile b/addons_updater/Dockerfile index 356295086..045edb547 100644 --- a/addons_updater/Dockerfile +++ b/addons_updater/Dockerfile @@ -1,18 +1,18 @@ -############### -# Build Image # -############### +################# +# 1 Build Image # +################# ARG BUILD_FROM FROM $BUILD_FROM VOLUME [ "/data" ] -################ -# Modify Image # -################ +################## +# 2 Modify Image # +################## -################ -# Install apps # -################ +################## +# 3 Install apps # +################## # Add rootfs COPY rootfs/ / @@ -21,17 +21,17 @@ COPY rootfs/ / ENV PACKAGES="" # Automatic apps & bashio -RUN $(ls /bin/bash &>/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl || apk add --no-cache curl) && \ +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); 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); fi && \ curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ chmod 777 /automatic_packages.sh && \ /automatic_packages.sh "${PACKAGES:-}" && \ rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE -############## -# Entrypoint # -############## - +################ +# 4 Entrypoint # +################ + # Entrypoint logic RUN chmod 777 /entrypoint.sh #WORKDIR / @@ -40,9 +40,9 @@ CMD [ "/entrypoint.sh" ] # Set shell SHELL ["/bin/bash", "-o", "pipefail", "-c"] -########## -# Labels # -########## +############ +# 5 Labels # +############ ARG BUILD_ARCH ARG BUILD_DATE diff --git a/addons_updater/rootfs/entrypoint.sh b/addons_updater/rootfs/entrypoint.sh index bf5da4a6c..35ccb7382 100644 --- a/addons_updater/rootfs/entrypoint.sh +++ b/addons_updater/rootfs/entrypoint.sh @@ -2,34 +2,6 @@ echo "Starting..." -################################### -# Export all addon options as env # -################################### - -# For all keys in options.json -JSONSOURCE="/data/options.json" - -# Export keys as env variables -echo "All addon options were exported as variables" -mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE}) -for KEYS in ${arr[@]}; do - # export key - VALUE=$(jq .$KEYS ${JSONSOURCE}) - export ${KEYS}=${VALUE//[\"\']/} &>/dev/null -done - -################ -# Set timezone # -################ -if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then - if [ -f /usr/share/zoneinfo/$TZ ]; then - echo "Timezone set from $(cat /etc/timezone) to $TZ" - ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone - else - echo "WARNING : Timezone $TZ is invalid, it will be kept to default value of $(cat /etc/timezone)" - fi -fi - #################### # Starting scripts # #################### diff --git a/addons_updater/rootfs/scripts/00-aaa_dockerfile_backup.sh b/addons_updater/rootfs/scripts/00-aaa_dockerfile_backup.sh index e33f7f063..4f9ed9c51 100644 --- a/addons_updater/rootfs/scripts/00-aaa_dockerfile_backup.sh +++ b/addons_updater/rootfs/scripts/00-aaa_dockerfile_backup.sh @@ -2,18 +2,17 @@ # If dockerfile failed install manually if [ -e "/ENVFILE" ]; then echo "Executing script" - PACKAGES=$(< /ENVFILE) + PACKAGES=$(/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl &>/dev/null || apk add --no-cache curl) && \ - curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ - chmod 777 /automatic_packages.sh && \ - eval /./automatic_packages.sh "$PACKAGES" && \ - rm /automatic_packages.sh - + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/arpspoof/CHANGELOG.md b/arpspoof/CHANGELOG.md index 6256f6532..18af5d834 100644 --- a/arpspoof/CHANGELOG.md +++ b/arpspoof/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 1.0.0 (07-12-2021) - Update to latest version from t0mer/Arpspoof-Docker diff --git a/arpspoof/Dockerfile b/arpspoof/Dockerfile index 72c4fd184..b596b54f2 100644 --- a/arpspoof/Dockerfile +++ b/arpspoof/Dockerfile @@ -1,18 +1,18 @@ -############### -# Build Image # -############### +################# +# 1 Build Image # +################# ARG BUILD_FROM ARG BUILD_VERSION FROM techblog/arpspoof-docker:latest -################ -# Modify Image # -################ +################## +# 2 Modify Image # +################## -################ -# Install apps # -################ +################## +# 3 Install apps # +################## # Add rootfs COPY rootfs/ / @@ -21,24 +21,24 @@ COPY rootfs/ / ENV PACKAGES="jq curl iproute2" # Automatic apps & bashio -RUN $(ls /bin/bash &>/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl || apk add --no-cache curl) && \ +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); 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); fi && \ curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ chmod 777 /automatic_packages.sh && \ /automatic_packages.sh "${PACKAGES:-}" && \ rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE -############## -# Entrypoint # -############## +################ +# 4 Entrypoint # +################ RUN chmod 777 /entrypoint.sh ENTRYPOINT [ "/usr/bin/env" ] CMD [ "/entrypoint.sh" ] -########## -# Labels # -########## +############ +# 5 Labels # +############ ARG BUILD_ARCH ARG BUILD_DATE diff --git a/arpspoof/rootfs/entrypoint.sh b/arpspoof/rootfs/entrypoint.sh index bf5da4a6c..35ccb7382 100644 --- a/arpspoof/rootfs/entrypoint.sh +++ b/arpspoof/rootfs/entrypoint.sh @@ -2,34 +2,6 @@ echo "Starting..." -################################### -# Export all addon options as env # -################################### - -# For all keys in options.json -JSONSOURCE="/data/options.json" - -# Export keys as env variables -echo "All addon options were exported as variables" -mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE}) -for KEYS in ${arr[@]}; do - # export key - VALUE=$(jq .$KEYS ${JSONSOURCE}) - export ${KEYS}=${VALUE//[\"\']/} &>/dev/null -done - -################ -# Set timezone # -################ -if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then - if [ -f /usr/share/zoneinfo/$TZ ]; then - echo "Timezone set from $(cat /etc/timezone) to $TZ" - ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone - else - echo "WARNING : Timezone $TZ is invalid, it will be kept to default value of $(cat /etc/timezone)" - fi -fi - #################### # Starting scripts # #################### diff --git a/arpspoof/rootfs/scripts/00-aaa_dockerfile_backup.sh b/arpspoof/rootfs/scripts/00-aaa_dockerfile_backup.sh index e33f7f063..4f9ed9c51 100644 --- a/arpspoof/rootfs/scripts/00-aaa_dockerfile_backup.sh +++ b/arpspoof/rootfs/scripts/00-aaa_dockerfile_backup.sh @@ -2,18 +2,17 @@ # If dockerfile failed install manually if [ -e "/ENVFILE" ]; then echo "Executing script" - PACKAGES=$(< /ENVFILE) + PACKAGES=$(/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl &>/dev/null || apk add --no-cache curl) && \ - curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ - chmod 777 /automatic_packages.sh && \ - eval /./automatic_packages.sh "$PACKAGES" && \ - rm /automatic_packages.sh - + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/bazarr/CHANGELOG.md b/bazarr/CHANGELOG.md index c559150e2..d1232be22 100644 --- a/bazarr/CHANGELOG.md +++ b/bazarr/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 1.0.1 (20-11-2021) - Update to latest version from linuxserver/docker-bazarr diff --git a/bazarr/Dockerfile b/bazarr/Dockerfile index 6a919c58e..9b09a9e20 100644 --- a/bazarr/Dockerfile +++ b/bazarr/Dockerfile @@ -1,29 +1,14 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="jq \ - curl \ - cifs-utils \ - keyutils \ - samba \ - samba-client" -RUN \ - ############################### - # Install apps test both dist # - ############################### - apk add --no-cache ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio || true +################## +# 2 Modify Image # +################## RUN \ # Correct config folder @@ -36,10 +21,37 @@ RUN \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser -# copy local files -COPY root/ / +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + curl \ + cifs-utils \ + keyutils \ + samba \ + samba-client" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/bazarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/bazarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/bazarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/bazarr/rootfs/etc/cont-init.d/00-banner.sh b/bazarr/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..54d7d491a --- /dev/null +++ b/bazarr/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/bazarr/rootfs/etc/cont-init.d/00-ha-env b/bazarr/rootfs/etc/cont-init.d/00-ha-env new file mode 100644 index 000000000..3b3e69246 --- /dev/null +++ b/bazarr/rootfs/etc/cont-init.d/00-ha-env @@ -0,0 +1,5 @@ +#!/usr/bin/with-contenv bashio + +for k in $(bashio::jq "${__BASHIO_ADDON_CONFIG}" 'keys | .[]'); do + printf "$(bashio::config $k)" > /var/run/s6/container_environment/$k +done \ No newline at end of file diff --git a/bazarr/rootfs/etc/cont-init.d/20-folders b/bazarr/rootfs/etc/cont-init.d/20-folders new file mode 100644 index 000000000..73e1f22de --- /dev/null +++ b/bazarr/rootfs/etc/cont-init.d/20-folders @@ -0,0 +1,19 @@ +#!/usr/bin/with-contenv bash + +if [ ! -d /share/storage/movies ]; then + echo "Creating /share/storage/movies" + mkdir -p /share/storage/movies + chown -R abc:abc /share/storage/movies +fi + +if [ ! -d /share/downloads ]; then + echo "Creating /share/downloads" + mkdir -p /share/downloads + chown -R abc:abc /share/downloads +fi + +if [ ! -d /config/bazarr ]; then + echo "Creating /config/bazarr" + mkdir -p /config/bazarr + chown -R abc:abc /config/bazarr +fi diff --git a/bazarr/rootfs/etc/cont-init.d/92-local_mounts.sh b/bazarr/rootfs/etc/cont-init.d/92-local_mounts.sh new file mode 100644 index 000000000..0920d68bd --- /dev/null +++ b/bazarr/rootfs/etc/cont-init.d/92-local_mounts.sh @@ -0,0 +1,32 @@ +#!/usr/bin/with-contenv bashio + +###################### +# MOUNT LOCAL SHARES # +###################### + +# Mount local Share if configured +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + echo "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + + # Mount by device as default + devpath=/dev + + # Mount as label + [ ${disk:0:2} != "sd" ] && devpath=/dev/disk/by-label + + # Creates dir + mkdir -p /mnt/$disk + chown -R $(id -u):$(id -g) /mnt/$disk + # Legacy mounting : mount to share if still exists (avoid breaking changes) + [ -d /share/$disk ] && mount $devpath/$disk /share/$disk || true + # Mount + mount $devpath/$disk /mnt/$disk && bashio::log.info "Success! $disk mounted to /mnt/$disk" || (bashio::log.fatal "Unable to mount local drives! Please check the name." && rmdir /mnt/$disk) + + done + +fi diff --git a/bazarr/rootfs/etc/cont-init.d/92-smb_mounts.sh b/bazarr/rootfs/etc/cont-init.d/92-smb_mounts.sh new file mode 100644 index 000000000..06410e554 --- /dev/null +++ b/bazarr/rootfs/etc/cont-init.d/92-smb_mounts.sh @@ -0,0 +1,83 @@ +#!/usr/bin/with-contenv bashio + +######################### +# MOUNT SMB SHARES v1.6 # +######################### +if bashio::config.has_value 'networkdisks'; then + + # Define variables + MOREDISKS=$(bashio::config 'networkdisks') + CIFS_USERNAME=$(bashio::config 'cifsusername') + CIFS_PASSWORD=$(bashio::config 'cifspassword') + MOUNTED=false + SMBVERS="" + SECVERS="" + + # Mount CIFS Share if configured and if Protection Mode is active + echo 'Mounting smb share(s)...' + + if bashio::config.has_value 'cifsdomain'; then + DOMAIN=",domain=$(bashio::config 'cifsdomain')" + else + DOMAIN="" + fi + + # Mounting disks + for disk in ${MOREDISKS//,/ }; do # Separate comma separated values + + # Clean name of network share + disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name + diskname=${disk//\\//} #replace \ with / + diskname=${diskname##*/} # Get only last part of the name + + # Data validation + if [[ ! $disk =~ ^.*+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[/]+.*+$ ]]; then + bashio::log.fatal "The structure of your \"networkdisks\" option : \"$disk\" doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2. If you don't use it, you can simply remove the text, this will avoid this error message in the future." + exit 0 + fi + + # Prepare mount point + mkdir -p /mnt/$diskname + chown -R root:root /mnt/$diskname + + #Tries to mount with default options + mount -t cifs -o rw,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname 2>ERRORCODE && MOUNTED=true || MOUNTED=false + + # if Fail test different smb and sec versions + if [ $MOUNTED = false ]; then + for SMBVERS in ",vers=3" ",vers=1.0" ",vers=2.1" ",vers=3.0" ",nodfs" ",uid=0,gid=0,forceuid,forcegid" ",noforceuid,noforcegid" ",${DOMAIN:-WORKGROUP}"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS $disk /mnt/$diskname 2>/dev/null && MOUNTED=true && break || MOUNTED=false + for SECVERS in ",sec=ntlmi" ",sec=ntlmv2" ",sec=ntlmv2i" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=ntlm" ",sec=krb5i" ",sec=krb5" ",iocharset=utf8"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS$SECVERS $disk /mnt/$disk name 2>/dev/null && MOUNTED=true && break 2 && break || MOUNTED=false + done + done + fi + + # Messages + if [ $MOUNTED = true ] && [ "mountpoint -q /mnt/$diskname" ]; then + #Test write permissions + touch /mnt/$diskname/testaze && rm /mnt/$diskname/testaze && + bashio::log.info "... $disk successfully mounted to /mnt/$diskname with options $SMBVERS$SECVERS" || + bashio::log.fatal "Disk is mounted, however unable to write in the shared disk. Please check UID/GID for permissions, and if the share is rw" + + else + # Mounting failed messages + bashio::log.fatal "Error, unable to mount $disk to /mnt/$diskname with username $CIFS_USERNAME, $CIFS_PASSWORD. Please check your remote share path, username, password, domain, try putting 0 in UID and GID" + bashio::log.fatal "Here is some debugging info :" + + # Provide debugging info + smbclient -V &>/dev/null || apt-get install smbclient || apk add --no-cache samba-client + #smbclient $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + smbclient -L $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + + # Error code + bashio::log.fatal "Error read : $(/dev/null || true + rmdir /mnt/$diskname || true + fi + + done +fi diff --git a/bitwarden/CHANGELOG.md b/bitwarden/CHANGELOG.md index 8229c6ecc..e15850430 100644 --- a/bitwarden/CHANGELOG.md +++ b/bitwarden/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 1.23.0 (21-10-2021) - Update to latest version from dani-garcia/bitwarden_rs diff --git a/bitwarden/Dockerfile b/bitwarden/Dockerfile index ac9b4bd37..af6a0f623 100644 --- a/bitwarden/Dockerfile +++ b/bitwarden/Dockerfile @@ -1,20 +1,12 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM=ghcr.io/hassio-addons/debian-base/amd64:4.0.0 -############################################################################### -# Get prebuild containers from Bitwarden RS -############################################################################### ARG BUILD_VERSION ARG BUILD_UPSTREAM="1.23.0" - -# hadolint ignore=DL3006 FROM "vaultwarden/server:${BUILD_UPSTREAM}" as vaultwarden - -############################################################################### -# Build the actual add-on. -############################################################################### -# hadolint ignore=DL3006 FROM ${BUILD_FROM} - -# Set shell SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Get the Bitwarden from official images @@ -22,33 +14,45 @@ COPY --from=vaultwarden /vaultwarden /opt/vaultwarden COPY --from=vaultwarden /Rocket.toml /opt/Rocket.toml COPY --from=vaultwarden /web-vault /opt/web-vault -################ -# Install apps # -################ +################## +# 2 Modify Image # +################## + +################## +# 3 Install apps # +################## + # Add rootfs COPY rootfs/ / # Manual apps ENV PACKAGES="libmariadb-dev-compat \ - libpq5 \ - nginx \ - sqlite3" + libpq5 \ + nginx \ + sqlite3" # Automatic apps & bashio -RUN $(ls /bin/bash &>/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl || apk add --no-cache curl) && \ +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); 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); fi && \ curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ chmod 777 /automatic_packages.sh && \ /automatic_packages.sh "${PACKAGES:-}" && \ rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE -# Entrypoint logic +################ +# 4 Entrypoint # +################ + #RUN chmod 777 /entrypoint.sh #WORKDIR / #ENTRYPOINT [ "/usr/bin/env" ] #CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/bitwarden/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/bitwarden/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh index e33f7f063..4f9ed9c51 100644 --- a/bitwarden/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ b/bitwarden/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -2,18 +2,17 @@ # If dockerfile failed install manually if [ -e "/ENVFILE" ]; then echo "Executing script" - PACKAGES=$(< /ENVFILE) + PACKAGES=$(/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl &>/dev/null || apk add --no-cache curl) && \ - curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ - chmod 777 /automatic_packages.sh && \ - eval /./automatic_packages.sh "$PACKAGES" && \ - rm /automatic_packages.sh - + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/booksonic_air/CHANGELOG.md b/booksonic_air/CHANGELOG.md index 4b13fa069..aba3fdeb2 100644 --- a/booksonic_air/CHANGELOG.md +++ b/booksonic_air/CHANGELOG.md @@ -1,3 +1,8 @@ + +## v2112.1.0-ls38 (12-12-2021) +- Update to latest version from linuxserver/docker-booksonic-air +- New standardized logic for Dockerfile build and packages installation + ## nightly-0.1.0.1024-ls29 (14-11-2021) - Update to latest version from linuxserver/docker-booksonic-air diff --git a/booksonic_air/Dockerfile b/booksonic_air/Dockerfile index 9711c5ce8..d59a90826 100644 --- a/booksonic_air/Dockerfile +++ b/booksonic_air/Dockerfile @@ -1,7 +1,30 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION -FROM linuxserver/booksonic-air:latest -ENV BASHIO_VERSION=0.14.3 +FROM $BUILD_FROM + +################## +# 2 Modify Image # +################## + +ENV BOOKSONIC_AIR_SETTINGS="/data" +RUN \ + # Allow UID and GID setting + sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ + && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ + && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser || true + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps ENV PACKAGES="jq \ curl \ cifs-utils \ @@ -9,38 +32,28 @@ ENV PACKAGES="jq \ samba \ smbclient" -RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################### - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE -################# -# Correct image # -################# -RUN \ - # Allow UID and GID setting - sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ - && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ - && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser || true +################ +# 4 Entrypoint # +################ -# copy local files -COPY root/ / -ENV BOOKSONIC_AIR_SETTINGS="/data" +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/booksonic_air/build.json b/booksonic_air/build.json new file mode 100644 index 000000000..87f02532c --- /dev/null +++ b/booksonic_air/build.json @@ -0,0 +1,8 @@ +{ + "build_from": { + "armhf": "linuxserver/booksonic-air:arm32v7-latest", + "armv7": "linuxserver/booksonic-air:arm32v7-latest", + "aarch64": "linuxserver/booksonic-air:arm64v8-latest", + "amd64": "linuxserver/booksonic-air:amd64-latest" + } +} diff --git a/booksonic_air/config.json b/booksonic_air/config.json index 4d717c228..ccdeafa0e 100644 --- a/booksonic_air/config.json +++ b/booksonic_air/config.json @@ -1,6 +1,11 @@ { "apparmor": true, - "arch": ["aarch64", "amd64", "armv7", "armhf"], + "arch": [ + "aarch64", + "amd64", + "armv7", + "armhf" + ], "boot": "auto", "description": "platform for accessing the audibooks you own wherever you are", "devices": [ @@ -35,7 +40,10 @@ "PUID": "0", "PGID": "0" }, - "map": ["share:rw", "media:rw"], + "map": [ + "share:rw", + "media:rw" + ], "name": "Booksonic-air", "options": { "PUID": 0, @@ -50,7 +58,10 @@ "ports_description": { "4040/tcp": "web interface" }, - "privileged": ["SYS_ADMIN", "DAC_READ_SEARCH"], + "privileged": [ + "SYS_ADMIN", + "DAC_READ_SEARCH" + ], "schema": { "PUID": "int", "PGID": "int", @@ -61,8 +72,8 @@ "cifspassword": "str?" }, "slug": "booksonic-air_nas", - "upstream": "v2009.1.0-ls37", + "upstream": "v2112.1.0-ls38", "url": "https://github.com/alexbelgium/hassio-addons", - "version": "v2009.1.0-ls37", + "version": "v2112.1.0-ls38", "webui": "http://[HOST]:[PORT:4040]" } diff --git a/booksonic_air/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/booksonic_air/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/booksonic_air/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/booksonic_air/rootfs/etc/cont-init.d/00-banner.sh b/booksonic_air/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..54d7d491a --- /dev/null +++ b/booksonic_air/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/booksonic_air/rootfs/etc/cont-init.d/92-local_mounts.sh b/booksonic_air/rootfs/etc/cont-init.d/92-local_mounts.sh new file mode 100644 index 000000000..0920d68bd --- /dev/null +++ b/booksonic_air/rootfs/etc/cont-init.d/92-local_mounts.sh @@ -0,0 +1,32 @@ +#!/usr/bin/with-contenv bashio + +###################### +# MOUNT LOCAL SHARES # +###################### + +# Mount local Share if configured +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + echo "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + + # Mount by device as default + devpath=/dev + + # Mount as label + [ ${disk:0:2} != "sd" ] && devpath=/dev/disk/by-label + + # Creates dir + mkdir -p /mnt/$disk + chown -R $(id -u):$(id -g) /mnt/$disk + # Legacy mounting : mount to share if still exists (avoid breaking changes) + [ -d /share/$disk ] && mount $devpath/$disk /share/$disk || true + # Mount + mount $devpath/$disk /mnt/$disk && bashio::log.info "Success! $disk mounted to /mnt/$disk" || (bashio::log.fatal "Unable to mount local drives! Please check the name." && rmdir /mnt/$disk) + + done + +fi diff --git a/booksonic_air/rootfs/etc/cont-init.d/92-smb_mounts.sh b/booksonic_air/rootfs/etc/cont-init.d/92-smb_mounts.sh new file mode 100644 index 000000000..06410e554 --- /dev/null +++ b/booksonic_air/rootfs/etc/cont-init.d/92-smb_mounts.sh @@ -0,0 +1,83 @@ +#!/usr/bin/with-contenv bashio + +######################### +# MOUNT SMB SHARES v1.6 # +######################### +if bashio::config.has_value 'networkdisks'; then + + # Define variables + MOREDISKS=$(bashio::config 'networkdisks') + CIFS_USERNAME=$(bashio::config 'cifsusername') + CIFS_PASSWORD=$(bashio::config 'cifspassword') + MOUNTED=false + SMBVERS="" + SECVERS="" + + # Mount CIFS Share if configured and if Protection Mode is active + echo 'Mounting smb share(s)...' + + if bashio::config.has_value 'cifsdomain'; then + DOMAIN=",domain=$(bashio::config 'cifsdomain')" + else + DOMAIN="" + fi + + # Mounting disks + for disk in ${MOREDISKS//,/ }; do # Separate comma separated values + + # Clean name of network share + disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name + diskname=${disk//\\//} #replace \ with / + diskname=${diskname##*/} # Get only last part of the name + + # Data validation + if [[ ! $disk =~ ^.*+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[/]+.*+$ ]]; then + bashio::log.fatal "The structure of your \"networkdisks\" option : \"$disk\" doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2. If you don't use it, you can simply remove the text, this will avoid this error message in the future." + exit 0 + fi + + # Prepare mount point + mkdir -p /mnt/$diskname + chown -R root:root /mnt/$diskname + + #Tries to mount with default options + mount -t cifs -o rw,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname 2>ERRORCODE && MOUNTED=true || MOUNTED=false + + # if Fail test different smb and sec versions + if [ $MOUNTED = false ]; then + for SMBVERS in ",vers=3" ",vers=1.0" ",vers=2.1" ",vers=3.0" ",nodfs" ",uid=0,gid=0,forceuid,forcegid" ",noforceuid,noforcegid" ",${DOMAIN:-WORKGROUP}"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS $disk /mnt/$diskname 2>/dev/null && MOUNTED=true && break || MOUNTED=false + for SECVERS in ",sec=ntlmi" ",sec=ntlmv2" ",sec=ntlmv2i" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=ntlm" ",sec=krb5i" ",sec=krb5" ",iocharset=utf8"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS$SECVERS $disk /mnt/$disk name 2>/dev/null && MOUNTED=true && break 2 && break || MOUNTED=false + done + done + fi + + # Messages + if [ $MOUNTED = true ] && [ "mountpoint -q /mnt/$diskname" ]; then + #Test write permissions + touch /mnt/$diskname/testaze && rm /mnt/$diskname/testaze && + bashio::log.info "... $disk successfully mounted to /mnt/$diskname with options $SMBVERS$SECVERS" || + bashio::log.fatal "Disk is mounted, however unable to write in the shared disk. Please check UID/GID for permissions, and if the share is rw" + + else + # Mounting failed messages + bashio::log.fatal "Error, unable to mount $disk to /mnt/$diskname with username $CIFS_USERNAME, $CIFS_PASSWORD. Please check your remote share path, username, password, domain, try putting 0 in UID and GID" + bashio::log.fatal "Here is some debugging info :" + + # Provide debugging info + smbclient -V &>/dev/null || apt-get install smbclient || apk add --no-cache samba-client + #smbclient $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + smbclient -L $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + + # Error code + bashio::log.fatal "Error read : $(/dev/null || true + rmdir /mnt/$diskname || true + fi + + done +fi diff --git a/cloudcommander/CHANGELOG.md b/cloudcommander/CHANGELOG.md index 8eaae1bd0..fa5db3ba7 100644 --- a/cloudcommander/CHANGELOG.md +++ b/cloudcommander/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 15.9.11 (09-12-2021) - Update to latest version from coderaiser/cloudcmd diff --git a/cloudcommander/Dockerfile b/cloudcommander/Dockerfile index ce1f64c5b..313535a05 100644 --- a/cloudcommander/Dockerfile +++ b/cloudcommander/Dockerfile @@ -1,6 +1,22 @@ +################# +# 1 Build Image # +################# + ARG BUILD_VERSION FROM coderaiser/cloudcmd:latest -ENV BASHIO_VERSION=0.14.3 + +################## +# 2 Modify Image # +################## + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps ENV PACKAGES="jq \ cifs-utils \ keyutils \ @@ -8,39 +24,25 @@ ENV PACKAGES="jq \ smbclient \ nginx" -RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - && apt-get clean \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio || true +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE -# Copy root filesystem -COPY rootfs / - -RUN \ - ############### - # Permissions # - ############### - chmod 777 /entrypoint.sh +################ +# 4 Entrypoint # +################ ENTRYPOINT [ "/entrypoint.sh" ] +RUN chmod 777 /entrypoint.sh -VOLUME [ "/data" ] +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/cloudcommander/rootfs/entrypoint.sh b/cloudcommander/rootfs/entrypoint.sh index bf5da4a6c..35ccb7382 100644 --- a/cloudcommander/rootfs/entrypoint.sh +++ b/cloudcommander/rootfs/entrypoint.sh @@ -2,34 +2,6 @@ echo "Starting..." -################################### -# Export all addon options as env # -################################### - -# For all keys in options.json -JSONSOURCE="/data/options.json" - -# Export keys as env variables -echo "All addon options were exported as variables" -mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE}) -for KEYS in ${arr[@]}; do - # export key - VALUE=$(jq .$KEYS ${JSONSOURCE}) - export ${KEYS}=${VALUE//[\"\']/} &>/dev/null -done - -################ -# Set timezone # -################ -if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then - if [ -f /usr/share/zoneinfo/$TZ ]; then - echo "Timezone set from $(cat /etc/timezone) to $TZ" - ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone - else - echo "WARNING : Timezone $TZ is invalid, it will be kept to default value of $(cat /etc/timezone)" - fi -fi - #################### # Starting scripts # #################### diff --git a/cloudcommander/rootfs/scripts/00-aaa_dockerfile_backup.sh b/cloudcommander/rootfs/scripts/00-aaa_dockerfile_backup.sh index 612e26d7e..4f9ed9c51 100644 --- a/cloudcommander/rootfs/scripts/00-aaa_dockerfile_backup.sh +++ b/cloudcommander/rootfs/scripts/00-aaa_dockerfile_backup.sh @@ -1,29 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - + ####################### + # Automatic installer # + ####################### + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/code-server/CHANGELOG.md b/code-server/CHANGELOG.md index a2a2bec9e..9c381e009 100644 --- a/code-server/CHANGELOG.md +++ b/code-server/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation - Allow mounting local drives by label. Just pust the label instead of sda1 for example - Allow mounting of devices up to sdg2 diff --git a/code-server/Dockerfile b/code-server/Dockerfile index e688c934d..6b0e12ed3 100644 --- a/code-server/Dockerfile +++ b/code-server/Dockerfile @@ -1,33 +1,56 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="jq" -# Install bashio -RUN apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio \ - \ +################## +# 2 Modify Image # +################## + +RUN \ # Allow UID and GID setting - && sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ + sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser \ # MOFIFY DATA PATH && sed -i "s|config|data|g" /etc/services.d/code-server/run \ && sed -i "s|config|data|g" /etc/cont-init.d/30-config -VOLUME [ "/data" ] +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/code-server/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/code-server/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/code-server/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/freqtrade/rootfs/etc/cont-init.d/00-banner.sh b/code-server/rootfs/etc/cont-init.d/00-banner.sh similarity index 94% rename from freqtrade/rootfs/etc/cont-init.d/00-banner.sh rename to code-server/rootfs/etc/cont-init.d/00-banner.sh index 31de08e93..0ac294e9a 100644 --- a/freqtrade/rootfs/etc/cont-init.d/00-banner.sh +++ b/code-server/rootfs/etc/cont-init.d/00-banner.sh @@ -1,7 +1,4 @@ #!/usr/bin/with-contenv bashio - -bashio::log.warning "Minimal (advised) system requirements: 2GB RAM, 1GB disk space, 2vCPU" - # ============================================================================== # Displays a simple add-on banner on startup # ============================================================================== diff --git a/code-server/rootfs/etc/cont-init.d/92-local_mounts.sh b/code-server/rootfs/etc/cont-init.d/92-local_mounts.sh new file mode 100644 index 000000000..0920d68bd --- /dev/null +++ b/code-server/rootfs/etc/cont-init.d/92-local_mounts.sh @@ -0,0 +1,32 @@ +#!/usr/bin/with-contenv bashio + +###################### +# MOUNT LOCAL SHARES # +###################### + +# Mount local Share if configured +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + echo "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + + # Mount by device as default + devpath=/dev + + # Mount as label + [ ${disk:0:2} != "sd" ] && devpath=/dev/disk/by-label + + # Creates dir + mkdir -p /mnt/$disk + chown -R $(id -u):$(id -g) /mnt/$disk + # Legacy mounting : mount to share if still exists (avoid breaking changes) + [ -d /share/$disk ] && mount $devpath/$disk /share/$disk || true + # Mount + mount $devpath/$disk /mnt/$disk && bashio::log.info "Success! $disk mounted to /mnt/$disk" || (bashio::log.fatal "Unable to mount local drives! Please check the name." && rmdir /mnt/$disk) + + done + +fi diff --git a/code-server/rootfs/etc/cont-init.d/92-smb_mounts.sh b/code-server/rootfs/etc/cont-init.d/92-smb_mounts.sh new file mode 100644 index 000000000..06410e554 --- /dev/null +++ b/code-server/rootfs/etc/cont-init.d/92-smb_mounts.sh @@ -0,0 +1,83 @@ +#!/usr/bin/with-contenv bashio + +######################### +# MOUNT SMB SHARES v1.6 # +######################### +if bashio::config.has_value 'networkdisks'; then + + # Define variables + MOREDISKS=$(bashio::config 'networkdisks') + CIFS_USERNAME=$(bashio::config 'cifsusername') + CIFS_PASSWORD=$(bashio::config 'cifspassword') + MOUNTED=false + SMBVERS="" + SECVERS="" + + # Mount CIFS Share if configured and if Protection Mode is active + echo 'Mounting smb share(s)...' + + if bashio::config.has_value 'cifsdomain'; then + DOMAIN=",domain=$(bashio::config 'cifsdomain')" + else + DOMAIN="" + fi + + # Mounting disks + for disk in ${MOREDISKS//,/ }; do # Separate comma separated values + + # Clean name of network share + disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name + diskname=${disk//\\//} #replace \ with / + diskname=${diskname##*/} # Get only last part of the name + + # Data validation + if [[ ! $disk =~ ^.*+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[/]+.*+$ ]]; then + bashio::log.fatal "The structure of your \"networkdisks\" option : \"$disk\" doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2. If you don't use it, you can simply remove the text, this will avoid this error message in the future." + exit 0 + fi + + # Prepare mount point + mkdir -p /mnt/$diskname + chown -R root:root /mnt/$diskname + + #Tries to mount with default options + mount -t cifs -o rw,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname 2>ERRORCODE && MOUNTED=true || MOUNTED=false + + # if Fail test different smb and sec versions + if [ $MOUNTED = false ]; then + for SMBVERS in ",vers=3" ",vers=1.0" ",vers=2.1" ",vers=3.0" ",nodfs" ",uid=0,gid=0,forceuid,forcegid" ",noforceuid,noforcegid" ",${DOMAIN:-WORKGROUP}"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS $disk /mnt/$diskname 2>/dev/null && MOUNTED=true && break || MOUNTED=false + for SECVERS in ",sec=ntlmi" ",sec=ntlmv2" ",sec=ntlmv2i" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=ntlm" ",sec=krb5i" ",sec=krb5" ",iocharset=utf8"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS$SECVERS $disk /mnt/$disk name 2>/dev/null && MOUNTED=true && break 2 && break || MOUNTED=false + done + done + fi + + # Messages + if [ $MOUNTED = true ] && [ "mountpoint -q /mnt/$diskname" ]; then + #Test write permissions + touch /mnt/$diskname/testaze && rm /mnt/$diskname/testaze && + bashio::log.info "... $disk successfully mounted to /mnt/$diskname with options $SMBVERS$SECVERS" || + bashio::log.fatal "Disk is mounted, however unable to write in the shared disk. Please check UID/GID for permissions, and if the share is rw" + + else + # Mounting failed messages + bashio::log.fatal "Error, unable to mount $disk to /mnt/$diskname with username $CIFS_USERNAME, $CIFS_PASSWORD. Please check your remote share path, username, password, domain, try putting 0 in UID and GID" + bashio::log.fatal "Here is some debugging info :" + + # Provide debugging info + smbclient -V &>/dev/null || apt-get install smbclient || apk add --no-cache samba-client + #smbclient $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + smbclient -L $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + + # Error code + bashio::log.fatal "Error read : $(/dev/null || true + rmdir /mnt/$diskname || true + fi + + done +fi diff --git a/doublecommander/CHANGELOG.md b/doublecommander/CHANGELOG.md index b12ec0716..e283b7b0a 100644 --- a/doublecommander/CHANGELOG.md +++ b/doublecommander/CHANGELOG.md @@ -1,4 +1,6 @@ +- New standardized logic for Dockerfile build and packages installation - Improve SMB mount code to v1.5 ; accepts several network disks separated by commas (//123.12.12.12/share,//123.12.12.12/hello) that are mount to /mnt/$sharename +- Removed full_access and host_network ## 0.8.2-1-ls54 (19-05-2021) diff --git a/doublecommander/Dockerfile b/doublecommander/Dockerfile index de36ad326..52a2f7bd3 100644 --- a/doublecommander/Dockerfile +++ b/doublecommander/Dockerfile @@ -1,39 +1,57 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 + +################## +# 2 Modify Image # +################## + +RUN \ + # Allow UID and GID setting + sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ + && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ + && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser \ + # MOFIFY DATA PATH + && sed -i "s|config|data|g" /defaults/autostart + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps ENV PACKAGES="jq \ samba \ smbclient" -# Install bashio -RUN apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio \ - \ - # Allow UID and GID setting - && sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ - && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ - && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE -# copy local files -COPY rootfs/ / +################ +# 4 Entrypoint # +################ -# MOFIFY DATA PATH -RUN sed -i "s|config|data|g" /defaults/autostart +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] -VOLUME [ "/data" ] +############ +# 5 Labels # +########### -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/doublecommander/config.json b/doublecommander/config.json index 574e41e2c..818ff83ee 100644 --- a/doublecommander/config.json +++ b/doublecommander/config.json @@ -7,8 +7,6 @@ "PUID": "0", "PGID": "0" }, - "full_access": true, - "host_network": true, "map": ["backup:rw", "config:rw", "share:rw", "media:rw", "ssl"], "name": "Double commander", "options": { diff --git a/doublecommander/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/doublecommander/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh index 612e26d7e..4f9ed9c51 100644 --- a/doublecommander/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ b/doublecommander/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -1,29 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - + ####################### + # Automatic installer # + ####################### + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/elasticsearch/CHANGELOG.md b/elasticsearch/CHANGELOG.md index 68dde260e..4a854f7ea 100644 --- a/elasticsearch/CHANGELOG.md +++ b/elasticsearch/CHANGELOG.md @@ -1 +1,2 @@ +- New standardized logic for Dockerfile build and packages installation - Initial build diff --git a/elasticsearch/Dockerfile b/elasticsearch/Dockerfile index d81ec0132..c055b89c2 100644 --- a/elasticsearch/Dockerfile +++ b/elasticsearch/Dockerfile @@ -1,21 +1,39 @@ +################# +# 1 Build Image # +################# + ARG BUILD_UPSTREAM="7.14.2" FROM elasticsearch:$BUILD_UPSTREAM +################## +# 2 Modify Image # +################## + # Data persistence RUN sed -i '5a echo "Data location moved. Please wait while elasticsearch starts..."' /usr/local/bin/docker-entrypoint.sh \ -&& sed -i '5a chown -R $(id -u):$(id -g) $HOME' /usr/local/bin/docker-entrypoint.sh \ -&& sed -i '5a done' /usr/local/bin/docker-entrypoint.sh \ -&& sed -i '5a ln -s $NEWHOME/$files /usr/share/elasticsearch || true' /usr/local/bin/docker-entrypoint.sh \ -&& sed -i '5a rm -r /usr/share/elasticsearch/$files || true' /usr/local/bin/docker-entrypoint.sh \ -&& sed -i '5a cp -rn /usr/share/elasticsearch/$files $NEWHOME || true' /usr/local/bin/docker-entrypoint.sh \ -&& sed -i '5a for files in "data" "config"; do' /usr/local/bin/docker-entrypoint.sh \ -&& sed -i '5a mkdir -p $NEWHOME' /usr/local/bin/docker-entrypoint.sh \ -&& sed -i '5a NEWHOME="/data"' /usr/local/bin/docker-entrypoint.sh + && sed -i '5a chown -R $(id -u):$(id -g) $HOME' /usr/local/bin/docker-entrypoint.sh \ + && sed -i '5a done' /usr/local/bin/docker-entrypoint.sh \ + && sed -i '5a ln -s $NEWHOME/$files /usr/share/elasticsearch || true' /usr/local/bin/docker-entrypoint.sh \ + && sed -i '5a rm -r /usr/share/elasticsearch/$files || true' /usr/local/bin/docker-entrypoint.sh \ + && sed -i '5a cp -rn /usr/share/elasticsearch/$files $NEWHOME || true' /usr/local/bin/docker-entrypoint.sh \ + && sed -i '5a for files in "data" "config"; do' /usr/local/bin/docker-entrypoint.sh \ + && sed -i '5a mkdir -p $NEWHOME' /usr/local/bin/docker-entrypoint.sh \ + && sed -i '5a NEWHOME="/data"' /usr/local/bin/docker-entrypoint.sh \ + # Install plugins + && /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch ingest-attachment -# Install plugins -RUN /usr/share/elasticsearch/bin/elasticsearch-plugin install --batch ingest-attachment +################## +# 3 Install apps # +################## + +################ +# 4 Entrypoint # +################ + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/elasticsearch/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/elasticsearch/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/elasticsearch/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/elasticsearch/rootfs/etc/cont-init.d/00-banner.sh b/elasticsearch/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/elasticsearch/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/emby/CHANGELOG.md b/emby/CHANGELOG.md index 133d6b9f0..f4799200a 100644 --- a/emby/CHANGELOG.md +++ b/emby/CHANGELOG.md @@ -1,4 +1,8 @@ +## 4.7.0.19 (14-12-2021) +- Update to latest version from linuxserver/docker-emby +- New standardized logic for Dockerfile build and packages installation + ## 4.7.0.18 (20-11-2021) - Update to latest version from linuxserver/docker-emby diff --git a/emby/Dockerfile b/emby/Dockerfile index eb999b6f9..f4e4d2212 100644 --- a/emby/Dockerfile +++ b/emby/Dockerfile @@ -1,18 +1,18 @@ -############### -# Build Image # -############### +################# +# 1 Build Image # +################# ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -################ -# Modify Image # -################ +################## +# 2 Modify Image # +################## # Set shell SHELL ["/bin/bash", "-o", "pipefail", "-c"] - + RUN \ # Allow UID and GID setting sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ @@ -24,9 +24,9 @@ RUN \ && sed -i "s|/config|/emby|g" /etc/services.d/emby/run \ && sed -i "s|/config|/emby|g" /etc/cont-init.d/30-config -################ -# Install apps # -################ +################## +# 3 Install apps # +################## # Copy local files COPY rootfs/ / @@ -34,20 +34,20 @@ COPY rootfs/ / ENV PACKAGES="" # Automatic apps & bashio -RUN $(ls /bin/bash &>/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl || apk add --no-cache curl) && \ +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); 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); fi && \ curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ chmod 777 /automatic_packages.sh && \ /automatic_packages.sh "${PACKAGES:-}" && \ rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE -############## -# Entrypoint # -############## +################ +# 4 Entrypoint # +################ -########## -# Labels # -########## +############ +# 5 Labels # +############ ARG BUILD_ARCH ARG BUILD_DATE diff --git a/emby/config.json b/emby/config.json index 1b12a521f..387161af2 100644 --- a/emby/config.json +++ b/emby/config.json @@ -1,6 +1,11 @@ { "apparmor": true, - "arch": ["aarch64", "amd64", "armv7", "armhf"], + "arch": [ + "aarch64", + "amd64", + "armv7", + "armhf" + ], "backup_exclude": [ "*/cache/", "*/logs/", @@ -47,7 +52,12 @@ "/dev/nvme1", "/dev/nvme2" ], - "map": ["config:rw", "share:rw", "media:rw", "ssl:rw"], + "map": [ + "config:rw", + "share:rw", + "media:rw", + "ssl:rw" + ], "name": "Emby NAS", "options": { "PUID": 0, @@ -66,7 +76,10 @@ "7359/udp": "udp server discover (optional)", "1900/udp": "dlna (optional)" }, - "privileged": ["SYS_ADMIN", "DAC_READ_SEARCH"], + "privileged": [ + "SYS_ADMIN", + "DAC_READ_SEARCH" + ], "schema": { "PUID": "int", "PGID": "int", @@ -81,9 +94,9 @@ }, "slug": "emby_nas", "startup": "services", - "upstream": "4.7.0.18", + "upstream": "4.7.0.19", "url": "https://github.com/alexbelgium/hassio-addons", - "version": "4.7.0.18", + "version": "4.7.0.19", "video": true, "webui": "http://[HOST]:[PORT:8096]" } diff --git a/emby/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/emby/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh index e33f7f063..4f9ed9c51 100644 --- a/emby/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ b/emby/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -2,18 +2,17 @@ # If dockerfile failed install manually if [ -e "/ENVFILE" ]; then echo "Executing script" - PACKAGES=$(< /ENVFILE) + PACKAGES=$(/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl &>/dev/null || apk add --no-cache curl) && \ - curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ - chmod 777 /automatic_packages.sh && \ - eval /./automatic_packages.sh "$PACKAGES" && \ - rm /automatic_packages.sh - + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/enedisgateway2mqtt/CHANGELOG.md b/enedisgateway2mqtt/CHANGELOG.md index 7e58b69e4..ebcb0ed9a 100644 --- a/enedisgateway2mqtt/CHANGELOG.md +++ b/enedisgateway2mqtt/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 0.7.7 (25-11-2021) - Update to latest version from m4dm4rtig4n/enedisgateway2mqtt diff --git a/enedisgateway2mqtt/Dockerfile b/enedisgateway2mqtt/Dockerfile index 972b8a860..5978c4eb9 100644 --- a/enedisgateway2mqtt/Dockerfile +++ b/enedisgateway2mqtt/Dockerfile @@ -1,43 +1,48 @@ +################# +# 1 Build Image # +################# + ARG BUILD_UPSTREAM="0.7.7" FROM m4dm4rtig4n/enedisgateway2mqtt:$BUILD_UPSTREAM -# Base system -ENV BASHIO_VERSION=0.14.3 + +################## +# 2 Modify Image # +################## + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps ENV PACKAGES="jq \ curl \ yamllint" -# Copy root filesystem -COPY rootfs / -VOLUME [ "/config" ] +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE -RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - && apt-get clean \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio || true - -#RUN ln -snf /usr/share/zoneinfo/Europe/Paris /etc/localtime +################ +# 4 Entrypoint # +################ RUN chmod 777 /entrypoint.sh ENTRYPOINT [ "/usr/bin/env" ] CMD ["/entrypoint.sh"] VOLUME [ "/data" ] -### LABELS +############ +# 5 Labels # +############ + ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/enedisgateway2mqtt/rootfs/scripts/00-aaa_dockerfile_backup.sh b/enedisgateway2mqtt/rootfs/scripts/00-aaa_dockerfile_backup.sh index 612e26d7e..4f9ed9c51 100644 --- a/enedisgateway2mqtt/rootfs/scripts/00-aaa_dockerfile_backup.sh +++ b/enedisgateway2mqtt/rootfs/scripts/00-aaa_dockerfile_backup.sh @@ -1,29 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - + ####################### + # Automatic installer # + ####################### + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/enedisgateway2mqtt_dev/CHANGELOG.md b/enedisgateway2mqtt_dev/CHANGELOG.md index 60dfdf4ce..ad16f6e6b 100644 --- a/enedisgateway2mqtt_dev/CHANGELOG.md +++ b/enedisgateway2mqtt_dev/CHANGELOG.md @@ -1,4 +1,5 @@ -- Always aligned with dev versions +- New standardized logic for Dockerfile build and packages installation +- Always aligned with dev versions ## 0.7.8-dev (23-11-2021) - Update to latest version from m4dm4rtig4n/enedisgateway2mqtt diff --git a/enedisgateway2mqtt_dev/Dockerfile b/enedisgateway2mqtt_dev/Dockerfile index 681525dee..9c45b66d8 100644 --- a/enedisgateway2mqtt_dev/Dockerfile +++ b/enedisgateway2mqtt_dev/Dockerfile @@ -1,43 +1,48 @@ +################# +# 1 Build Image # +################# + ARG BUILD_UPSTREAM="0.7.8-dev" FROM m4dm4rtig4n/enedisgateway2mqtt:$BUILD_UPSTREAM -# Base system -ENV BASHIO_VERSION=0.14.3 -# Copy root filesystem -COPY rootfs / -VOLUME [ "/config" ] +################## +# 2 Modify Image # +################## -RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y \ - jq \ +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ curl \ - yamllint \ - && apt-get clean \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio || true + yamllint" -#RUN ln -snf /usr/share/zoneinfo/Europe/Paris /etc/localtime +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ RUN chmod 777 /entrypoint.sh ENTRYPOINT [ "/usr/bin/env" ] CMD ["/entrypoint.sh"] VOLUME [ "/data" ] -### LABELS +############ +# 5 Labels # +############ + ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/enedisgateway2mqtt_dev/rootfs/scripts/00-aaa_dockerfile_backup.sh b/enedisgateway2mqtt_dev/rootfs/scripts/00-aaa_dockerfile_backup.sh index 3b3b8653f..4f9ed9c51 100644 --- a/enedisgateway2mqtt_dev/rootfs/scripts/00-aaa_dockerfile_backup.sh +++ b/enedisgateway2mqtt_dev/rootfs/scripts/00-aaa_dockerfile_backup.sh @@ -1,30 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/filebrowser/CHANGELOG.md b/filebrowser/CHANGELOG.md index cc3ce0608..055941e08 100644 --- a/filebrowser/CHANGELOG.md +++ b/filebrowser/CHANGELOG.md @@ -1,4 +1,5 @@ - Mount ssl in write +- New standardized logic for Dockerfile build and packages installation - Mount nvme drives ## 2.19.0 (25-11-2021) diff --git a/filebrowser/Dockerfile b/filebrowser/Dockerfile index 5cc2047d4..c534ff683 100644 --- a/filebrowser/Dockerfile +++ b/filebrowser/Dockerfile @@ -1,8 +1,27 @@ +################# +# 1 Build Image # +################# + ARG BUILD_VERSION ARG BUILD_UPSTREAM="2.19.0" FROM hurlenko/filebrowser:v${BUILD_UPSTREAM} -ENV BASHIO_VERSION=0.14.3 +################## +# 2 Modify Image # +################## + +RUN \ + # Correct upstream image folders links + mkdir -p -m 777 /config/filebrowser + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps ENV PACKAGES="curl \ jq \ bash \ @@ -13,30 +32,17 @@ ENV PACKAGES="curl \ bind-tools \ nginx" -RUN \ - ################ - # Install apps # - ################ - apk add --no-cache ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio || true +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE -RUN \ - ######################################## - # Correct upstream image folders links # - ######################################## - mkdir -p -m 777 /config/filebrowser - -# Copy root filesystem -COPY rootfs / +################ +# 4 Entrypoint # +################ VOLUME [ "/data" ] WORKDIR / @@ -44,8 +50,10 @@ RUN chmod 777 /entrypoint.sh ENTRYPOINT [ "/usr/bin/env" ] CMD [ "/entrypoint.sh" ] +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/filebrowser/rootfs/entrypoint.sh b/filebrowser/rootfs/entrypoint.sh index bf5da4a6c..35ccb7382 100644 --- a/filebrowser/rootfs/entrypoint.sh +++ b/filebrowser/rootfs/entrypoint.sh @@ -2,34 +2,6 @@ echo "Starting..." -################################### -# Export all addon options as env # -################################### - -# For all keys in options.json -JSONSOURCE="/data/options.json" - -# Export keys as env variables -echo "All addon options were exported as variables" -mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE}) -for KEYS in ${arr[@]}; do - # export key - VALUE=$(jq .$KEYS ${JSONSOURCE}) - export ${KEYS}=${VALUE//[\"\']/} &>/dev/null -done - -################ -# Set timezone # -################ -if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then - if [ -f /usr/share/zoneinfo/$TZ ]; then - echo "Timezone set from $(cat /etc/timezone) to $TZ" - ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone - else - echo "WARNING : Timezone $TZ is invalid, it will be kept to default value of $(cat /etc/timezone)" - fi -fi - #################### # Starting scripts # #################### diff --git a/filebrowser/rootfs/scripts/00-aaa_dockerfile_backup.sh b/filebrowser/rootfs/scripts/00-aaa_dockerfile_backup.sh index 612e26d7e..4f9ed9c51 100644 --- a/filebrowser/rootfs/scripts/00-aaa_dockerfile_backup.sh +++ b/filebrowser/rootfs/scripts/00-aaa_dockerfile_backup.sh @@ -1,29 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - + ####################### + # Automatic installer # + ####################### + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/flexget/CHANGELOG.md b/flexget/CHANGELOG.md index 33f9cca8c..38bbbc8cd 100644 --- a/flexget/CHANGELOG.md +++ b/flexget/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 3.2.4 (08-12-2021) - Update to latest version from flexget/flexget diff --git a/flexget/Dockerfile b/flexget/Dockerfile index ba057483f..f8c07b5f8 100644 --- a/flexget/Dockerfile +++ b/flexget/Dockerfile @@ -1,32 +1,18 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM wiserain/flexget:latest -ENV BASHIO_VERSION=0.14.3 + +################## +# 2 Modify Image # +################## RUN \ - ################## - # Install apps # - ################## - apk add --no-cache \ - jq \ - curl \ - cifs-utils \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio \ - \ - ############### - # Adapt image # - ############### # Allow UID and GID setting - && sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ + sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser \ \ @@ -40,9 +26,40 @@ RUN \ && sed -i 's/# set FG_WEBUI_PASSWD/if bashio::config.has_value "WebuiPass"; then FG_WEBUI_PASSWD=$(bashio::config "WebuiPass"); fi/g' /etc/cont-init.d/20-config \ && sed -i 's/# install custom plugins/if bashio::config.has_value "FG_PLUGINS"; then FG_PLUGINS=$(bashio::config "FG_PLUGINS"); fi/g' /etc/cont-init.d/20-config -VOLUME [ "/data" ] +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + curl \ + cifs-utils" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE] + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/flexget/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/flexget/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/flexget/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/flexget/rootfs/etc/cont-init.d/00-banner.sh b/flexget/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/flexget/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/flexget/rootfs/etc/cont-init.d/00-folders.sh b/flexget/rootfs/etc/cont-init.d/00-folders.sh new file mode 100644 index 000000000..6e8bb9452 --- /dev/null +++ b/flexget/rootfs/etc/cont-init.d/00-folders.sh @@ -0,0 +1,3 @@ +#!/usr/bin/with-contenv bashio + +mkdir -p /config/flexget diff --git a/freqtrade/CHANGELOG.md b/freqtrade/CHANGELOG.md deleted file mode 100644 index a9215ab42..000000000 --- a/freqtrade/CHANGELOG.md +++ /dev/null @@ -1,7 +0,0 @@ - -## 2021.11 (27-11-2021) -- Update to latest version from freqtrade/freqtrade - -## 2021.10 (29-10-2021) -- Update to latest version from freqtrade/freqtrade -- Initial release diff --git a/freqtrade/Dockerfile b/freqtrade/Dockerfile deleted file mode 100644 index e34085015..000000000 --- a/freqtrade/Dockerfile +++ /dev/null @@ -1,68 +0,0 @@ -ARG BUILD_FROM -ARG BUILD_VERSION -FROM freqtradeorg/freqtrade:latest -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="jq git" - -USER root -COPY rootfs / - -RUN \ - ################ - # Install apps # - ################ - apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################### - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio || true - -VOLUME [ "/data" ] -WORKDIR / -RUN chmod 777 /entrypoint.sh -ENTRYPOINT [ "/bin/bash" ] -CMD [ "/entrypoint.sh" ] - -# use /data instead of /config for hass.io environment -# && sed -i "s|/config|/share/freqtrade|g" /etc/services.d/freqtrade/run \ -#&& sed -i "s|/config|/share/freqtrade|g" /etc/cont-init.d/50-config \ -#&& sed -i "s|/share/freqtrade/nginx|/config/nginx|g" /etc/cont-init.d/50-config \ -#\ -# Allow UID and GID setting -#&& sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ -#&& sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ -#&& sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser - -### 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} diff --git a/freqtrade/Readme.md b/freqtrade/Readme.md deleted file mode 100644 index b0202726a..000000000 --- a/freqtrade/Readme.md +++ /dev/null @@ -1 +0,0 @@ -EXPERIMENTAL - DO NOT USE diff --git a/freqtrade/apparmor.txt b/freqtrade/apparmor.txt deleted file mode 100644 index 9efe66c73..000000000 --- a/freqtrade/apparmor.txt +++ /dev/null @@ -1,48 +0,0 @@ -#include - -profile freqtrade_addon flags=(attach_disconnected,mediate_deleted) { - #include - - capability, - file, - mount, - umount, - remount, - - capability setgid, - capability setuid, - capability sys_admin, - capability dac_read_search, - # capability dac_override, - # capability sys_rawio, - -# S6-Overlay - /bin/** ix, - /usr/bin/** ix, - /usr/lib/bashio/** ix, - /etc/s6/** rix, - /run/s6/** rix, - /etc/services.d/** rwix, - /etc/cont-init.d/** rwix, - /etc/cont-finish.d/** rwix, - /init rix, - /var/run/** mrwkl, - /var/run/ mrwkl, - /dev/i2c-1 mrwkl, - # Files required - /dev/sda1 mrwkl, - /dev/sdb1 mrwkl, - /dev/mmcblk0p1 mrwkl, - /dev/* mrwkl, - /tmp/** mrkwl, - - # Data access - /data/** rw, - - # suppress ptrace denials when using 'docker ps' or using 'ps' inside a container - ptrace (trace,read) peer=docker-default, - - # docker daemon confinement requires explict allow rule for signal - signal (receive) set=(kill,term) peer=/usr/bin/docker, - -} diff --git a/freqtrade/config.json b/freqtrade/config.json deleted file mode 100644 index eb39790ac..000000000 --- a/freqtrade/config.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "apparmor": true, - "arch": [ - "aarch64", - "amd64", - "armv7", - "armhf" - ], - "boot": "auto", - "description": "Simple High frequency trading bot for crypto currencies ", - "devices": [], - "environment": {}, - "map": [ - "share:rw" - ], - "name": "freqtrade web server - DO NOT USE", - "options": {}, - "ports": { - "8080/tcp": 9711 - }, - "ports_description": { - "8080/tcp": "web interface" - }, - "privileged": [], - "schema": {}, - "slug": "freqtrade", - "upstream": "2021.11", - "url": "https://github.com/alexbelgium/hassio-addons", - "version": "2021.11", - "webui": "http://[HOST]:[PORT:80]" -} diff --git a/freqtrade/icon.png b/freqtrade/icon.png deleted file mode 100644 index 4bcfb3139..000000000 Binary files a/freqtrade/icon.png and /dev/null differ diff --git a/freqtrade/logo.png b/freqtrade/logo.png deleted file mode 100644 index 4bcfb3139..000000000 Binary files a/freqtrade/logo.png and /dev/null differ diff --git a/freqtrade/rootfs/entrypoint.sh b/freqtrade/rootfs/entrypoint.sh deleted file mode 100644 index 165ffe1bb..000000000 --- a/freqtrade/rootfs/entrypoint.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -echo "Starting" - -if [ ! -f /data/config.json ]; then - echo "building userdir" - freqtrade create-userdir --userdir /data - echo "building initial config" - freqtrade new-config --config /data/config.json -fi - -sleep 5000000 - -echo "Starting app" -freqtrade trade --logfile /data/logs/freqtrade.log --db-url sqlite://///data/tradesv3.sqlite --config /data/config.json --strategy SampleStrategy diff --git a/freqtrade/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/freqtrade/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh deleted file mode 100644 index 612e26d7e..000000000 --- a/freqtrade/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -# If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" - ( - ################ - # Install apps # - ################ - PACKAGES="${PACKAGES:="curl"}" - - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} 2>/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - - ) >/dev/null - -fi diff --git a/gazpar2mqtt/CHANGELOG.md b/gazpar2mqtt/CHANGELOG.md index b42a9154c..680183a93 100644 --- a/gazpar2mqtt/CHANGELOG.md +++ b/gazpar2mqtt/CHANGELOG.md @@ -1,4 +1,11 @@ +## 0.6.1 (14-12-2021) +- Update to latest version from yukulehe/gazpar2mqtt +- New standardized logic for Dockerfile build and packages installation + +## 0.6 (11-12-2021) +- Update to latest version from yukulehe/gazpar2mqtt + ## 0.5.3 (07-12-2021) - Update to latest version from yukulehe/gazpar2mqtt - mqtt autodiscover added diff --git a/gazpar2mqtt/Dockerfile b/gazpar2mqtt/Dockerfile index e753dcc94..9f0ed1c6a 100644 --- a/gazpar2mqtt/Dockerfile +++ b/gazpar2mqtt/Dockerfile @@ -1,40 +1,38 @@ +################# +# 1 Build Image # +################# + FROM yukulehe/gazpar2mqtt:latest -# Base system -ENV BASHIO_VERSION=0.14.3 +################## +# 2 Modify Image # +################## + ENV TZ=Europe/Paris + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps ENV PACKAGES="jq \ curl \ yamllint" -# Copy root filesystem -COPY rootfs / +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE -RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - && apt-get clean \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio || true - -RUN \ - ################# - # Copy template # - ################# - mkdir -p /share/gazpar2mqtt \ - && cp -n /templates/config.yaml /share/gazpar2mqtt/ +################ +# 4 Entrypoint # +################ RUN chmod 777 /entrypoint.sh ENTRYPOINT [ "/usr/bin/env" ] @@ -42,7 +40,10 @@ CMD ["/entrypoint.sh"] VOLUME [ "/data" ] VOLUME [ "/share" ] -### LABELS +############ +# 5 Labels # +############ + ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/gazpar2mqtt/config.json b/gazpar2mqtt/config.json index af5a8da13..d521a7b64 100644 --- a/gazpar2mqtt/config.json +++ b/gazpar2mqtt/config.json @@ -25,7 +25,7 @@ "mqtt:want" ], "slug": "gazpar2mqtt", - "upstream": "0.5.3", + "upstream": "0.6.1", "url": "https://github.com/alexbelgium/hassio-addons", - "version": "0.5.3" + "version": "0.6.1" } diff --git a/gazpar2mqtt/rootfs/entrypoint.sh b/gazpar2mqtt/rootfs/entrypoint.sh index bf5da4a6c..35ccb7382 100644 --- a/gazpar2mqtt/rootfs/entrypoint.sh +++ b/gazpar2mqtt/rootfs/entrypoint.sh @@ -2,34 +2,6 @@ echo "Starting..." -################################### -# Export all addon options as env # -################################### - -# For all keys in options.json -JSONSOURCE="/data/options.json" - -# Export keys as env variables -echo "All addon options were exported as variables" -mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE}) -for KEYS in ${arr[@]}; do - # export key - VALUE=$(jq .$KEYS ${JSONSOURCE}) - export ${KEYS}=${VALUE//[\"\']/} &>/dev/null -done - -################ -# Set timezone # -################ -if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then - if [ -f /usr/share/zoneinfo/$TZ ]; then - echo "Timezone set from $(cat /etc/timezone) to $TZ" - ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone - else - echo "WARNING : Timezone $TZ is invalid, it will be kept to default value of $(cat /etc/timezone)" - fi -fi - #################### # Starting scripts # #################### diff --git a/gazpar2mqtt/rootfs/scripts/00-aaa_dockerfile_backup.sh b/gazpar2mqtt/rootfs/scripts/00-aaa_dockerfile_backup.sh index 612e26d7e..4f9ed9c51 100644 --- a/gazpar2mqtt/rootfs/scripts/00-aaa_dockerfile_backup.sh +++ b/gazpar2mqtt/rootfs/scripts/00-aaa_dockerfile_backup.sh @@ -1,29 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - + ####################### + # Automatic installer # + ####################### + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/gazpar2mqtt/rootfs/scripts/92-config_yaml.sh b/gazpar2mqtt/rootfs/scripts/92-config_yaml.sh index 8d94b196e..e37468ce2 100644 --- a/gazpar2mqtt/rootfs/scripts/92-config_yaml.sh +++ b/gazpar2mqtt/rootfs/scripts/92-config_yaml.sh @@ -83,7 +83,8 @@ while IFS= read -r line; do if [[ $line =~ ^.+[=].+$ ]]; then export $line # Export the variable - sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || sed -i "1a export $line" /scripts/*run* + sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || true + sed -i "1a export $line" /scripts/*run* 2>/dev/null || true # Show in log bashio::log.blue "$line" else diff --git a/grav/CHANGELOG.md b/grav/CHANGELOG.md index 568208d3b..310f4da25 100644 --- a/grav/CHANGELOG.md +++ b/grav/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 1.7.25 (17-11-2021) - Update to latest version from linuxserver/docker-grav diff --git a/grav/Dockerfile b/grav/Dockerfile index 0c9794c1b..4c41ea309 100644 --- a/grav/Dockerfile +++ b/grav/Dockerfile @@ -1,33 +1,18 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="jq \ - curl \ - cifs-utils \ - keyutils \ - samba \ - samba-client" + +################## +# 2 Modify Image # +################## RUN \ - ################ - # Install apps # - ################ - apk add --no-cache ${PACKAGES} \ - \ - ################### - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio \ - \ # use /data instead of /config for hass.io environment - # && sed -i "s|/config|/share/grav|g" /etc/services.d/grav/run \ - && sed -i "s|/config|/share/grav|g" /etc/cont-init.d/50-config \ + sed -i "s|/config|/share/grav|g" /etc/cont-init.d/50-config \ && sed -i "s|/share/grav/nginx|/config/nginx|g" /etc/cont-init.d/50-config \ \ # Allow UID and GID setting @@ -35,10 +20,37 @@ RUN \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser -# copy local files -COPY root/ / +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + curl \ + cifs-utils \ + keyutils \ + samba \ + samba-client" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/grav/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/grav/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/grav/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/grav/rootfs/etc/cont-init.d/00-banner.sh b/grav/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/grav/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/freqtrade/rootfs/etc/cont-init.d/00-ha-env b/grav/rootfs/etc/cont-init.d/00-ha-env similarity index 100% rename from freqtrade/rootfs/etc/cont-init.d/00-ha-env rename to grav/rootfs/etc/cont-init.d/00-ha-env diff --git a/grav/rootfs/etc/cont-init.d/20-folders b/grav/rootfs/etc/cont-init.d/20-folders new file mode 100644 index 000000000..5cf2a6207 --- /dev/null +++ b/grav/rootfs/etc/cont-init.d/20-folders @@ -0,0 +1,12 @@ +#!/usr/bin/with-contenv bashio + +echo "Updating folders..." + +for FOLDERS in "/share/grav" "/app/grav-admin/backup" +do + echo "... $FOLDERS" + mkdir -p $FOLDERS + chown -R abc:abc $FOLDERS +done + +bashio::log.warning "If error of missing folder when loading addon, just restart" diff --git a/inadyn/Dockerfile b/inadyn/Dockerfile index a7006b9c4..1af09a4f2 100644 --- a/inadyn/Dockerfile +++ b/inadyn/Dockerfile @@ -1,39 +1,44 @@ +################# +# 1 Build Image # +################# + FROM troglobit/inadyn:latest -# Base system -ENV BASHIO_VERSION=0.14.3 -ARG BUILD_ARCH +################## +# 2 Modify Image # +################## +ARG BUILD_ARCH ENV LANG='C.UTF-8'\ TERM='xterm-256color'\ GOPATH='/opt/go' + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps ENV PACKAGES="curl \ jq \ bash \ - xz build-base libressl-dev ca-certificates npm" + build-base libressl-dev ca-certificates npm" -RUN \ - ################ - # Install apps # - ################ - apk add --no-cache ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio \ - \ - #################### - # Install mustache # - #################### - && apk add --no-cache \ +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +# Install mustache +RUN apk add --no-cache \ go \ npm \ + xz \ # && npm install mustache-cli --global && apk upgrade --no-cache &&\ apk add --no-cache --virtual .build-deps\ @@ -43,19 +48,22 @@ RUN \ go get -u github.com/quantumew/mustache-cli &&\ cp $GOPATH/bin/* /usr/bin/ && \ rm -rf $GOPATH /var/cache/apk/* /tmp/src &&\ - apk del .build-deps xz build-base + apk del .build-deps xz build-base || true -# Copy root filesystem -COPY rootfs / +################ +# 4 Entrypoint # +################ WORKDIR / -RUN chmod 777 /run.sh +RUN chmod 777 /entrypoint.sh ENTRYPOINT [ "/usr/bin/env" ] -CMD [ "/run.sh" ] - +CMD [ "/entrypoint.sh" ] VOLUME [ "/data" ] -### LABELS +############ +# 5 Labels # +############ + ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/inadyn/rootfs/entrypoint.sh b/inadyn/rootfs/entrypoint.sh new file mode 100644 index 000000000..35ccb7382 --- /dev/null +++ b/inadyn/rootfs/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "Starting..." + +#################### +# Starting scripts # +#################### + +cd / +for SCRIPTS in scripts/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown $(id -u):$(id -g) $SCRIPTS + chmod a+x $SCRIPTS + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' $SCRIPTS || true + ./$SCRIPTS || echo "$SCRIPTS: exiting $?" +done diff --git a/inadyn/rootfs/scripts/00-aaa_dockerfile_backup.sh b/inadyn/rootfs/scripts/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/inadyn/rootfs/scripts/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/inadyn/rootfs/scripts/00-banner.sh b/inadyn/rootfs/scripts/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/inadyn/rootfs/scripts/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/inadyn/rootfs/scripts/99-run.sh b/inadyn/rootfs/scripts/99-run.sh new file mode 100644 index 000000000..b47224a94 --- /dev/null +++ b/inadyn/rootfs/scripts/99-run.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bashio + +################# +# Create config # +################# +mustache-cli /data/options.json /templates/inadyn.mustache >/etc/inadyn.conf + +############## +# Launch App # +############## +/usr/sbin/inadyn --foreground diff --git a/jackett/CHANGELOG.md b/jackett/CHANGELOG.md index 8ab10f811..80da4bfd4 100644 --- a/jackett/CHANGELOG.md +++ b/jackett/CHANGELOG.md @@ -1,4 +1,15 @@ +## 0.20.162 (14-12-2021) +- Update to latest version from linuxserver/docker-jackett + +## 0.20.159 (12-12-2021) +- Update to latest version from linuxserver/docker-jackett +- New standardized logic for Dockerfile build and packages installation +- Removed full access (not used anymore) + +## 0.20.147 (11-12-2021) +- Update to latest version from linuxserver/docker-jackett + ## 0.20.141 (10-12-2021) - Update to latest version from linuxserver/docker-jackett diff --git a/jackett/Dockerfile b/jackett/Dockerfile index c0ae0d69d..cc50cfaca 100644 --- a/jackett/Dockerfile +++ b/jackett/Dockerfile @@ -1,28 +1,14 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="curl" -RUN \ - ################ - # Install apps # - ################ - apk add --no-cache ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && curl -J -L -o /tmp/bashio.tar.gz \ - "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - && mkdir /tmp/bashio \ - && tar zxvf \ - /tmp/bashio.tar.gz \ - --strip 1 -C /tmp/bashio \ - \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -fr /tmp/bashio.tar.gz || true +################## +# 2 Modify Image # +################## # use /data instead of /config for hass.io environment RUN sed -i "s|/config|/config/jackett|g" /etc/services.d/jackett/run \ @@ -33,10 +19,32 @@ RUN sed -i "s|/config|/config/jackett|g" /etc/services.d/jackett/run \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser -# copy local files -COPY root/ / +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="curl" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/jackett/config.json b/jackett/config.json index 836568bb3..6dfe65e73 100644 --- a/jackett/config.json +++ b/jackett/config.json @@ -11,7 +11,6 @@ "PUID": "0", "PGID": "0" }, - "full_access": true, "map": [ "config:rw", "share:rw", @@ -44,8 +43,8 @@ }, "slug": "jackett_nas", "startup": "services", - "upstream": "0.20.141", + "upstream": "0.20.162", "url": "https://github.com/alexbelgium/hassio-addons", - "version": "0.20.141", + "version": "0.20.162", "webui": "http://[HOST]:[PORT:9117]" } diff --git a/jackett/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/jackett/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/jackett/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/jackett/rootfs/etc/cont-init.d/00-banner.sh b/jackett/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/jackett/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/jackett/rootfs/etc/cont-init.d/00-ha-env b/jackett/rootfs/etc/cont-init.d/00-ha-env new file mode 100644 index 000000000..3b3e69246 --- /dev/null +++ b/jackett/rootfs/etc/cont-init.d/00-ha-env @@ -0,0 +1,5 @@ +#!/usr/bin/with-contenv bashio + +for k in $(bashio::jq "${__BASHIO_ADDON_CONFIG}" 'keys | .[]'); do + printf "$(bashio::config $k)" > /var/run/s6/container_environment/$k +done \ No newline at end of file diff --git a/jackett/rootfs/etc/cont-init.d/20-folders b/jackett/rootfs/etc/cont-init.d/20-folders new file mode 100644 index 000000000..0a8112e46 --- /dev/null +++ b/jackett/rootfs/etc/cont-init.d/20-folders @@ -0,0 +1,19 @@ +#!/usr/bin/with-contenv bash + +if [ ! -d /share/storage/movies ]; then + echo "Creating /share/storage/movies" + mkdir -p /share/storage/movies + chown -R abc:abc /share/storage/movies +fi + +if [ ! -d /share/downloads ]; then + echo "Creating /share/downloads" + mkdir -p /share/downloads + chown -R abc:abc /share/downloads +fi + +if [ ! -d /config/jackett ]; then + echo "Creating /config/jackett" + mkdir -p /config/jackett + chown -R abc:abc /config/jackett +fi diff --git a/jackett/rootfs/etc/cont-init.d/92-local_mounts.sh b/jackett/rootfs/etc/cont-init.d/92-local_mounts.sh new file mode 100644 index 000000000..0920d68bd --- /dev/null +++ b/jackett/rootfs/etc/cont-init.d/92-local_mounts.sh @@ -0,0 +1,32 @@ +#!/usr/bin/with-contenv bashio + +###################### +# MOUNT LOCAL SHARES # +###################### + +# Mount local Share if configured +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + echo "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + + # Mount by device as default + devpath=/dev + + # Mount as label + [ ${disk:0:2} != "sd" ] && devpath=/dev/disk/by-label + + # Creates dir + mkdir -p /mnt/$disk + chown -R $(id -u):$(id -g) /mnt/$disk + # Legacy mounting : mount to share if still exists (avoid breaking changes) + [ -d /share/$disk ] && mount $devpath/$disk /share/$disk || true + # Mount + mount $devpath/$disk /mnt/$disk && bashio::log.info "Success! $disk mounted to /mnt/$disk" || (bashio::log.fatal "Unable to mount local drives! Please check the name." && rmdir /mnt/$disk) + + done + +fi diff --git a/jackett/rootfs/etc/cont-init.d/92-smb_mounts.sh b/jackett/rootfs/etc/cont-init.d/92-smb_mounts.sh new file mode 100644 index 000000000..06410e554 --- /dev/null +++ b/jackett/rootfs/etc/cont-init.d/92-smb_mounts.sh @@ -0,0 +1,83 @@ +#!/usr/bin/with-contenv bashio + +######################### +# MOUNT SMB SHARES v1.6 # +######################### +if bashio::config.has_value 'networkdisks'; then + + # Define variables + MOREDISKS=$(bashio::config 'networkdisks') + CIFS_USERNAME=$(bashio::config 'cifsusername') + CIFS_PASSWORD=$(bashio::config 'cifspassword') + MOUNTED=false + SMBVERS="" + SECVERS="" + + # Mount CIFS Share if configured and if Protection Mode is active + echo 'Mounting smb share(s)...' + + if bashio::config.has_value 'cifsdomain'; then + DOMAIN=",domain=$(bashio::config 'cifsdomain')" + else + DOMAIN="" + fi + + # Mounting disks + for disk in ${MOREDISKS//,/ }; do # Separate comma separated values + + # Clean name of network share + disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name + diskname=${disk//\\//} #replace \ with / + diskname=${diskname##*/} # Get only last part of the name + + # Data validation + if [[ ! $disk =~ ^.*+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[/]+.*+$ ]]; then + bashio::log.fatal "The structure of your \"networkdisks\" option : \"$disk\" doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2. If you don't use it, you can simply remove the text, this will avoid this error message in the future." + exit 0 + fi + + # Prepare mount point + mkdir -p /mnt/$diskname + chown -R root:root /mnt/$diskname + + #Tries to mount with default options + mount -t cifs -o rw,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname 2>ERRORCODE && MOUNTED=true || MOUNTED=false + + # if Fail test different smb and sec versions + if [ $MOUNTED = false ]; then + for SMBVERS in ",vers=3" ",vers=1.0" ",vers=2.1" ",vers=3.0" ",nodfs" ",uid=0,gid=0,forceuid,forcegid" ",noforceuid,noforcegid" ",${DOMAIN:-WORKGROUP}"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS $disk /mnt/$diskname 2>/dev/null && MOUNTED=true && break || MOUNTED=false + for SECVERS in ",sec=ntlmi" ",sec=ntlmv2" ",sec=ntlmv2i" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=ntlm" ",sec=krb5i" ",sec=krb5" ",iocharset=utf8"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS$SECVERS $disk /mnt/$disk name 2>/dev/null && MOUNTED=true && break 2 && break || MOUNTED=false + done + done + fi + + # Messages + if [ $MOUNTED = true ] && [ "mountpoint -q /mnt/$diskname" ]; then + #Test write permissions + touch /mnt/$diskname/testaze && rm /mnt/$diskname/testaze && + bashio::log.info "... $disk successfully mounted to /mnt/$diskname with options $SMBVERS$SECVERS" || + bashio::log.fatal "Disk is mounted, however unable to write in the shared disk. Please check UID/GID for permissions, and if the share is rw" + + else + # Mounting failed messages + bashio::log.fatal "Error, unable to mount $disk to /mnt/$diskname with username $CIFS_USERNAME, $CIFS_PASSWORD. Please check your remote share path, username, password, domain, try putting 0 in UID and GID" + bashio::log.fatal "Here is some debugging info :" + + # Provide debugging info + smbclient -V &>/dev/null || apt-get install smbclient || apk add --no-cache samba-client + #smbclient $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + smbclient -L $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + + # Error code + bashio::log.fatal "Error read : $(/dev/null || true + rmdir /mnt/$diskname || true + fi + + done +fi diff --git a/jellyfin/CHANGELOG.md b/jellyfin/CHANGELOG.md index afc167a9b..64152c0a9 100644 --- a/jellyfin/CHANGELOG.md +++ b/jellyfin/CHANGELOG.md @@ -1,4 +1,5 @@ -- Add local mount (see readmeà +- New standardized logic for Dockerfile build and packages installation +- Add local mount (see readme) - Added watchdog feature - Allow mounting of devices up to sdg2 - Improve SMB mount code to v1.5 ; accepts several network disks separated by commas (//123.12.12.12/share,//123.12.12.12/hello) that are mount to /mnt/$sharename diff --git a/jellyfin/Dockerfile b/jellyfin/Dockerfile index 7da6d7bb5..16ff1fd27 100644 --- a/jellyfin/Dockerfile +++ b/jellyfin/Dockerfile @@ -1,40 +1,59 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -# Set shell -SHELL ["/bin/bash", "-o", "pipefail", "-c"] -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="jq \ - samba \ - cifs-utils \ - smbclient" +################## +# 2 Modify Image # +################## -RUN apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio \ - \ - # Allow UID and GID setting - && sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ +# Allow UID and GID setting +RUN \ + sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser \ && sed -i "s|/config|/config/jellyfin|g" /etc/services.d/jellyfin/run \ && sed -i "s|/config|/config/jellyfin|g" /etc/cont-init.d/10-adduser \ && sed -i "s|/config|/config/jellyfin|g" /etc/cont-init.d/30-config -# copy local files -COPY root/ / +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + samba \ + cifs-utils \ + smbclient" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/jellyfin/config.json b/jellyfin/config.json index fd34137cb..595885638 100644 --- a/jellyfin/config.json +++ b/jellyfin/config.json @@ -78,6 +78,5 @@ "url": "https://github.com/alexbelgium/hassio-addons", "version": "10.7.7-1-ls130-4", "video": true, - "watchdog": "http://[HOST]:[PORT:8096]", "webui": "http://[HOST]:[PORT:8096]" } diff --git a/jellyfin/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/jellyfin/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/jellyfin/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/jellyfin/rootfs/etc/cont-init.d/00-banner.sh b/jellyfin/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/jellyfin/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/jellyfin/rootfs/etc/cont-init.d/00-ha-env b/jellyfin/rootfs/etc/cont-init.d/00-ha-env new file mode 100644 index 000000000..3b3e69246 --- /dev/null +++ b/jellyfin/rootfs/etc/cont-init.d/00-ha-env @@ -0,0 +1,5 @@ +#!/usr/bin/with-contenv bashio + +for k in $(bashio::jq "${__BASHIO_ADDON_CONFIG}" 'keys | .[]'); do + printf "$(bashio::config $k)" > /var/run/s6/container_environment/$k +done \ No newline at end of file diff --git a/jellyfin/rootfs/etc/cont-init.d/20-folders b/jellyfin/rootfs/etc/cont-init.d/20-folders new file mode 100644 index 000000000..9015351ab --- /dev/null +++ b/jellyfin/rootfs/etc/cont-init.d/20-folders @@ -0,0 +1,82 @@ +#!/usr/bin/with-contenv bash + +if [ ! -d /jellyfin ]; then + echo "Creating /jellyfin" + mkdir -p /jellyfin + chown -R abc:abc /jellyfin +fi + +if [ ! -d /share/storage/tv ]; then + echo "Creating /share/storage/tv" + mkdir -p /share/storage/tv + chown -R abc:abc /share/storage/tv +fi + +if [ ! -d /share/storage/movies ]; then + echo "Creating /share/storage/movies" + mkdir -p /share/storage/movies + chown -R abc:abc /share/storage/movies +fi + +if [ ! -d /share/jellyfin ]; then + echo "Creating /share/jellyfin" + mkdir -p /share/jellyfin + chown -R abc:abc /share/jellyfin +fi + +if [ ! -d /config/jellyfin ]; then + echo "Creating /config/jellyfin" + mkdir -p /config/jellyfin + chown -R abc:abc /config/jellyfin +fi + +# links + +if [ ! -d /jellyfin/cache ]; then + echo "Creating link for /jellyfin/cache" + mkdir -p /share/jellyfin/cache + chown -R abc:abc /share/jellyfin/cache + ln -s /share/jellyfin/cache /jellyfin/cache +fi + +if [ ! -d /jellyfin/config ]; then + echo "Creating link for /jellyfin/config" + mkdir -p /config/jellyfin + chown -R abc:abc /config/jellyfin + ln -s /config/jellyfin /jellyfin/config +fi + +if [ ! -d /jellyfin/data ]; then + echo "Creating link for /jellyfin/data" + mkdir -p /share/jellyfin/data + chown -R abc:abc /share/jellyfin/data + ln -s /share/jellyfin/data /jellyfin/data +fi + +if [ ! -d /jellyfin/logs ]; then + echo "Creating link for /jellyfin/logs" + mkdir -p /share/jellyfin/logs + chown -R abc:abc /share/jellyfin/logs + ln -s /share/jellyfin/logs /jellyfin/logs +fi + +if [ ! -d /jellyfin/metadata ]; then + echo "Creating link for /jellyfin/metadata" + mkdir -p /share/jellyfin/metadata + chown -R abc:abc /share/jellyfin/metadata + ln -s /share/jellyfin/metadata /jellyfin/metadata +fi + +if [ ! -d /jellyfin/plugins ]; then + echo "Creating link for /jellyfin/plugins" + mkdir -p /share/jellyfin/plugins + chown -R abc:abc /share/jellyfin/plugins + ln -s /share/jellyfin/plugins /jellyfin/plugins +fi + +if [ ! -d /jellyfin/root ]; then + echo "Creating link for /jellyfin/root" + mkdir -p /share/jellyfin/root + chown -R abc:abc /share/jellyfin/root + ln -s /share/jellyfin/root /jellyfin/root +fi diff --git a/jellyfin/rootfs/etc/cont-init.d/92-local_mounts.sh b/jellyfin/rootfs/etc/cont-init.d/92-local_mounts.sh new file mode 100644 index 000000000..0920d68bd --- /dev/null +++ b/jellyfin/rootfs/etc/cont-init.d/92-local_mounts.sh @@ -0,0 +1,32 @@ +#!/usr/bin/with-contenv bashio + +###################### +# MOUNT LOCAL SHARES # +###################### + +# Mount local Share if configured +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + echo "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + + # Mount by device as default + devpath=/dev + + # Mount as label + [ ${disk:0:2} != "sd" ] && devpath=/dev/disk/by-label + + # Creates dir + mkdir -p /mnt/$disk + chown -R $(id -u):$(id -g) /mnt/$disk + # Legacy mounting : mount to share if still exists (avoid breaking changes) + [ -d /share/$disk ] && mount $devpath/$disk /share/$disk || true + # Mount + mount $devpath/$disk /mnt/$disk && bashio::log.info "Success! $disk mounted to /mnt/$disk" || (bashio::log.fatal "Unable to mount local drives! Please check the name." && rmdir /mnt/$disk) + + done + +fi diff --git a/jellyfin/rootfs/etc/cont-init.d/92-smb_mounts.sh b/jellyfin/rootfs/etc/cont-init.d/92-smb_mounts.sh new file mode 100644 index 000000000..06410e554 --- /dev/null +++ b/jellyfin/rootfs/etc/cont-init.d/92-smb_mounts.sh @@ -0,0 +1,83 @@ +#!/usr/bin/with-contenv bashio + +######################### +# MOUNT SMB SHARES v1.6 # +######################### +if bashio::config.has_value 'networkdisks'; then + + # Define variables + MOREDISKS=$(bashio::config 'networkdisks') + CIFS_USERNAME=$(bashio::config 'cifsusername') + CIFS_PASSWORD=$(bashio::config 'cifspassword') + MOUNTED=false + SMBVERS="" + SECVERS="" + + # Mount CIFS Share if configured and if Protection Mode is active + echo 'Mounting smb share(s)...' + + if bashio::config.has_value 'cifsdomain'; then + DOMAIN=",domain=$(bashio::config 'cifsdomain')" + else + DOMAIN="" + fi + + # Mounting disks + for disk in ${MOREDISKS//,/ }; do # Separate comma separated values + + # Clean name of network share + disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name + diskname=${disk//\\//} #replace \ with / + diskname=${diskname##*/} # Get only last part of the name + + # Data validation + if [[ ! $disk =~ ^.*+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[/]+.*+$ ]]; then + bashio::log.fatal "The structure of your \"networkdisks\" option : \"$disk\" doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2. If you don't use it, you can simply remove the text, this will avoid this error message in the future." + exit 0 + fi + + # Prepare mount point + mkdir -p /mnt/$diskname + chown -R root:root /mnt/$diskname + + #Tries to mount with default options + mount -t cifs -o rw,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname 2>ERRORCODE && MOUNTED=true || MOUNTED=false + + # if Fail test different smb and sec versions + if [ $MOUNTED = false ]; then + for SMBVERS in ",vers=3" ",vers=1.0" ",vers=2.1" ",vers=3.0" ",nodfs" ",uid=0,gid=0,forceuid,forcegid" ",noforceuid,noforcegid" ",${DOMAIN:-WORKGROUP}"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS $disk /mnt/$diskname 2>/dev/null && MOUNTED=true && break || MOUNTED=false + for SECVERS in ",sec=ntlmi" ",sec=ntlmv2" ",sec=ntlmv2i" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=ntlm" ",sec=krb5i" ",sec=krb5" ",iocharset=utf8"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS$SECVERS $disk /mnt/$disk name 2>/dev/null && MOUNTED=true && break 2 && break || MOUNTED=false + done + done + fi + + # Messages + if [ $MOUNTED = true ] && [ "mountpoint -q /mnt/$diskname" ]; then + #Test write permissions + touch /mnt/$diskname/testaze && rm /mnt/$diskname/testaze && + bashio::log.info "... $disk successfully mounted to /mnt/$diskname with options $SMBVERS$SECVERS" || + bashio::log.fatal "Disk is mounted, however unable to write in the shared disk. Please check UID/GID for permissions, and if the share is rw" + + else + # Mounting failed messages + bashio::log.fatal "Error, unable to mount $disk to /mnt/$diskname with username $CIFS_USERNAME, $CIFS_PASSWORD. Please check your remote share path, username, password, domain, try putting 0 in UID and GID" + bashio::log.fatal "Here is some debugging info :" + + # Provide debugging info + smbclient -V &>/dev/null || apt-get install smbclient || apk add --no-cache samba-client + #smbclient $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + smbclient -L $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + + # Error code + bashio::log.fatal "Error read : $(/dev/null || true + rmdir /mnt/$diskname || true + fi + + done +fi diff --git a/joal/CHANGELOG.md b/joal/CHANGELOG.md index 3daef1abf..3b5132019 100644 --- a/joal/CHANGELOG.md +++ b/joal/CHANGELOG.md @@ -1,4 +1,8 @@ +## 2.1.28 (14-12-2021) +- Update to latest version from anthonyraymond/joal +- New standardized logic for Dockerfile build and packages installation + ## 2.1.27 (17-11-2021) - Update to latest version from anthonyraymond/joal diff --git a/joal/Dockerfile b/joal/Dockerfile index 0c87dc1d1..ad4fc7a06 100644 --- a/joal/Dockerfile +++ b/joal/Dockerfile @@ -1,58 +1,60 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM -ARG BUILD_UPSTREAM="2.1.27" +ARG BUILD_UPSTREAM="2.1.28" FROM anthonyraymond/joal:$BUILD_UPSTREAM -# Set shell +################## +# 2 Modify Image # +################## + +#Install Joal +RUN \ + 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); fi && \ + curl -s -S -J -L -o /tmp/joal.tar.gz $(curl -s https://api.github.com/repos/anthonyraymond/joal/releases/latest | grep -o "http.*joal.tar.gz") >/dev/null &&\ + mkdir -p /data/joal &&\ + tar zxvf /tmp/joal.tar.gz -C /data/joal >/dev/null &&\ + chown -R $(id -u):$(id -g) /data/joal &&\ + rm /data/joal/jack-of* || true + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + nginx" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + SHELL ["/bin/bash", "-o", "pipefail", "-c"] ARG BUILD_VERSION -ARG BUILD_UPSTREAM="2.1.27" -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="wget \ - jq \ - nginx" +ARG BUILD_UPSTREAM="2.1.28" -RUN \ - #Install bashio - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && curl -J -L -o /tmp/bashio.tar.gz \ - "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - && mkdir /tmp/bashio \ - && tar zxvf \ - /tmp/bashio.tar.gz \ - --strip 1 -C /tmp/bashio \ - \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio || true +################ +# 4 Entrypoint # +################ -RUN \ - #Install Joal - wget -O /tmp/joal.tar.gz "https://github.com/anthonyraymond/joal/releases/download/$BUILD_UPSTREAM/joal.tar.gz" \ - && mkdir -p /data/joal \ - && tar zxvf /tmp/joal.tar.gz -C /data/joal \ - && rm /data/joal/jack-of* \ - #Clean - && rm -fr \ - /tmp/* \ - /var/{cache,log}/* \ - /var/lib/apt/lists/* - -VOLUME [ "/data" ] - -# copy local files -COPY rootfs/ / -#WORKDIR / RUN chmod 777 /entrypoint.sh ENTRYPOINT [ "/usr/bin/env" ] CMD [ "/entrypoint.sh" ] -### LABELS +############ +# 5 Labels # +############ + ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/joal/config.json b/joal/config.json index 212425de1..b658db43a 100644 --- a/joal/config.json +++ b/joal/config.json @@ -38,8 +38,8 @@ }, "slug": "joal", "startup": "services", - "upstream": "2.1.27", + "upstream": "2.1.28", "url": "https://github.com/alexbelgium/hassio-addons", - "version": "2.1.27", + "version": "2.1.28", "webui": "http://[HOST]:[PORT:8081]/joal/ui?ui_credentials=%7B%22host%22%3A%22[HOST]%22%2C%22port%22%3A%22[PORT:8081]%22%2C%22pathPrefix%22%3A%22joal%22%2C%22secretToken%22%3A%22lrMY24Byhx%22%7D" } diff --git a/joal/rootfs/entrypoint.sh b/joal/rootfs/entrypoint.sh index bf5da4a6c..35ccb7382 100644 --- a/joal/rootfs/entrypoint.sh +++ b/joal/rootfs/entrypoint.sh @@ -2,34 +2,6 @@ echo "Starting..." -################################### -# Export all addon options as env # -################################### - -# For all keys in options.json -JSONSOURCE="/data/options.json" - -# Export keys as env variables -echo "All addon options were exported as variables" -mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE}) -for KEYS in ${arr[@]}; do - # export key - VALUE=$(jq .$KEYS ${JSONSOURCE}) - export ${KEYS}=${VALUE//[\"\']/} &>/dev/null -done - -################ -# Set timezone # -################ -if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then - if [ -f /usr/share/zoneinfo/$TZ ]; then - echo "Timezone set from $(cat /etc/timezone) to $TZ" - ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone - else - echo "WARNING : Timezone $TZ is invalid, it will be kept to default value of $(cat /etc/timezone)" - fi -fi - #################### # Starting scripts # #################### diff --git a/joal/rootfs/scripts/00-aaa_dockerfile_backup.sh b/joal/rootfs/scripts/00-aaa_dockerfile_backup.sh index 612e26d7e..4f9ed9c51 100644 --- a/joal/rootfs/scripts/00-aaa_dockerfile_backup.sh +++ b/joal/rootfs/scripts/00-aaa_dockerfile_backup.sh @@ -1,29 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - + ####################### + # Automatic installer # + ####################### + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/joal/rootfs/scripts/99-run.sh b/joal/rootfs/scripts/99-run.sh index eec197a1f..f0a83cde8 100644 --- a/joal/rootfs/scripts/99-run.sh +++ b/joal/rootfs/scripts/99-run.sh @@ -18,10 +18,8 @@ fi if [ $VERBOSE = true ]; then curl -J -L -o /tmp/joal.tar.gz $(curl -s https://api.github.com/repos/anthonyraymond/joal/releases/latest | grep -o "http.*joal.tar.gz") - #wget -O /tmp/joal.tar.gz "https://github.com/anthonyraymond/joal/releases/download/$UPSTREAM/joal.tar.gz" else curl -s -S -J -L -o /tmp/joal.tar.gz $(curl -s https://api.github.com/repos/anthonyraymond/joal/releases/latest | grep -o "http.*joal.tar.gz") >/dev/null - #wget -q -O /tmp/joal.tar.gz "https://github.com/anthonyraymond/joal/releases/download/$UPSTREAM/joal.tar.gz" fi mkdir -p /data/joal tar zxvf /tmp/joal.tar.gz -C /data/joal >/dev/null diff --git a/joplin/CHANGELOG.md b/joplin/CHANGELOG.md index 5d407ad82..6a2a73ec6 100644 --- a/joplin/CHANGELOG.md +++ b/joplin/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 2.5.12 (08-11-2021) - Update to latest version from laurent22/joplin diff --git a/joplin/Dockerfile b/joplin/Dockerfile index f283dba1b..1e764b53e 100644 --- a/joplin/Dockerfile +++ b/joplin/Dockerfile @@ -1,36 +1,50 @@ +################# +# 1 Build Image # +################# ARG BUILD_FROM ARG BUILD_VERSION FROM florider89/joplin-server:master -ENV BASHIO_VERSION=0.14.3 +################## +# 2 Modify Image # +################## + +USER root + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps ENV PACKAGES="jq \ curl" -USER root -RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio -COPY rootfs / -RUN chmod +x /run.sh +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +RUN chmod 777 /entrypoint.sh ENTRYPOINT [ "/usr/bin/env" ] -CMD [ "/run.sh" ] +CMD [ "/entrypoint.sh" ] +#WORKDIR / +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/joplin/rootfs/entrypoint.sh b/joplin/rootfs/entrypoint.sh new file mode 100644 index 000000000..35ccb7382 --- /dev/null +++ b/joplin/rootfs/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "Starting..." + +#################### +# Starting scripts # +#################### + +cd / +for SCRIPTS in scripts/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown $(id -u):$(id -g) $SCRIPTS + chmod a+x $SCRIPTS + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' $SCRIPTS || true + ./$SCRIPTS || echo "$SCRIPTS: exiting $?" +done diff --git a/joplin/rootfs/scripts/00-aaa_dockerfile_backup.sh b/joplin/rootfs/scripts/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/joplin/rootfs/scripts/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/joplin/rootfs/scripts/00-banner.sh b/joplin/rootfs/scripts/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/joplin/rootfs/scripts/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/joplin/rootfs/scripts/99-run.sh b/joplin/rootfs/scripts/99-run.sh new file mode 100644 index 000000000..66ec58d27 --- /dev/null +++ b/joplin/rootfs/scripts/99-run.sh @@ -0,0 +1,67 @@ +#!/usr/bin/env bashio + +bashio::log.warning "Warning - minimum configuration recommended : 2 cpu cores and 4 GB of memory. Otherwise the system will become unresponsive and crash." + +########## +# BANNER # +########## + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums or the Discord chat.' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi + +############## +# LAUNCH APP # +############## + +# Configure app +bashio::config.has_value 'DB_CLIENT' && export DB_CLIENT=$(bashio::config 'DB_CLIENT') && bashio::log.info 'Database client set' +bashio::config.has_value 'POSTGRES_PASSWORD' && export POSTGRES_PASSWORD=$(bashio::config 'POSTGRES_PASSWORD') && bashio::log.info 'Postgrep Password set' +bashio::config.has_value 'POSTGRES_DATABASE' && export POSTGRES_DATABASE=$(bashio::config 'POSTGRES_DATABASE') && bashio::log.info 'Postgrep Database set' +bashio::config.has_value 'POSTGRES_USER' && export POSTGRES_USER=$(bashio::config 'POSTGRES_USER') && bashio::log.info 'Postgrep User set' +bashio::config.has_value 'POSTGRES_PORT' && export POSTGRES_PORT=$(bashio::config 'POSTGRES_PORT') && bashio::log.info 'Postgrep Port set' +bashio::config.has_value 'POSTGRES_HOST' && export POSTGRES_HOST=$(bashio::config 'POSTGRES_HOST') && bashio::log.info 'Postgrep Host set' +bashio::config.has_value 'MAILER_HOST' && export MAILER_HOST=$(bashio::config 'MAILER_HOST') && bashio::log.info 'Mailer Host set' +bashio::config.has_value 'MAILER_PORT' && export MAILER_PORT=$(bashio::config 'MAILER_PORT') && bashio::log.info 'Mailer Port set' +bashio::config.has_value 'MAILER_SECURE' && export MAILER_SECURE=$(bashio::config 'MAILER_SECURE') && bashio::log.info 'Mailer Secure set' +bashio::config.has_value 'MAILER_AUTH_USER' && export MAILER_AUTH_USER=$(bashio::config 'MAILER_AUTH_USER') && bashio::log.info 'Mailer User set' +bashio::config.has_value 'MAILER_AUTH_PASSWORD' && export MAILER_AUTH_PASSWORD=$(bashio::config 'MAILER_AUTH_PASSWORD') && bashio::log.info 'Mailer Password set' +bashio::config.has_value 'MAILER_NOREPLY_NAME' && export MAILER_NOREPLY_NAME=$(bashio::config 'MAILER_NOREPLY_NAME') && bashio::log.info 'Mailer Noreply Name set' +bashio::config.has_value 'MAILER_NOREPLY_EMAIL' && export MAILER_NOREPLY_EMAIL=$(bashio::config 'MAILER_NOREPLY_EMAIL') && bashio::log.info 'Mailer Noreply Email set' +bashio::config.has_value 'MAILER_ENABLED' && export MAILER_ENABLED=$(bashio::config 'MAILER_ENABLED') && bashio::log.info 'Mailer Enabled set' +export APP_BASE_URL=$(bashio::config 'APP_BASE_URL') + +bashio::log.info 'Starting Joplin. Initial user is "admin@localhost" with password "admin"' + +npm --prefix packages/server start diff --git a/lidarr/CHANGELOG.md b/lidarr/CHANGELOG.md index c9ac238b9..aab139117 100644 --- a/lidarr/CHANGELOG.md +++ b/lidarr/CHANGELOG.md @@ -1,3 +1,5 @@ +- New standardized logic for Dockerfile build and packages installation - Allow mounting local drives by label. Just pust the label instead of sda1 for example + - Initial release - Improve SMB mount code to v1.5 ; accepts several network disks separated by commas (//123.12.12.12/share,//123.12.12.12/hello) that are mount to /mnt/$sharename diff --git a/lidarr/Dockerfile b/lidarr/Dockerfile index 93500f1fc..6b10ff969 100644 --- a/lidarr/Dockerfile +++ b/lidarr/Dockerfile @@ -1,34 +1,18 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="jq \ - curl \ - cifs-utils \ - keyutils \ - samba \ - smbclient" + +################## +# 2 Modify Image # +################## RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################### - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio \ - \ # use /data instead of /config for hass.io environment - && sed -i "s|/config|/config/lidarr|g" /etc/services.d/lidarr/run \ + sed -i "s|/config|/config/lidarr|g" /etc/services.d/lidarr/run \ && sed -i "s|/config|/config/lidarr|g" /etc/cont-init.d/30-config \ \ # Allow UID and GID setting @@ -36,10 +20,43 @@ RUN \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser -# copy local files -COPY root/ / +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + curl \ + cifs-utils \ + keyutils \ + samba \ + smbclient" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/lidarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/lidarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/lidarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/lidarr/rootfs/etc/cont-init.d/00-banner.sh b/lidarr/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/lidarr/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/lidarr/rootfs/etc/cont-init.d/20-folders b/lidarr/rootfs/etc/cont-init.d/20-folders new file mode 100644 index 000000000..6e2cb7cce --- /dev/null +++ b/lidarr/rootfs/etc/cont-init.d/20-folders @@ -0,0 +1,19 @@ +#!/usr/bin/with-contenv bash + +if [ ! -d /share/music ]; then + echo "Creating /share/music" + mkdir -p /share/music + chown -R abc:abc /share/music +fi + +if [ ! -d /share/downloads ]; then + echo "Creating /share/downloads" + mkdir -p /share/downloads + chown -R abc:abc /share/downloads +fi + +if [ ! -d /config/lidarr ]; then + echo "Creating /config/lidarr" + mkdir -p /config/lidarr + chown -R abc:abc /config/lidarr +fi diff --git a/lidarr/rootfs/etc/cont-init.d/92-local_mounts.sh b/lidarr/rootfs/etc/cont-init.d/92-local_mounts.sh new file mode 100644 index 000000000..0920d68bd --- /dev/null +++ b/lidarr/rootfs/etc/cont-init.d/92-local_mounts.sh @@ -0,0 +1,32 @@ +#!/usr/bin/with-contenv bashio + +###################### +# MOUNT LOCAL SHARES # +###################### + +# Mount local Share if configured +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + echo "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + + # Mount by device as default + devpath=/dev + + # Mount as label + [ ${disk:0:2} != "sd" ] && devpath=/dev/disk/by-label + + # Creates dir + mkdir -p /mnt/$disk + chown -R $(id -u):$(id -g) /mnt/$disk + # Legacy mounting : mount to share if still exists (avoid breaking changes) + [ -d /share/$disk ] && mount $devpath/$disk /share/$disk || true + # Mount + mount $devpath/$disk /mnt/$disk && bashio::log.info "Success! $disk mounted to /mnt/$disk" || (bashio::log.fatal "Unable to mount local drives! Please check the name." && rmdir /mnt/$disk) + + done + +fi diff --git a/lidarr/rootfs/etc/cont-init.d/92-smb_mounts.sh b/lidarr/rootfs/etc/cont-init.d/92-smb_mounts.sh new file mode 100644 index 000000000..06410e554 --- /dev/null +++ b/lidarr/rootfs/etc/cont-init.d/92-smb_mounts.sh @@ -0,0 +1,83 @@ +#!/usr/bin/with-contenv bashio + +######################### +# MOUNT SMB SHARES v1.6 # +######################### +if bashio::config.has_value 'networkdisks'; then + + # Define variables + MOREDISKS=$(bashio::config 'networkdisks') + CIFS_USERNAME=$(bashio::config 'cifsusername') + CIFS_PASSWORD=$(bashio::config 'cifspassword') + MOUNTED=false + SMBVERS="" + SECVERS="" + + # Mount CIFS Share if configured and if Protection Mode is active + echo 'Mounting smb share(s)...' + + if bashio::config.has_value 'cifsdomain'; then + DOMAIN=",domain=$(bashio::config 'cifsdomain')" + else + DOMAIN="" + fi + + # Mounting disks + for disk in ${MOREDISKS//,/ }; do # Separate comma separated values + + # Clean name of network share + disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name + diskname=${disk//\\//} #replace \ with / + diskname=${diskname##*/} # Get only last part of the name + + # Data validation + if [[ ! $disk =~ ^.*+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[/]+.*+$ ]]; then + bashio::log.fatal "The structure of your \"networkdisks\" option : \"$disk\" doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2. If you don't use it, you can simply remove the text, this will avoid this error message in the future." + exit 0 + fi + + # Prepare mount point + mkdir -p /mnt/$diskname + chown -R root:root /mnt/$diskname + + #Tries to mount with default options + mount -t cifs -o rw,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname 2>ERRORCODE && MOUNTED=true || MOUNTED=false + + # if Fail test different smb and sec versions + if [ $MOUNTED = false ]; then + for SMBVERS in ",vers=3" ",vers=1.0" ",vers=2.1" ",vers=3.0" ",nodfs" ",uid=0,gid=0,forceuid,forcegid" ",noforceuid,noforcegid" ",${DOMAIN:-WORKGROUP}"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS $disk /mnt/$diskname 2>/dev/null && MOUNTED=true && break || MOUNTED=false + for SECVERS in ",sec=ntlmi" ",sec=ntlmv2" ",sec=ntlmv2i" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=ntlm" ",sec=krb5i" ",sec=krb5" ",iocharset=utf8"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS$SECVERS $disk /mnt/$disk name 2>/dev/null && MOUNTED=true && break 2 && break || MOUNTED=false + done + done + fi + + # Messages + if [ $MOUNTED = true ] && [ "mountpoint -q /mnt/$diskname" ]; then + #Test write permissions + touch /mnt/$diskname/testaze && rm /mnt/$diskname/testaze && + bashio::log.info "... $disk successfully mounted to /mnt/$diskname with options $SMBVERS$SECVERS" || + bashio::log.fatal "Disk is mounted, however unable to write in the shared disk. Please check UID/GID for permissions, and if the share is rw" + + else + # Mounting failed messages + bashio::log.fatal "Error, unable to mount $disk to /mnt/$diskname with username $CIFS_USERNAME, $CIFS_PASSWORD. Please check your remote share path, username, password, domain, try putting 0 in UID and GID" + bashio::log.fatal "Here is some debugging info :" + + # Provide debugging info + smbclient -V &>/dev/null || apt-get install smbclient || apk add --no-cache samba-client + #smbclient $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + smbclient -L $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + + # Error code + bashio::log.fatal "Error read : $(/dev/null || true + rmdir /mnt/$diskname || true + fi + + done +fi diff --git a/mealie/CHANGELOG.md b/mealie/CHANGELOG.md index 9eb5083fa..4439bc34e 100644 --- a/mealie/CHANGELOG.md +++ b/mealie/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 0.5.4 (03-12-2021) - Update to latest version from hay-kot/mealie diff --git a/mealie/Dockerfile b/mealie/Dockerfile index e6299c639..eb26c61a6 100644 --- a/mealie/Dockerfile +++ b/mealie/Dockerfile @@ -1,43 +1,52 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -COPY rootfs / +################## +# 2 Modify Image # +################## -ENV BASHIO_VERSION=0.14.3 +# Correct data path +RUN \ + grep -rl "/app/data" /app | xargs sed -i 's|/app/data|/data|g' + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps ENV PACKAGES="jq curl bash" +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + RUN \ - ################ - # Install apps # - ################ - apt-get update && apt-get install -y --no-install-recommends ${PACKAGES} && apt-get clean || apk add --no-cache ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio \ - ############### - # Adapt image # - ############### - # Correct data path - && grep -rl "/app/data" /app | xargs sed -i 's|/app/data|/data|g' \ # Add custom instructions to run.sh - && sed -i '1d' /app/mealie/run.sh \ + sed -i '1d' /app/mealie/run.sh \ && cat /app/mealie/run.sh >> /run.txt \ && cat /run.txt > /app/mealie/run.sh \ - && chmod +x /app/mealie/run.sh -# Add custom caddy instructions for ingress -#&& cat /caddy.txt >> /app/Caddyfile + && chmod +x /app/mealie/run.sh -VOLUME [ "/data" ] +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/mealie/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/mealie/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/mealie/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/mealie/rootfs/etc/cont-init.d/00-banner.sh b/mealie/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/mealie/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/mylar3/CHANGELOG.md b/mylar3/CHANGELOG.md index 66f7e8b76..4214b05a4 100644 --- a/mylar3/CHANGELOG.md +++ b/mylar3/CHANGELOG.md @@ -1 +1,5 @@ +- New standardized logic for Dockerfile build and packages installation + +## 0.6.1 (11-12-2021) +- Update to latest version from linuxserver/docker-mylar3 - Initial release diff --git a/mylar3/Dockerfile b/mylar3/Dockerfile index 1537c5759..cfcc4c91d 100644 --- a/mylar3/Dockerfile +++ b/mylar3/Dockerfile @@ -1,14 +1,14 @@ -############### -# Build Image # -############### +################# +# 1 Build Image # +################# ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -################ -# Modify Image # -################ +################## +# 2 Modify Image # +################## RUN sed -i "s|/config|/data|g" /etc/services.d/*/run \ && sed -i "s|/config|/data|g" /etc/cont-init.d/* \ @@ -18,9 +18,9 @@ RUN sed -i "s|/config|/data|g" /etc/services.d/*/run \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser -################ -# Install apps # -################ +################## +# 3 Install apps # +################## # Copy local files COPY rootfs/ / @@ -29,25 +29,25 @@ COPY rootfs/ / ENV PACKAGES="" # Automatic apps & bashio -RUN $(ls /bin/bash &>/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl || apk add --no-cache curl) && \ +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); 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); fi && \ curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ chmod 777 /automatic_packages.sh && \ /automatic_packages.sh "${PACKAGES:-}" && \ rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE - -############## -# Entrypoint # -############## + +################ +# 4 Entrypoint # +################ #RUN chmod 777 /entrypoint.sh #WORKDIR / #ENTRYPOINT [ "/usr/bin/env" ] #CMD [ "/entrypoint.sh" ] - -########## -# Labels # -########## + +############ +# 5 Labels # +############ ARG BUILD_ARCH ARG BUILD_DATE diff --git a/mylar3/config.json b/mylar3/config.json index 20ddd19d4..f356ce67e 100644 --- a/mylar3/config.json +++ b/mylar3/config.json @@ -71,8 +71,8 @@ "cifspassword": "str?" }, "slug": "mylar3", - "upstream": "v0.6.1-ls40", + "upstream": "0.6.1", "url": "https://github.com/alexbelgium/hassio-addons", - "version": "v0.6.1-ls40", + "version": "0.6.1", "webui": "http://[HOST]:[PORT:8090]" } diff --git a/mylar3/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/mylar3/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh index e33f7f063..4f9ed9c51 100644 --- a/mylar3/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ b/mylar3/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -2,18 +2,17 @@ # If dockerfile failed install manually if [ -e "/ENVFILE" ]; then echo "Executing script" - PACKAGES=$(< /ENVFILE) + PACKAGES=$(/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl &>/dev/null || apk add --no-cache curl) && \ - curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ - chmod 777 /automatic_packages.sh && \ - eval /./automatic_packages.sh "$PACKAGES" && \ - rm /automatic_packages.sh - + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/nextcloud/CHANGELOG.md b/nextcloud/CHANGELOG.md index 3860606bf..433d159b2 100644 --- a/nextcloud/CHANGELOG.md +++ b/nextcloud/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 23.0.0 (30-11-2021) - Update to latest version from linuxserver/docker-nextcloud diff --git a/nextcloud/Dockerfile b/nextcloud/Dockerfile index a1038f8a5..dbe0c58d9 100644 --- a/nextcloud/Dockerfile +++ b/nextcloud/Dockerfile @@ -1,6 +1,6 @@ -############### -# Build Image # -############### +################# +# 1 Build Image # +################# ARG BUILD_FROM ARG BUILD_VERSION @@ -8,9 +8,9 @@ ARG BUILD_ARCH ARG BUILD_UPSTREAM="23.0.0" FROM ${BUILD_FROM} -################ -# Modify Image # -################ +################## +# 2 Modify Image # +################## ENV NEXTCLOUD_PATH="/data/config/www/nextcloud" @@ -22,24 +22,40 @@ RUN \ && sed -i "s|data|share/nextcloud|g" /etc/services.d/nginx/* \ && sed -i "s|config|data/config|g" /etc/services.d/nginx/* -################ -# Install apps # -################ +################## +# 3 Install apps # +################## -COPY root/ / +# Add rootfs +COPY rootfs/ / +# Manual apps ENV PACKAGES="curl jq wget" -RUN $(ls /bin/bash &>/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl || apk add --no-cache curl) && \ +# 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); 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); fi && \ curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ chmod 777 /automatic_packages.sh && \ - /automatic_packagesaa.sh "$PACKAGES" && \ + /automatic_packages.sh "${PACKAGES:-}" && \ rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE VOLUME ["/share", "/ssl", "/data", "/media"] -### LABELS +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ + ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/nextcloud/rootfs/defaults/config.php b/nextcloud/rootfs/defaults/config.php new file mode 100644 index 000000000..367cad15d --- /dev/null +++ b/nextcloud/rootfs/defaults/config.php @@ -0,0 +1,6 @@ + '\OC\Memcache\APCu', + 'datadirectory' => '/share/nextcloud', + ); + diff --git a/nextcloud/rootfs/defaults/default b/nextcloud/rootfs/defaults/default new file mode 100644 index 000000000..f17b71216 --- /dev/null +++ b/nextcloud/rootfs/defaults/default @@ -0,0 +1,121 @@ +upstream php-handler { + server 127.0.0.1:9000; +} +server { + listen 80; + listen [::]:80; + server_name _; + return 301 https://$host$request_uri; +} +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + server_name _; + ssl_certificate /ssl/nextcloud/keys/cert.crt; + ssl_certificate_key /ssl/nextcloud/keys/cert.key; + + # Add headers to serve security related headers + # Before enabling Strict-Transport-Security headers please read into this + # topic first. + #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always; + # + # WARNING: Only add the preload option once you read about + # the consequences in https://hstspreload.org/. This option + # will add the domain to a hardcoded list that is shipped + # in all major browsers and getting removed from this list + # could take several months. + + add_header X-Content-Type-Options nosniff; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Robots-Tag none; + add_header X-Download-Options noopen; + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-Permitted-Cross-Domain-Policies none; + add_header Referrer-Policy no-referrer; + fastcgi_hide_header X-Powered-By; + root /data/config/www/nextcloud/; + # display real ip in nginx logs when connected through reverse proxy via docker network + set_real_ip_from 172.0.0.0/8; + real_ip_header X-Forwarded-For; + location = /robots.txt { + allow all; + log_not_found off; + access_log off; + } + location = /.well-known/carddav { + return 301 $scheme://$host:$server_port/remote.php/dav; + } + location = /.well-known/caldav { + return 301 $scheme://$host:$server_port/remote.php/dav; + } + location = /.well-known/webfinger { + return 301 $scheme://$host:$server_port/public.php?service=webfinger; + } + location = /.well-known/host-meta { + return 301 $scheme://$host:$server_port/public.php?service=host-meta; + } + location = /.well-known/host-meta.json { + return 301 $scheme://$host:$server_port/public.php?service=host-meta-json; + } + client_max_body_size 10G; + fastcgi_buffers 64 4K; + gzip on; + gzip_vary on; + gzip_comp_level 4; + gzip_min_length 256; + gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; + gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; + location / { + rewrite ^ /index.php; + } + location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ { + deny all; + } + location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) { + deny all; + } + location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+|.+\/richdocumentscode\/proxy)\.php(?:$|\/) { + fastcgi_split_path_info ^(.+?\.php)(\/.*|)$; + set $path_info $fastcgi_path_info; + try_files $fastcgi_script_name =404; + include /etc/nginx/fastcgi_params; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param PATH_INFO $path_info; + fastcgi_param HTTPS on; + fastcgi_param modHeadersAvailable true; + fastcgi_param front_controller_active true; + fastcgi_pass php-handler; + fastcgi_intercept_errors on; + fastcgi_request_buffering off; + } + location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) { + try_files $uri/ =404; + index index.php; + } + location ~ \.(?:css|js|woff2?|svg|gif|map)$ { + try_files $uri /index.php$request_uri; + add_header Cache-Control "public, max-age=15778463"; + # Add headers to serve security related headers + # Before enabling Strict-Transport-Security headers please read into this + # topic first. + #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always; + # + # WARNING: Only add the preload option once you read about + # the consequences in https://hstspreload.org/. This option + # will add the domain to a hardcoded list that is shipped + # in all major browsers and getting removed from this list + # could take several months. + add_header X-Content-Type-Options nosniff; + add_header X-XSS-Protection "1; mode=block"; + add_header X-Robots-Tag none; + add_header X-Download-Options noopen; + add_header X-Frame-Options "SAMEORIGIN"; + add_header X-Permitted-Cross-Domain-Policies none; + add_header Referrer-Policy no-referrer; + access_log off; + } + location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ { + try_files $uri /index.php$request_uri; + access_log off; + } +} diff --git a/nextcloud/rootfs/defaults/nextcloud-perms.sh b/nextcloud/rootfs/defaults/nextcloud-perms.sh new file mode 100644 index 000000000..6bf4607f0 --- /dev/null +++ b/nextcloud/rootfs/defaults/nextcloud-perms.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +ocpath="${NEXTCLOUD_PATH}" +htuser='abc' +htgroup='abc' +rootuser='root' + +printf "Creating possible missing Directories\n" +mkdir -p $ocpath/data +mkdir -p $ocpath/assets +mkdir -p $ocpath/updater +mkdir -p $ocpath/apps +mkdir -p $ocpath/assets +mkdir -p $ocpath/config +mkdir -p $ocpath/data +mkdir -p $ocpath/themes +mkdir -p /data/config/nextcloud/config +mkdir -p /data/config/nextcloud/data +mkdir -p /data/config/www/nextcloud/occ 2>/dev/null +mkdir -p /share/nextcloud +mkdir -p /ssl/nextcloud/keys + +printf "chmod Files and Directories. This could take some time, please wait...\n" +#chmod -R 777 ${ocpath} +find ${ocpath}/ -type f -exec chmod 0640 {} \; +find ${ocpath}/ -type d -exec chmod 0750 {} \; + +#find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640 +#find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750 + +printf "chown Directories. This could take some time, please wait...\n" +chown -R ${rootuser}:${htgroup} ${ocpath}/ +chown -R ${htuser}:${htgroup} ${ocpath}/apps/ +chown -R ${htuser}:${htgroup} ${ocpath}/assets/ +chown -R ${htuser}:${htgroup} ${ocpath}/config/ +chown -R ${htuser}:${htgroup} ${ocpath}/data/ +chown -R ${htuser}:${htgroup} ${ocpath}/themes/ +chown -R ${htuser}:${htgroup} ${ocpath}/updater/ +chown -R ${htuser}:${htgroup} /share/nextcloud +chown -R ${htuser}:${htgroup} /ssl/nextcloud/keys || true + +chmod +x ${ocpath}/occ + +printf "chmod/chown .htaccess\n" +if [ -f ${ocpath}/.htaccess ] + then + chmod 0644 ${ocpath}/.htaccess + chown ${rootuser}:${htgroup} ${ocpath}/.htaccess +fi +if [ -f ${ocpath}/data/.htaccess ] + then + chmod 0644 ${ocpath}/data/.htaccess + chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess +fi diff --git a/nextcloud/rootfs/defaults/nginx.conf b/nextcloud/rootfs/defaults/nginx.conf new file mode 100644 index 000000000..9949edc82 --- /dev/null +++ b/nextcloud/rootfs/defaults/nginx.conf @@ -0,0 +1,102 @@ +## Version 2018/08/16 - Changelog: https://github.com/linuxserver/docker-baseimage-alpine-nginx/commits/master/root/defaults/nginx.conf + +user abc; +worker_processes 4; +pid /run/nginx.pid; +include /etc/nginx/modules/*.conf; + +events { + worker_connections 768; + # multi_accept on; +} + +http { + + ## + # Basic Settings + ## + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + keepalive_timeout 300; + types_hash_max_size 2048; + fastcgi_read_timeout 86400; + # server_tokens off; + + # server_names_hash_bucket_size 64; + # server_name_in_redirect off; + + client_max_body_size 0; + + include /etc/nginx/mime.types; + default_type application/octet-stream; + + ## + # Logging Settings + ## + + access_log /data/config/log/nginx/access.log; + error_log /data/config/log/nginx/error.log; + + ## + # Gzip Settings + ## + + gzip on; + gzip_disable "msie6"; + + # gzip_vary on; + # gzip_proxied any; + # gzip_comp_level 6; + # gzip_buffers 16 8k; + # gzip_http_version 1.1; + # gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; + + ## + # nginx-naxsi config + ## + # Uncomment it if you installed nginx-naxsi + ## + + #include /etc/nginx/naxsi_core.rules; + + ## + # nginx-passenger config + ## + # Uncomment it if you installed nginx-passenger + ## + + #passenger_root /usr; + #passenger_ruby /usr/bin/ruby; + + ## + # Virtual Host Configs + ## + include /etc/nginx/conf.d/*.conf; + include /data/config/nginx/site-confs/*; + +} + +#mail { +# # See sample authentication script at: +# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript +# +# # auth_http localhost/auth.php; +# # pop3_capabilities "TOP" "USER"; +# # imap_capabilities "IMAP4rev1" "UIDPLUS"; +# +# server { +# listen localhost:110; +# protocol pop3; +# proxy on; +# } +# +# server { +# listen localhost:143; +# protocol imap; +# proxy on; +# } +#} +daemon off; + diff --git a/nextcloud/rootfs/defaults/root b/nextcloud/rootfs/defaults/root new file mode 100644 index 000000000..7563168d1 --- /dev/null +++ b/nextcloud/rootfs/defaults/root @@ -0,0 +1,9 @@ +# do daily/weekly/monthly maintenance +# min hour day month weekday command +*/15 * * * * run-parts /etc/periodic/15min +0 * * * * run-parts /etc/periodic/hourly +0 2 * * * run-parts /etc/periodic/daily +0 3 * * 6 run-parts /etc/periodic/weekly +0 5 1 * * run-parts /etc/periodic/monthly +# nextcloud cron +*/5 * * * * s6-setuidgid abc php7 -f /data/config/www/nextcloud/cron.php diff --git a/nextcloud/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/nextcloud/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/nextcloud/rootfs/etc/cont-init.d/00-banner.sh b/nextcloud/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/nextcloud/rootfs/etc/cont-init.d/10-adduser b/nextcloud/rootfs/etc/cont-init.d/10-adduser new file mode 100644 index 000000000..a1207733b --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/10-adduser @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio + +PUID=$(bashio::config "PUID") +PGID=$(bashio::config "PGID") + +groupmod -o -g "$PGID" abc +usermod -o -u "$PUID" abc +mkdir -p /data/config +mkdir -p /share/nextcloud +echo ' +------------------------------------- + _ () + | | ___ _ __ + | | / __| | | / \ + | | \__ \ | | | () | + |_| |___/ |_| \__/ + + +Brought to you by linuxserver.io +-------------------------------------' +if [[ -f /donate.txt ]]; then + echo ' +To support the app dev(s) visit:' + cat /donate.txt +fi +echo ' +To support LSIO projects visit: +https://www.linuxserver.io/donate/ +------------------------------------- +GID/UID +-------------------------------------' +echo " +User uid: $(id -u abc) +User gid: $(id -g abc) +------------------------------------- +" +chown abc:abc /app +chown abc:abc /data/config +chown abc:abc /defaults diff --git a/nextcloud/rootfs/etc/cont-init.d/30-keygen b/nextcloud/rootfs/etc/cont-init.d/30-keygen new file mode 100644 index 000000000..2d41156b2 --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/30-keygen @@ -0,0 +1,37 @@ +#!/usr/bin/with-contenv bashio + +if bashio::config.true 'use_own_certs'; then + + bashio::log.info "Using referenced ssl certificates..." + CERTFILE=$(bashio::config 'certfile') + KEYFILE=$(bashio::config 'keyfile') + + #Check if files exist + echo "... checking if referenced files exist" + [ ! -f /ssl/$CERTFILE ] && bashio::log.fatal "... use_own_certs is true but certificate /ssl/$CERTFILE not found" && bashio::exit.nok + [ ! -f /ssl/$KEYFILE ] && bashio::log.fatal "... use_own_certs is true but certificate /ssl/$KEYFILE not found" && bashio::exit.nok + +else + mkdir -p /ssl/nextcloud/keys + bashio::log.info "No ssl certificates set. Auto generating ones..." + SUBJECT="/C=US/ST=CA/L=Carlsbad/O=Linuxserver.io/OU=LSIO Server/CN=*" + openssl req -new -x509 -days 3650 -nodes -out /ssl/nextcloud/keys/cert.crt -keyout /ssl/nextcloud/keys/cert.key -subj "$SUBJECT" + CERTFILE="nextcloud/keys/cert.crt" + KEYFILE="nextcloud/keys/cert.key" + +fi + +#Sets certificates +echo "... adding ssl certs in files" +#Sets certificates +for NGINXFILE in "/defaults/default" "/config/nginx/site-confs/default" "/data/config/nginx/site-confs/default"; do + if [ -f $NGINXFILE ]; then + LINE=$(sed -n "/ssl_certificate /=" $NGINXFILE) + if [ ! -z $LINE ]; then + sed -i "/ssl_certificate/ d" $NGINXFILE + sed -i "$LINE a ssl_certificate_key /ssl/$KEYFILE;" $NGINXFILE + sed -i "$LINE a ssl_certificate /ssl/$CERTFILE;" $NGINXFILE + fi + fi +done +bashio::log.info "... done" diff --git a/nextcloud/rootfs/etc/cont-init.d/40-config b/nextcloud/rootfs/etc/cont-init.d/40-config new file mode 100644 index 000000000..f63e7eb5b --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/40-config @@ -0,0 +1,19 @@ +#!/usr/bin/with-contenv bash + +#create folders +mkdir -p \ + /share/nextcloud \ + /data/config/nextcloud/config \ + /data/config/nextcloud/data + +#permissions +chown abc:abc \ + /share/nextcloud \ + /data/config/nextcloud/config \ + /data/config/nextcloud/data + +chown -R abc:abc \ + /var/lib/nginx + +rm -r /data/config/www/nextcloud/assets &>/dev/null +chmod -R 777 /data/config diff --git a/nextcloud/rootfs/etc/cont-init.d/50-install b/nextcloud/rootfs/etc/cont-init.d/50-install new file mode 100644 index 000000000..bd2695198 --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/50-install @@ -0,0 +1,21 @@ +#!/usr/bin/with-contenv bash + +# create folders +mkdir -p \ + "${NEXTCLOUD_PATH}" \ + /data/config/crontabs + +# install app +if [ ! -e "${NEXTCLOUD_PATH}/index.php" ]; then + tar xf /app/nextcloud.tar.bz2 -C \ + "${NEXTCLOUD_PATH}" --strip-components=1 + chown abc:abc -R \ + "${NEXTCLOUD_PATH}" + chmod +x "${NEXTCLOUD_PATH}/occ" +fi + +#?set cronjob +[[ ! -f /data/config/crontabs/root ]] && \ + cp /defaults/root /data/config/crontabs/root +cp /data/config/crontabs/root /etc/crontabs/root + diff --git a/nextcloud/rootfs/etc/cont-init.d/60-memcache b/nextcloud/rootfs/etc/cont-init.d/60-memcache new file mode 100644 index 000000000..0307c088d --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/60-memcache @@ -0,0 +1,9 @@ +#!/usr/bin/with-contenv bash + +# copy config +[[ ! -f /data/config/www/nextcloud/config/config.php ]] && \ + cp /defaults/config.php /data/config/www/nextcloud/config/config.php + +# permissions +chown abc:abc \ + /data/config/www/nextcloud/config/config.php diff --git a/nextcloud/rootfs/etc/cont-init.d/99-elasticsearch b/nextcloud/rootfs/etc/cont-init.d/99-elasticsearch new file mode 100644 index 000000000..b87d40798 --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/99-elasticsearch @@ -0,0 +1,76 @@ +#!/usr/bin/with-contenv bashio + +LAUNCHER="sudo -u abc php /data/config/www/nextcloud/occ" || bashio::log.info "/data/config/www/nextcloud/occ not found" +if ! bashio::fs.file_exists '/data/config/www/nextcloud/occ'; then + LAUNCHER=$(find / -name "occ" -print -quit) +fi || bashio::log.info "occ not found" + +# Make sure there is an Nextcloud installation +if [[ $($LAUNCHER -V) == *"not installed"* ]]; then + bashio::log.warning "It seems there is no Nextcloud server installed. Please restart the addon after initialization of the user." + exit 0 +fi + +############ +# BASED ON # +################################################################################# +# https://raw.githubusercontent.com/nextcloud/vm/master/apps/fulltextsearch.sh # +# T&M Hansson IT AB © - 2021, https://www.hanssonit.se/ # +# SwITNet Ltd © - 2021, https://switnet.net/ # +################################################################################# + +if bashio::config.true 'Full_Text_Search'; then + if [ $LAUNCHER fulltextsearch:index ] &>/dev/null; then + echo "Full Text Search is already working" + break 2 + fi + + echo "Installing Full Text Search" + # Reset Full Text Search to be able to index again, and also remove the app to be able to install it again + occ fulltextsearch:reset &>/dev/null || true + APPS=(fulltextsearch fulltextsearch_elasticsearch files_fulltextsearch) + for app in "${APPS[@]}"; do + # If app exists, remove it + [ ! -z $($LAUNCHER app:getpath $app) ] && $LAUNCHER app:remove $app &>/dev/null + done + + # Get Full Text Search app for nextcloud + for app in "${APPS[@]}"; do + echo "... installing apps : $app" + $LAUNCHER app:install $app >/dev/null + $LAUNCHER app:enable $app >/dev/null + done + chown -R abc:abc $NEXTCLOUD_PATH/apps + + if bashio::config.has_value 'elasticsearch_server'; then + HOST=$(bashio::config 'elasticsearch_server') + else + bashio::log.warning 'Please define elasticsearch server url in addon options with the format "ip:port" such as "192.168.178.1:9200"' + HOST=$(bashio::network.ipv4_address) + HOST="${HOST%/*}:9200" + fi + + # Final setup + echo "... settings apps" + #occ fulltextsearch:configure '{"search_platform":"ElasticSearchPlatform"}' + $LAUNCHER fulltextsearch_elasticsearch:configure "{\"elastic_host\":\"http://$HOST:9200\"}" &>/dev/null + $LAUNCHER fulltextsearch_elasticsearch:configure "{\"elastic_index\":\"my_index\"}" &>/dev/null + $LAUNCHER fulltextsearch_elasticsearch:configure "{\"analyzer_tokenizer\":\"standard\"}" &>/dev/null + $LAUNCHER fulltextsearch:configure '{"search_platform":"OCA\\FullTextSearch_Elasticsearch\\Platform\\ElasticSearchPlatform"}' &>/dev/null || true + $LAUNCHER files_fulltextsearch:configure "{\"files_pdf\":\"1\",\"files_office\":\"1\"}" &>/dev/null || true + + # Is server detected + # if [ curl $HOST ] &>/dev/null; then + # Wait further for cache for index to work + echo "Waiting for a few seconds before indexing starts..." + sleep 10s + if $LAUNCHER fulltextsearch:index &>/dev/null; then + bashio::log.info "Full Text Search was successfully installed using elasticsearch server $HOST!" + + else + + bashio::log.warning "Elasticsearch can't connect. Please manually define its server in the options" + fi +else + echo "Full_Text_Search option not set" +fi diff --git a/nextcloud/rootfs/etc/cont-init.d/99-ocr b/nextcloud/rootfs/etc/cont-init.d/99-ocr new file mode 100644 index 000000000..8d5693f82 --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/99-ocr @@ -0,0 +1,45 @@ +#!/usr/bin/with-contenv bashio + +LAUNCHER="sudo -u abc php /data/config/www/nextcloud/occ" || bashio::log.info "/data/config/www/nextcloud/occ not found" +if ! bashio::fs.file_exists '/data/config/www/nextcloud/occ'; then + LAUNCHER=$(find / -name "occ" -print -quit) +fi || bashio::log.info "occ not found" + +# Make sure there is an Nextcloud installation +if [[ $($LAUNCHER -V) == *"not installed"* ]]; then + bashio::log.warning "It seems there is no Nextcloud server installed. Please restart the addon after initialization of the user." + exit 0 +fi + +# Install OCR if requested +if bashio::config.has_value 'OCR'; then + # Install package + if $(bashio::config 'OCR') = true; then + + # Get Full Text Search app for nextcloud + echo "... installing apps : fulltextsearch" + occ app:install files_fulltextsearch_tesseract &>/dev/null || true + occ app:enable files_fulltextsearch_tesseract &>/dev/null || true + + echo "Installing OCR" + apk add --quiet --no-cache tesseract-ocr || apk add --quiet --no-cache tesseract-ocr@community + # Install additional language if requested + if bashio::config.has_value 'OCRLANG'; then + LANG=$(bashio::config 'OCRLANG') + apk add --quiet --no-cache tesseract-ocr-data-$LANG || apk add --quiet --no-cache tesseract-ocr-data-$LANG@community && \ + bashio::log.info "OCR Language installed : $LANG" || bashio::log.fatal "Couldn't install OCR lang $LANG. Please check its format is conform" + + # Downloading trainer data + cd /usr/share/tessdata + sudo rm -r $LANG.traineddata &>/dev/null || true + wget https://github.com/tesseract-ocr/tessdata/raw/main/$LANG.traineddata &>/dev/null + + fi + elif $(bashio::config 'OCR') = false; then + bashio::log.info 'Removing OCR' + # Delete package + apk del tesseract-ocr.* &>/dev/null || true + # Remove app + occ app:disable files_fulltextsearch_tesseract &>/dev/null || true + fi +fi diff --git a/nextcloud/rootfs/etc/cont-init.d/99-trusted_domains b/nextcloud/rootfs/etc/cont-init.d/99-trusted_domains new file mode 100644 index 000000000..59036b0a9 --- /dev/null +++ b/nextcloud/rootfs/etc/cont-init.d/99-trusted_domains @@ -0,0 +1,48 @@ +#!/usr/bin/with-contenv bashio + +LAUNCHER="sudo -u abc php /data/config/www/nextcloud/occ" || bashio::log.info "/data/config/www/nextcloud/occ not found" +if ! bashio::fs.file_exists '/data/config/www/nextcloud/occ'; then + LAUNCHER=$(find / -name "occ" -print -quit) +fi || bashio::log.info "occ not found" + +# Make sure there is an Nextcloud installation +if [[ $($LAUNCHER -V) == *"not installed"* ]]; then + bashio::log.warning "It seems there is no Nextcloud server installed. Please restart the addon after initialization of the user." + exit 0 +fi + +#################### +# Initialization # +#################### + +if bashio::config.has_value 'trusted_domains'; then + + bashio::log.info "Currently set trusted domains :" + $LAUNCHER config:system:get trusted_domains || bashio::log.info "No trusted domain set yet. The first one will be set when doing initial configuration" + + bashio::log.info "Trusted domains set in the configuration. Refreshing domains." && \ + ################################### + # Remove previous trusted domains # + ################################### + bashio::log.info "... removing previously added trusted domain (except for first one created)" + i=2 + until [ $i -gt 5 ]; do + $LAUNCHER config:system:delete trusted_domains $i && \ + ((i = i + 1)) || exit + done + + ########################### + # Add new trusted domains # + ########################### + TRUSTEDDOMAINS=$(bashio::config 'trusted_domains') + bashio::log.info "... alignement with trusted domains list : ${TRUSTEDDOMAINS}" + for domain in ${TRUSTEDDOMAINS//,/ }; do # Comma separated values + bashio::log.info "... adding ${domain}" + $LAUNCHER config:system:set trusted_domains $i --value=${domain} + i=$((i + 1)) + done + + bashio::log.info "Remaining configurated trusted domains :" + bashio::log.info "$($LAUNCHER config:system:get trusted_domains)" || exit + +fi diff --git a/nextcloud/rootfs/etc/services.d/cron/run b/nextcloud/rootfs/etc/services.d/cron/run new file mode 100644 index 000000000..a1b27f4a7 --- /dev/null +++ b/nextcloud/rootfs/etc/services.d/cron/run @@ -0,0 +1,3 @@ +#!/usr/bin/with-contenv bash + +/usr/sbin/crond -f -S -l 0 -c /etc/crontabs diff --git a/ombi/CHANGELOG.md b/ombi/CHANGELOG.md index e21e4f2b7..278a6f5fb 100644 --- a/ombi/CHANGELOG.md +++ b/ombi/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 4.3.3 (07-11-2021) - Update to latest version from linuxserver/docker-ombi diff --git a/ombi/Dockerfile b/ombi/Dockerfile index 23fd0ce13..a6e70e5b3 100644 --- a/ombi/Dockerfile +++ b/ombi/Dockerfile @@ -1,38 +1,16 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 + +################## +# 2 Modify Image # +################## RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends \ - jq \ - curl \ - # Backup if change - || apk add --no-cache jq curl \ - \ - ################## - # Install bashio # - ################## - && curl -J -L -o /tmp/bashio.tar.gz \ - "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - && mkdir /tmp/bashio \ - && tar zxvf \ - /tmp/bashio.tar.gz \ - --strip 1 -C /tmp/bashio \ - \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -fr \ - /tmp/* \ - \ - ############### - # Adapt image # - ############### # Allow UID and GID setting && sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ @@ -43,9 +21,38 @@ RUN \ && grep -rl "/config" /etc/services.d | xargs sed -i 's|/config|/config/ombi|g' || true \ && sed -i 's=/config/ombi=/config/ombi || true=g' /etc/cont-init.d/10-adduser || true -VOLUME [ "/data" ] +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq curl" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/ombi/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/ombi/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/ombi/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/ombi/rootfs/etc/cont-init.d/00-banner.sh b/ombi/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/ombi/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/organizr/CHANGELOG.md b/organizr/CHANGELOG.md index 8b1378917..4a854f7ea 100644 --- a/organizr/CHANGELOG.md +++ b/organizr/CHANGELOG.md @@ -1 +1,2 @@ - +- New standardized logic for Dockerfile build and packages installation +- Initial build diff --git a/organizr/Dockerfile b/organizr/Dockerfile index e6357f4aa..88e57c65b 100644 --- a/organizr/Dockerfile +++ b/organizr/Dockerfile @@ -1,25 +1,13 @@ +################# +# 1 Build Image # +################# ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="curl \ - jq" -RUN \ - ################ - # Install apps # - ################ - apk add --no-cache ${PACKAGES} \ - \ - ################### - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio || true +################## +# 2 Modify Image # +################## RUN \ ######################################## @@ -36,10 +24,33 @@ RUN \ && grep -rl '/config' /etc/logrotate.d/ | xargs sed -i 's|/config|/data/organizr|g' \ && grep -rl '/config' /etc/services.d/ | xargs sed -i 's|/config|/data/organizr|g' -# copy local files -COPY root/ / +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="curl \ + jq" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/organizr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/organizr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/organizr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/organizr/rootfs/etc/cont-init.d/00-banner.sh b/organizr/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/organizr/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/organizr/rootfs/etc/cont-init.d/00-folders b/organizr/rootfs/etc/cont-init.d/00-folders new file mode 100644 index 000000000..73c65e4d3 --- /dev/null +++ b/organizr/rootfs/etc/cont-init.d/00-folders @@ -0,0 +1,7 @@ +#!/usr/bin/with-contenv bash + +if [ ! -d /data/organizr ]; then + echo "Creating /data/organizr" + mkdir -p /data/organizr + chown -R abc:abc /data/organizr +fi diff --git a/paperless_ng/CHANGELOG.md b/paperless_ng/CHANGELOG.md index cc74fde3c..db30fd1c7 100644 --- a/paperless_ng/CHANGELOG.md +++ b/paperless_ng/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation - allow !secrets in config.yaml (see Home Assistant documentation) ## 1.5.0 (27-11-2021) diff --git a/paperless_ng/Dockerfile b/paperless_ng/Dockerfile index 677a1693b..4d07acb10 100644 --- a/paperless_ng/Dockerfile +++ b/paperless_ng/Dockerfile @@ -1,35 +1,16 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -# Set shell -ENV BASHIO_VERSION=0.14.3 -ENV PAPERLESS_DATA_DIR=/config/paperless_ng -ENV PACKAGES="jq \ - curl \ - cifs-utils \ - keyutils \ - smbclient \ - samba \ - yamllint" - -RUN apt-get clean && \ - apt-get update && \ - apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio || true - -# copy local files -COPY rootfs/ / +################## +# 2 Modify Image # +################## +ENV PAPERLESS_DATA_DIR=/config/paperless_ng RUN \ ################# # Correct image # @@ -42,7 +23,44 @@ RUN \ && sed -i "s|/config|$PAPERLESS_DATA_DIR|g" /etc/cont-init.d/10-adduser \ && sed -i "s|/config|$PAPERLESS_DATA_DIR|g" /etc/cont-init.d/50-config -### LABELS +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + curl \ + cifs-utils \ + keyutils \ + smbclient \ + samba \ + yamllint" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ + ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/paperless_ng/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/paperless_ng/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh index 612e26d7e..4f9ed9c51 100644 --- a/paperless_ng/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ b/paperless_ng/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -1,29 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - + ####################### + # Automatic installer # + ####################### + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/paperless_ng/rootfs/etc/cont-init.d/90-config_yaml.sh b/paperless_ng/rootfs/etc/cont-init.d/90-config_yaml.sh index 00646fc3f..e37468ce2 100644 --- a/paperless_ng/rootfs/etc/cont-init.d/90-config_yaml.sh +++ b/paperless_ng/rootfs/etc/cont-init.d/90-config_yaml.sh @@ -83,8 +83,8 @@ while IFS= read -r line; do if [[ $line =~ ^.+[=].+$ ]]; then export $line # Export the variable - sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || sed -i "1a export $line" /scripts/*run* - + sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || true + sed -i "1a export $line" /scripts/*run* 2>/dev/null || true # Show in log bashio::log.blue "$line" else diff --git a/papermerge/CHANGELOG.md b/papermerge/CHANGELOG.md index 78ae76daa..d5a91d9b5 100644 --- a/papermerge/CHANGELOG.md +++ b/papermerge/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation - OCR repaired - Improve SMB mount code to v1.5 ; accepts several network disks separated by commas (//123.12.12.12/share,//123.12.12.12/hello) that are mount to /mnt/$sharename diff --git a/papermerge/Dockerfile b/papermerge/Dockerfile index dff969a6c..b8dd80591 100644 --- a/papermerge/Dockerfile +++ b/papermerge/Dockerfile @@ -1,37 +1,14 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION - FROM ${BUILD_FROM} -# Add bashio -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="jq \ - curl \ - cifs-utils \ - keyutils \ - samba \ - smbclient" - -RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio || true - -# Copy root filesystem -COPY rootfs / +################## +# 2 Modify Image # +################## RUN \ # Allow UID and GID setting @@ -42,9 +19,43 @@ RUN \ && sed -i "s| /config| /data/config|g" /etc/cont-init.d/* \ && sed -i "s| /config| /data/config|g" /defaults/* || true -VOLUME [ "/data" ] +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + curl \ + cifs-utils \ + keyutils \ + samba \ + smbclient" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/papermerge/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/papermerge/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh index 612e26d7e..4f9ed9c51 100644 --- a/papermerge/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ b/papermerge/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -1,29 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - + ####################### + # Automatic installer # + ####################### + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/papermerge/rootfs/etc/cont-init.d/91-OCR b/papermerge/rootfs/etc/cont-init.d/91-OCR index 6bfb0ccf8..e642780f0 100644 --- a/papermerge/rootfs/etc/cont-init.d/91-OCR +++ b/papermerge/rootfs/etc/cont-init.d/91-OCR @@ -4,17 +4,17 @@ OCRLANG="$(bashio::config "ocrlang")" if [ -n "$OCRLANG" ]; then - LINE=$(sed -n '/OCR_LANGUAGES/=' /data/config/papermerge.conf.py) + LINE=$(sed -n '/OCR_LANGUAGES/=' /data/config/papermerge.conf.py) bashio::log.info "OCRLANG variable is set, processing the language packages" apt-get update >/dev/null for i in $(echo "$OCRLANG" | tr "," " "); do - if apt-cache show tesseract-ocr-"${i}" > /dev/null 2>&1; then + if apt-cache show tesseract-ocr-"${i}" >/dev/null 2>&1; then echo "installing tesseract-ocr-${i}" >/dev/null - apt-get install -y tesseract-ocr-"${i}" >/dev/null + apt-get install -yqq tesseract-ocr-"${i}" >/dev/null else echo "package tesseract-ocr-${i} not found in the repository, skipping" fi - sed -i "$LINE a \"${i}\": \"${i}\"," /data/config/papermerge.conf.py - bashio::log.info "... ${i} installed" + sed -i "$LINE a \"${i}\": \"${i}\"," /data/config/papermerge.conf.py + bashio::log.info "... ${i} installed" done fi diff --git a/photoprism/CHANGELOG.md b/photoprism/CHANGELOG.md index 5bedd9f1d..ff6989aff 100644 --- a/photoprism/CHANGELOG.md +++ b/photoprism/CHANGELOG.md @@ -1,3 +1,7 @@ + +## 20211210 (12-12-2021) +- Update to latest version from photoprism/photoprism +- New standardized logic for Dockerfile build and packages installation - Allow mounting local drives by label. Just pust the label instead of sda1 for example - Allow mounting of devices up to sdg2 - Improve SMB mount code to v1.5 ; accepts several network disks separated by commas (//123.12.12.12/share,//123.12.12.12/hello) that are mount to /mnt/$sharename diff --git a/photoprism/Dockerfile b/photoprism/Dockerfile index 4f1bbebc2..3f59e29c1 100644 --- a/photoprism/Dockerfile +++ b/photoprism/Dockerfile @@ -1,43 +1,17 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION -ARG BUILD_UPSTREAM="210217-49039368" -FROM photoprism/photoprism:preview +ARG BUILD_UPSTREAM="20211210" +FROM photoprism/photoprism:20211203 -# Copy root filesystem -COPY rootfs / - -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="jq \ - curl \ - cifs-utils \ - keyutils \ - samba \ - smbclient \ - coreutils" +################## +# 2 Modify Image # +################## RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio || true - -RUN \ - ################### - # Configure image # - ################### - \ # Create directories mkdir -m 777 -p \ /data/photoprism/originals \ @@ -46,14 +20,47 @@ RUN \ /data/photoprism/backup \ /data/photoprism/storage/cache && \ chown -Rf photoprism:photoprism /data/photoprism && \ - chmod -Rf a+rwx /data/photoprism \ - # Allow execution of run - && chmod 777 /run.sh + chmod -Rf a+rwx /data/photoprism && \ + # rename entrypoint + mv /entrypoint.sh /entrypoint_photoprism.sh + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + curl \ + cifs-utils \ + keyutils \ + samba \ + smbclient \ + coreutils" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +RUN chmod 777 /entrypoint.sh ENTRYPOINT [ "/usr/bin/env" ] -CMD [ "/run.sh" ] +CMD [ "/entrypoint.sh" ] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/photoprism/config.json b/photoprism/config.json index f6b5e0d67..017fcea2d 100644 --- a/photoprism/config.json +++ b/photoprism/config.json @@ -1,6 +1,8 @@ { "apparmor": true, - "arch": ["aarch64", "amd64", "armhf", "armv7"], + "arch": [ + "amd64" + ], "description": "A server-based application for browsing, organizing and sharing your personal photo collection", "devices": [ "/dev/sda", @@ -33,7 +35,10 @@ "environment": { "PHOTOPRISM_ADMIN_PASSWORD": "please_change_password" }, - "map": ["media:rw", "share:rw"], + "map": [ + "media:rw", + "share:rw" + ], "name": "Photoprism", "options": { "networkdisks": "//server/share", @@ -52,7 +57,10 @@ "ports_description": { "2342/tcp": "Web interface" }, - "privileged": ["SYS_ADMIN", "DAC_READ_SEARCH"], + "privileged": [ + "SYS_ADMIN", + "DAC_READ_SEARCH" + ], "schema": { "localdisks": "str?", "networkdisks": "str?", @@ -66,8 +74,8 @@ "CUSTOM_OPTIONS": "str?" }, "slug": "photoprism", - "upstream": "210217-49039368", + "upstream": "20211210", "url": "https://github.com/alexbelgium/hassio-addons-test", - "version": "210217-49039368-5", + "version": "20211210", "webui": "http://[HOST]:[PORT:2342]" } diff --git a/photoprism/rootfs/entrypoint.sh b/photoprism/rootfs/entrypoint.sh new file mode 100644 index 000000000..35ccb7382 --- /dev/null +++ b/photoprism/rootfs/entrypoint.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "Starting..." + +#################### +# Starting scripts # +#################### + +cd / +for SCRIPTS in scripts/*; do + [ -e "$SCRIPTS" ] || continue + echo "$SCRIPTS: executing" + chown $(id -u):$(id -g) $SCRIPTS + chmod a+x $SCRIPTS + sed -i 's|/usr/bin/with-contenv bashio|/usr/bin/env bashio|g' $SCRIPTS || true + ./$SCRIPTS || echo "$SCRIPTS: exiting $?" +done diff --git a/photoprism/rootfs/scripts/00-aaa_dockerfile_backup.sh b/photoprism/rootfs/scripts/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/photoprism/rootfs/scripts/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/photoprism/rootfs/scripts/00-banner.sh b/photoprism/rootfs/scripts/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/photoprism/rootfs/scripts/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/photoprism/rootfs/scripts/92-local_mounts.sh b/photoprism/rootfs/scripts/92-local_mounts.sh new file mode 100644 index 000000000..0920d68bd --- /dev/null +++ b/photoprism/rootfs/scripts/92-local_mounts.sh @@ -0,0 +1,32 @@ +#!/usr/bin/with-contenv bashio + +###################### +# MOUNT LOCAL SHARES # +###################### + +# Mount local Share if configured +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + echo "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + + # Mount by device as default + devpath=/dev + + # Mount as label + [ ${disk:0:2} != "sd" ] && devpath=/dev/disk/by-label + + # Creates dir + mkdir -p /mnt/$disk + chown -R $(id -u):$(id -g) /mnt/$disk + # Legacy mounting : mount to share if still exists (avoid breaking changes) + [ -d /share/$disk ] && mount $devpath/$disk /share/$disk || true + # Mount + mount $devpath/$disk /mnt/$disk && bashio::log.info "Success! $disk mounted to /mnt/$disk" || (bashio::log.fatal "Unable to mount local drives! Please check the name." && rmdir /mnt/$disk) + + done + +fi diff --git a/photoprism/rootfs/scripts/92-smb_mounts.sh b/photoprism/rootfs/scripts/92-smb_mounts.sh new file mode 100644 index 000000000..06410e554 --- /dev/null +++ b/photoprism/rootfs/scripts/92-smb_mounts.sh @@ -0,0 +1,83 @@ +#!/usr/bin/with-contenv bashio + +######################### +# MOUNT SMB SHARES v1.6 # +######################### +if bashio::config.has_value 'networkdisks'; then + + # Define variables + MOREDISKS=$(bashio::config 'networkdisks') + CIFS_USERNAME=$(bashio::config 'cifsusername') + CIFS_PASSWORD=$(bashio::config 'cifspassword') + MOUNTED=false + SMBVERS="" + SECVERS="" + + # Mount CIFS Share if configured and if Protection Mode is active + echo 'Mounting smb share(s)...' + + if bashio::config.has_value 'cifsdomain'; then + DOMAIN=",domain=$(bashio::config 'cifsdomain')" + else + DOMAIN="" + fi + + # Mounting disks + for disk in ${MOREDISKS//,/ }; do # Separate comma separated values + + # Clean name of network share + disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name + diskname=${disk//\\//} #replace \ with / + diskname=${diskname##*/} # Get only last part of the name + + # Data validation + if [[ ! $disk =~ ^.*+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[/]+.*+$ ]]; then + bashio::log.fatal "The structure of your \"networkdisks\" option : \"$disk\" doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2. If you don't use it, you can simply remove the text, this will avoid this error message in the future." + exit 0 + fi + + # Prepare mount point + mkdir -p /mnt/$diskname + chown -R root:root /mnt/$diskname + + #Tries to mount with default options + mount -t cifs -o rw,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname 2>ERRORCODE && MOUNTED=true || MOUNTED=false + + # if Fail test different smb and sec versions + if [ $MOUNTED = false ]; then + for SMBVERS in ",vers=3" ",vers=1.0" ",vers=2.1" ",vers=3.0" ",nodfs" ",uid=0,gid=0,forceuid,forcegid" ",noforceuid,noforcegid" ",${DOMAIN:-WORKGROUP}"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS $disk /mnt/$diskname 2>/dev/null && MOUNTED=true && break || MOUNTED=false + for SECVERS in ",sec=ntlmi" ",sec=ntlmv2" ",sec=ntlmv2i" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=ntlm" ",sec=krb5i" ",sec=krb5" ",iocharset=utf8"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS$SECVERS $disk /mnt/$disk name 2>/dev/null && MOUNTED=true && break 2 && break || MOUNTED=false + done + done + fi + + # Messages + if [ $MOUNTED = true ] && [ "mountpoint -q /mnt/$diskname" ]; then + #Test write permissions + touch /mnt/$diskname/testaze && rm /mnt/$diskname/testaze && + bashio::log.info "... $disk successfully mounted to /mnt/$diskname with options $SMBVERS$SECVERS" || + bashio::log.fatal "Disk is mounted, however unable to write in the shared disk. Please check UID/GID for permissions, and if the share is rw" + + else + # Mounting failed messages + bashio::log.fatal "Error, unable to mount $disk to /mnt/$diskname with username $CIFS_USERNAME, $CIFS_PASSWORD. Please check your remote share path, username, password, domain, try putting 0 in UID and GID" + bashio::log.fatal "Here is some debugging info :" + + # Provide debugging info + smbclient -V &>/dev/null || apt-get install smbclient || apk add --no-cache samba-client + #smbclient $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + smbclient -L $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + + # Error code + bashio::log.fatal "Error read : $(/dev/null || true + rmdir /mnt/$diskname || true + fi + + done +fi diff --git a/photoprism/rootfs/scripts/99-run.sh b/photoprism/rootfs/scripts/99-run.sh new file mode 100644 index 000000000..7bc8615af --- /dev/null +++ b/photoprism/rootfs/scripts/99-run.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bashio + +############## +# LAUNCH APP # +############## + +# Configure app +export PHOTOPRISM_UPLOAD_NSFW=$(bashio::config 'UPLOAD_NSFW') +export PHOTOPRISM_STORAGE_PATH=$(bashio::config 'STORAGE_PATH') +export PHOTOPRISM_ORIGINALS_PATH=$(bashio::config 'ORIGINALS_PATH') +export PHOTOPRISM_IMPORT_PATH=$(bashio::config 'IMPORT_PATH') +export PHOTOPRISM_BACKUP_PATH=$(bashio::config 'BACKUP_PATH') + +if bashio::config.has_value 'CUSTOM_OPTIONS'; then + CUSTOMOPTIONS=$(bashio::config 'CUSTOM_OPTIONS') +else + CUSTOMOPTIONS="" +fi + +# Test configs +for variabletest in $PHOTOPRISM_STORAGE_PATH $PHOTOPRISM_ORIGINALS_PATH $PHOTOPRISM_IMPORT_PATH $PHOTOPRISM_BACKUP_PATH; do + # Check if path exists + if bashio::fs.directory_exists $variabletest; then + true + else + bashio::log.info "Path $variabletest doesn't exist. Creating it now..." + mkdir -p $variabletest || bashio::log.fatal "Can't create $variabletest path" + fi + # Check if path writable + touch $variabletest/aze && rm $variabletest/aze || bashio::log.fatal "$variable path is not writable" +done + +# Start messages +bashio::log.info "Please wait 1 or 2 minutes to allow the server to load" +bashio::log.info 'Default username : admin, default password: "please_change_password"' + +cd / +./entrypoint_photoprism.sh photoprism start '"'$CUSTOMOPTIONS'"' diff --git a/piwigo/CHANGELOG.md b/piwigo/CHANGELOG.md index 0adf39619..2b0ff66c3 100644 --- a/piwigo/CHANGELOG.md +++ b/piwigo/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 12.1.0 (13-11-2021) - Update to latest version from linuxserver/docker-piwigo diff --git a/piwigo/Dockerfile b/piwigo/Dockerfile index f2e9ec040..311ee065e 100644 --- a/piwigo/Dockerfile +++ b/piwigo/Dockerfile @@ -1,50 +1,56 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="jq \ - curl \ - cifs-utils" -# Copy root filesystem -COPY rootfs / - -VOLUME [ "/data" ] - -RUN \ - # Install bashio - apk add --no-cache ${PACKAGES} \ - \ - && curl -J -L -o /tmp/bashio.tar.gz \ - "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - && mkdir /tmp/bashio \ - && tar zxvf \ - /tmp/bashio.tar.gz \ - --strip 1 -C /tmp/bashio \ - \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -fr \ - /tmp/* || true +################## +# 2 Modify Image # +################## RUN \ # Allow UID and GID setting && sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser -# Use subfolder in config -# Protect files starting by config. -# && files=$(grep -rl '/config.' /etc/cont-init.d/*) && echo $files | xargs sed -i 's|/config.|/temptemp.|g' \ -# && files=$(grep -rl '/config' /defaults/*) && echo $files | xargs sed -i 's|/config|/share/piwigo|g' \ -# && files=$(grep -rl '/config' /etc/cont-init.d/*) && echo $files | xargs sed -i 's|/config|/share/piwigo|g' \ -# && files=$(grep -rl '/temptemp.' /etc/cont-init.d/*) && echo $files | xargs sed -i 's|/temptemp.|/config.|g' -# && files=$(grep -rl "/config/" /etc/services.d/*) && echo $files | xargs sed -i "s|/config/|/share/piwigo|g" -# && files=$(grep -rl " /config" /etc/cont-init.d/*) && echo $files | xargs sed -i "s= /config= /config/piwigo=g" -# && files=$(grep -rl '/data/config.inc.php' /defaults/*) && echo $files | xargs sed -i 's|/data/config.inc.php|/config/config.inc.php|g' || true \ -# && files=$(grep -rl '/data/config.inc.php' /etc/cont-init.d/*) && echo $files | xargs sed -i 's|/data/config.inc.php|/config/config.inc.php|g' \ -# && sed -i '2i cp -vnpr /config/* /data || true' /etc/cont-init.d/00-banner.sh -### LABELS + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + curl \ + cifs-utils" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ + ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/piwigo/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/piwigo/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh index 612e26d7e..4f9ed9c51 100644 --- a/piwigo/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ b/piwigo/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -1,29 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - + ####################### + # Automatic installer # + ####################### + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/plex/CHANGELOG.md b/plex/CHANGELOG.md index fd3718277..1e1d5a54a 100644 --- a/plex/CHANGELOG.md +++ b/plex/CHANGELOG.md @@ -1,4 +1,8 @@ +## 1.25.2.5319-c43dc0277-ls92 (14-12-2021) +- Update to latest version from linuxserver/docker-plex +- New standardized logic for Dockerfile build and packages installation + ## 1.25.1.5286-34f965be8-ls91 (07-12-2021) - Update to latest version from linuxserver/docker-plex - localdisks: sda1 #put the hardware name of your drive to mount separated by commas, or its label. Ex: sda1, sdb1, MYNAS... diff --git a/plex/Dockerfile b/plex/Dockerfile index 3d1a78b03..b7d3b5309 100644 --- a/plex/Dockerfile +++ b/plex/Dockerfile @@ -1,38 +1,18 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} +################## +# 2 Modify Image # +################## + # Set shell SHELL ["/bin/bash", "-o", "pipefail", "-c"] -# copy local files -COPY root/ / - -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="jq \ - cifs-utils \ - keyutils \ - samba \ - smbclient" - -RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio || true - RUN \ ############################# # Allow UID and GID setting # @@ -50,14 +30,44 @@ RUN \ && sed -i 's/with-contenv bash/with-contenv bashio/g' /etc/cont-init.d/45-plex-claim \ && sed -i '2iexport PLEX_CLAIM=$(bashio::config "claim")' /etc/cont-init.d/45-plex-claim \ && sed -i '3i[ $PLEX_CLAIM = "Get_from_https://www.plex.tv/claim" ] && bashio::log.warning "Please change the PLEX_CLAIM code from the options" && exit 1 || true' /etc/cont-init.d/45-plex-claim -########### -# FOLDERS # -########### -# && files=$(grep -rl '/config' /etc/cont-init.d/*) && echo $files | xargs sed -i 's|/config|/data|g' \ -# && sed -i "s|/config|/data|g" /defaults/plexmediaserver \ -# && sed -i '2i cp -vnpr /config /data || true' /etc/cont-init.d/00-banner.sh -### LABELS + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + cifs-utils \ + keyutils \ + samba \ + smbclient" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ + ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/plex/config.json b/plex/config.json index 748daffe5..13a2b69cc 100644 --- a/plex/config.json +++ b/plex/config.json @@ -109,9 +109,9 @@ }, "slug": "plex_nas", "startup": "services", - "upstream": "1.25.1.5286-34f965be8-ls91", + "upstream": "1.25.2.5319-c43dc0277-ls92", "url": "https://github.com/alexbelgium/hassio-addons", - "version": "1.25.1.5286-34f965be8-ls91", + "version": "1.25.2.5319-c43dc0277-ls92", "video": true, "webui": "http://[HOST]:[PORT:32400]/web" } diff --git a/plex/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/plex/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/plex/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/plex/rootfs/etc/cont-init.d/00-banner.sh b/plex/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/plex/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/plex/rootfs/etc/cont-init.d/21-folders b/plex/rootfs/etc/cont-init.d/21-folders new file mode 100644 index 000000000..afb2a6707 --- /dev/null +++ b/plex/rootfs/etc/cont-init.d/21-folders @@ -0,0 +1,26 @@ +#!/usr/bin/with-contenv bash + +################## +# SYMLINK CONFIG # +################## + +echo "Database stored in /share/plex" + +if [ ! -d "/share/plex/Plex Media Server" ]; then +echo "... creating /share/plex/Plex Media Server" +mkdir -p "/share/plex/Plex Media Server" +fi + +if [ -d "/config/Library/Application Support/Plex Media Server" ]; then + echo "... creating /symlink" + rm -r "/config/Library/Application Support/*" + ln -s "/share/plex/Plex Media Server" "/config/Library/Application Support" +fi + +if [ ! -d "/config/Library/Application Support" ]; then + echo "... creating /symlink" + mkdir -p "/config/Library/Application Support" + ln -s "/share/plex/Plex Media Server" "/config/Library/Application Support" +fi + +chown -R abc:abc /share/plex diff --git a/plex/rootfs/etc/cont-init.d/90-create_links b/plex/rootfs/etc/cont-init.d/90-create_links new file mode 100644 index 000000000..8cca2b550 --- /dev/null +++ b/plex/rootfs/etc/cont-init.d/90-create_links @@ -0,0 +1,24 @@ +#!/usr/bin/with-contenv bash + +################## +# SYMLINK CONFIG # +################## + +if [ ! -d /share/plex ]; then + echo "Creating /share/plex" + mkdir -p /share/plex + chown -R abc:abc /share/plex +else + chown -R abc:abc /share/plex +fi + +if [ ! -d /share/plex/Library ]; then + echo "moving Library folder" + mv /config/Library /share/plex + ln -s /share/plex/Library /config + echo "links done" +else + rm -r /config/Library + ln -s /share/plex/Library /config + echo "Using existing config" +fi diff --git a/plex/rootfs/etc/cont-init.d/92-local_mounts.sh b/plex/rootfs/etc/cont-init.d/92-local_mounts.sh new file mode 100644 index 000000000..0920d68bd --- /dev/null +++ b/plex/rootfs/etc/cont-init.d/92-local_mounts.sh @@ -0,0 +1,32 @@ +#!/usr/bin/with-contenv bashio + +###################### +# MOUNT LOCAL SHARES # +###################### + +# Mount local Share if configured +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + echo "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + + # Mount by device as default + devpath=/dev + + # Mount as label + [ ${disk:0:2} != "sd" ] && devpath=/dev/disk/by-label + + # Creates dir + mkdir -p /mnt/$disk + chown -R $(id -u):$(id -g) /mnt/$disk + # Legacy mounting : mount to share if still exists (avoid breaking changes) + [ -d /share/$disk ] && mount $devpath/$disk /share/$disk || true + # Mount + mount $devpath/$disk /mnt/$disk && bashio::log.info "Success! $disk mounted to /mnt/$disk" || (bashio::log.fatal "Unable to mount local drives! Please check the name." && rmdir /mnt/$disk) + + done + +fi diff --git a/plex/rootfs/etc/cont-init.d/92-smb_mounts.sh b/plex/rootfs/etc/cont-init.d/92-smb_mounts.sh new file mode 100644 index 000000000..06410e554 --- /dev/null +++ b/plex/rootfs/etc/cont-init.d/92-smb_mounts.sh @@ -0,0 +1,83 @@ +#!/usr/bin/with-contenv bashio + +######################### +# MOUNT SMB SHARES v1.6 # +######################### +if bashio::config.has_value 'networkdisks'; then + + # Define variables + MOREDISKS=$(bashio::config 'networkdisks') + CIFS_USERNAME=$(bashio::config 'cifsusername') + CIFS_PASSWORD=$(bashio::config 'cifspassword') + MOUNTED=false + SMBVERS="" + SECVERS="" + + # Mount CIFS Share if configured and if Protection Mode is active + echo 'Mounting smb share(s)...' + + if bashio::config.has_value 'cifsdomain'; then + DOMAIN=",domain=$(bashio::config 'cifsdomain')" + else + DOMAIN="" + fi + + # Mounting disks + for disk in ${MOREDISKS//,/ }; do # Separate comma separated values + + # Clean name of network share + disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name + diskname=${disk//\\//} #replace \ with / + diskname=${diskname##*/} # Get only last part of the name + + # Data validation + if [[ ! $disk =~ ^.*+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[/]+.*+$ ]]; then + bashio::log.fatal "The structure of your \"networkdisks\" option : \"$disk\" doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2. If you don't use it, you can simply remove the text, this will avoid this error message in the future." + exit 0 + fi + + # Prepare mount point + mkdir -p /mnt/$diskname + chown -R root:root /mnt/$diskname + + #Tries to mount with default options + mount -t cifs -o rw,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname 2>ERRORCODE && MOUNTED=true || MOUNTED=false + + # if Fail test different smb and sec versions + if [ $MOUNTED = false ]; then + for SMBVERS in ",vers=3" ",vers=1.0" ",vers=2.1" ",vers=3.0" ",nodfs" ",uid=0,gid=0,forceuid,forcegid" ",noforceuid,noforcegid" ",${DOMAIN:-WORKGROUP}"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS $disk /mnt/$diskname 2>/dev/null && MOUNTED=true && break || MOUNTED=false + for SECVERS in ",sec=ntlmi" ",sec=ntlmv2" ",sec=ntlmv2i" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=ntlm" ",sec=krb5i" ",sec=krb5" ",iocharset=utf8"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS$SECVERS $disk /mnt/$disk name 2>/dev/null && MOUNTED=true && break 2 && break || MOUNTED=false + done + done + fi + + # Messages + if [ $MOUNTED = true ] && [ "mountpoint -q /mnt/$diskname" ]; then + #Test write permissions + touch /mnt/$diskname/testaze && rm /mnt/$diskname/testaze && + bashio::log.info "... $disk successfully mounted to /mnt/$diskname with options $SMBVERS$SECVERS" || + bashio::log.fatal "Disk is mounted, however unable to write in the shared disk. Please check UID/GID for permissions, and if the share is rw" + + else + # Mounting failed messages + bashio::log.fatal "Error, unable to mount $disk to /mnt/$diskname with username $CIFS_USERNAME, $CIFS_PASSWORD. Please check your remote share path, username, password, domain, try putting 0 in UID and GID" + bashio::log.fatal "Here is some debugging info :" + + # Provide debugging info + smbclient -V &>/dev/null || apt-get install smbclient || apk add --no-cache samba-client + #smbclient $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + smbclient -L $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + + # Error code + bashio::log.fatal "Error read : $(/dev/null || true + rmdir /mnt/$diskname || true + fi + + done +fi diff --git a/portainer/CHANGELOG.md b/portainer/CHANGELOG.md index 3afb43cf5..f75560a0c 100644 --- a/portainer/CHANGELOG.md +++ b/portainer/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 2.11.0 (09-12-2021) - Update to latest version from portainer/portainer diff --git a/portainer/Dockerfile b/portainer/Dockerfile index f575ddf29..1aad2aed6 100644 --- a/portainer/Dockerfile +++ b/portainer/Dockerfile @@ -1,14 +1,20 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM=ghcr.io/hassio-addons/base/amd64:9.2.0 -# hadolint ignore=DL3006 FROM ${BUILD_FROM} +################## +# 2 Modify Image # +################## + # Set shell SHELL ["/bin/bash", "-o", "pipefail", "-c"] # Setup base ARG BUILD_ARCH=amd64 ARG BUILD_UPSTREAM="2.11.0" -ENV PACKAGES="nginx" RUN \ if [ "${BUILD_ARCH}" = "aarch64" ]; then ARCH="arm64"; fi \ @@ -20,13 +26,38 @@ RUN \ "https://github.com/portainer/portainer/releases/download/${BUILD_UPSTREAM}/portainer-${BUILD_UPSTREAM}-linux-${ARCH}.tar.gz" \ | tar zxvf - -C /opt/ -RUN \ - apk add --no-cache ${PACKAGES} || true +################## +# 3 Install apps # +################## -# Copy root filesystem -COPY rootfs / +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="nginx" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/portainer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/portainer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh index 612e26d7e..4f9ed9c51 100644 --- a/portainer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ b/portainer/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -1,29 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - + ####################### + # Automatic installer # + ####################### + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/prowlarr/CHANGELOG.md b/prowlarr/CHANGELOG.md index 7e164722d..cdbf54a11 100644 --- a/prowlarr/CHANGELOG.md +++ b/prowlarr/CHANGELOG.md @@ -1,4 +1,11 @@ +## nightly-0.1.8.1253-ls229 (14-12-2021) +- Update to latest version from linuxserver/docker-prowlarr + +## nightly-0.1.8.1238-ls228 (12-12-2021) +- Update to latest version from linuxserver/docker-prowlarr +- New standardized logic for Dockerfile build and packages installation + ## nightly-0.1.8.1232-ls226 (10-12-2021) - Update to latest version from linuxserver/docker-prowlarr diff --git a/prowlarr/Dockerfile b/prowlarr/Dockerfile index 59efa0590..b35361e06 100644 --- a/prowlarr/Dockerfile +++ b/prowlarr/Dockerfile @@ -1,38 +1,18 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="jq \ - curl \ - cifs-utils \ - keyutils \ - samba \ - smbclient" + +################## +# 2 Modify Image # +################## RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################### - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio \ - \ - ######################################## - # Correct upstream image folders links # - ######################################## - \ # Allow UID and GID setting - && sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ + sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser \ \ @@ -41,10 +21,43 @@ RUN \ && sed -i 's= /config=/config/prowlarr || true=g' /etc/cont-init.d/30-config \ && sed -i 's|/config|/config/prowlarr|g' /etc/services.d/prowlarr/run -# copy local files -COPY root/ / +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + curl \ + cifs-utils \ + keyutils \ + samba \ + smbclient" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/prowlarr/config.json b/prowlarr/config.json index 9d0e0683c..5261eee03 100644 --- a/prowlarr/config.json +++ b/prowlarr/config.json @@ -47,8 +47,8 @@ }, "slug": "prowlarr", "startup": "services", - "upstream": "nightly-0.1.8.1232-ls226", + "upstream": "nightly-0.1.8.1253-ls229", "url": "https://github.com/alexbelgium/hassio-addons", - "version": "nightly-0.1.8.1232-ls226", + "version": "nightly-0.1.8.1253-ls229", "webui": "http://[HOST]:[PORT:9696]" } diff --git a/prowlarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/prowlarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/prowlarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/prowlarr/rootfs/etc/cont-init.d/00-banner.sh b/prowlarr/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/prowlarr/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/prowlarr/rootfs/etc/cont-init.d/00-ha-env b/prowlarr/rootfs/etc/cont-init.d/00-ha-env new file mode 100644 index 000000000..3b3e69246 --- /dev/null +++ b/prowlarr/rootfs/etc/cont-init.d/00-ha-env @@ -0,0 +1,5 @@ +#!/usr/bin/with-contenv bashio + +for k in $(bashio::jq "${__BASHIO_ADDON_CONFIG}" 'keys | .[]'); do + printf "$(bashio::config $k)" > /var/run/s6/container_environment/$k +done \ No newline at end of file diff --git a/prowlarr/rootfs/etc/cont-init.d/20-folders b/prowlarr/rootfs/etc/cont-init.d/20-folders new file mode 100644 index 000000000..a40d5c92e --- /dev/null +++ b/prowlarr/rootfs/etc/cont-init.d/20-folders @@ -0,0 +1,7 @@ +#!/usr/bin/with-contenv bash + +if [ ! -d /config/prowlarr ]; then + echo "Creating /config/radarr" + mkdir -p /config/prowlarr + chown -R abc:abc /config/prowlarr +fi diff --git a/prowlarr/rootfs/etc/cont-init.d/92-smb_mounts.sh b/prowlarr/rootfs/etc/cont-init.d/92-smb_mounts.sh new file mode 100644 index 000000000..06410e554 --- /dev/null +++ b/prowlarr/rootfs/etc/cont-init.d/92-smb_mounts.sh @@ -0,0 +1,83 @@ +#!/usr/bin/with-contenv bashio + +######################### +# MOUNT SMB SHARES v1.6 # +######################### +if bashio::config.has_value 'networkdisks'; then + + # Define variables + MOREDISKS=$(bashio::config 'networkdisks') + CIFS_USERNAME=$(bashio::config 'cifsusername') + CIFS_PASSWORD=$(bashio::config 'cifspassword') + MOUNTED=false + SMBVERS="" + SECVERS="" + + # Mount CIFS Share if configured and if Protection Mode is active + echo 'Mounting smb share(s)...' + + if bashio::config.has_value 'cifsdomain'; then + DOMAIN=",domain=$(bashio::config 'cifsdomain')" + else + DOMAIN="" + fi + + # Mounting disks + for disk in ${MOREDISKS//,/ }; do # Separate comma separated values + + # Clean name of network share + disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name + diskname=${disk//\\//} #replace \ with / + diskname=${diskname##*/} # Get only last part of the name + + # Data validation + if [[ ! $disk =~ ^.*+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[/]+.*+$ ]]; then + bashio::log.fatal "The structure of your \"networkdisks\" option : \"$disk\" doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2. If you don't use it, you can simply remove the text, this will avoid this error message in the future." + exit 0 + fi + + # Prepare mount point + mkdir -p /mnt/$diskname + chown -R root:root /mnt/$diskname + + #Tries to mount with default options + mount -t cifs -o rw,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname 2>ERRORCODE && MOUNTED=true || MOUNTED=false + + # if Fail test different smb and sec versions + if [ $MOUNTED = false ]; then + for SMBVERS in ",vers=3" ",vers=1.0" ",vers=2.1" ",vers=3.0" ",nodfs" ",uid=0,gid=0,forceuid,forcegid" ",noforceuid,noforcegid" ",${DOMAIN:-WORKGROUP}"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS $disk /mnt/$diskname 2>/dev/null && MOUNTED=true && break || MOUNTED=false + for SECVERS in ",sec=ntlmi" ",sec=ntlmv2" ",sec=ntlmv2i" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=ntlm" ",sec=krb5i" ",sec=krb5" ",iocharset=utf8"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS$SECVERS $disk /mnt/$disk name 2>/dev/null && MOUNTED=true && break 2 && break || MOUNTED=false + done + done + fi + + # Messages + if [ $MOUNTED = true ] && [ "mountpoint -q /mnt/$diskname" ]; then + #Test write permissions + touch /mnt/$diskname/testaze && rm /mnt/$diskname/testaze && + bashio::log.info "... $disk successfully mounted to /mnt/$diskname with options $SMBVERS$SECVERS" || + bashio::log.fatal "Disk is mounted, however unable to write in the shared disk. Please check UID/GID for permissions, and if the share is rw" + + else + # Mounting failed messages + bashio::log.fatal "Error, unable to mount $disk to /mnt/$diskname with username $CIFS_USERNAME, $CIFS_PASSWORD. Please check your remote share path, username, password, domain, try putting 0 in UID and GID" + bashio::log.fatal "Here is some debugging info :" + + # Provide debugging info + smbclient -V &>/dev/null || apt-get install smbclient || apk add --no-cache samba-client + #smbclient $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + smbclient -L $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + + # Error code + bashio::log.fatal "Error read : $(/dev/null || true + rmdir /mnt/$diskname || true + fi + + done +fi diff --git a/qbittorrent/CHANGELOG.md b/qbittorrent/CHANGELOG.md index 12a8d0cac..35eb5e419 100644 --- a/qbittorrent/CHANGELOG.md +++ b/qbittorrent/CHANGELOG.md @@ -1,3 +1,6 @@ +- Removed watchdog +- New standardized logic for Dockerfile build and packages installation +- Allow mounting nvme - Allow mounting local drives by label. Just pust the label instead of sda1 for example ## 14.3.9.99202110311443-7435-01519b5e7ubuntu20.04.1-ls159 (31-10-2021) diff --git a/qbittorrent/Dockerfile b/qbittorrent/Dockerfile index 1710c7e53..af4977373 100644 --- a/qbittorrent/Dockerfile +++ b/qbittorrent/Dockerfile @@ -1,14 +1,14 @@ -############### -# Build Image # -############### +################# +# 1 Build Image # +################# ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -################ -# Modify Image # -################ +################## +# 2 Modify Image # +################## # Environment variables ENV \ @@ -20,9 +20,6 @@ ENV \ TERM="xterm-256color" RUN \ - ######################################## - # Correct upstream image folders links # - ######################################## # Allow UID and GID setting sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ @@ -40,9 +37,9 @@ RUN \ && echo 'WebUI\HostHeaderValidation=false' >> /defaults/qBittorrent.conf \ && echo 'WebUI\LocalHostAuth=false' >> /defaults/qBittorrent.conf || true -################ -# Install apps # -################ +################## +# 3 Install apps # +################## # Copy local files COPY rootfs/ / @@ -58,20 +55,20 @@ ENV PACKAGES="jq \ openvpn" # Automatic apps & bashio -RUN $(ls /bin/bash &>/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl || apk add --no-cache curl) && \ +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); 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); fi && \ curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ chmod 777 /automatic_packages.sh && \ /automatic_packages.sh "${PACKAGES:-}" && \ rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE -############## -# Entrypoint # -############## +################ +# 4 Entrypoint # +################ -########## -# Labels # -########## +############ +# 5 Labels # +############ ARG BUILD_ARCH ARG BUILD_DATE diff --git a/qbittorrent/config.json b/qbittorrent/config.json index 36571c8d9..2354f2f2d 100644 --- a/qbittorrent/config.json +++ b/qbittorrent/config.json @@ -98,7 +98,6 @@ "slug": "qbittorrent", "upstream": "14.3.9.99202110311443-7435-01519b5e7ubuntu20.04.1-ls159", "url": "https://github.com/alexbelgium/hassio-addons", - "version": "14.3.9.99202110311443-7435-01519b5e7ubuntu20.04.1-ls160", - "watchdog": "[PROTO:ssl]://[HOST]:[PORT:8080]", + "version": "14.3.9.99202110311443-7435-01519b5e7ubuntu20.04.1-ls160-2", "webui": "[PROTO:ssl]://[HOST]:[PORT:8080]" } diff --git a/qbittorrent/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/qbittorrent/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh index e33f7f063..187df42f7 100644 --- a/qbittorrent/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ b/qbittorrent/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -2,14 +2,14 @@ # If dockerfile failed install manually if [ -e "/ENVFILE" ]; then echo "Executing script" - PACKAGES=$(< /ENVFILE) + PACKAGES=$(/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl &>/dev/null || apk add --no-cache curl) && \ - curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + 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); fi && \ + $(curl --help &>/dev/null) || (apt-get update && apt-get install -yqq --no-install-recommends curl &>/dev/null || apk add --no-cache curl) && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ chmod 777 /automatic_packages.sh && \ eval /./automatic_packages.sh "$PACKAGES" && \ rm /automatic_packages.sh diff --git a/radarr/CHANGELOG.md b/radarr/CHANGELOG.md index a7a3d6190..af078aef5 100644 --- a/radarr/CHANGELOG.md +++ b/radarr/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation - Allow mounting local drives by label. Just pust the label instead of sda1 for example - Improve SMB mount code to v1.5 ; accepts several network disks separated by commas (//123.12.12.12/share,//123.12.12.12/hello) that are mount to /mnt/$sharename - Breaking changes : multiple network disks must be separated by a "," and they are mounted to a folder with the name of the external share. diff --git a/radarr/Dockerfile b/radarr/Dockerfile index ea95c9f49..a728b068c 100644 --- a/radarr/Dockerfile +++ b/radarr/Dockerfile @@ -1,31 +1,14 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="jq \ - curl \ - cifs-utils \ - keyutils \ - samba \ - smbclient" -RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################### - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio || true +################## +# 2 Modify Image # +################## RUN \ # use /data instead of /config for hass.io environment @@ -37,10 +20,45 @@ RUN \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser -# copy local files -COPY root/ / -### LABELS +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV BASHIO_VERSION=0.14.3 +ENV PACKAGES="jq \ + curl \ + cifs-utils \ + keyutils \ + samba \ + smbclient" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ + ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/radarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/radarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/radarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/radarr/rootfs/etc/cont-init.d/00-banner.sh b/radarr/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/radarr/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/radarr/rootfs/etc/cont-init.d/00-ha-env b/radarr/rootfs/etc/cont-init.d/00-ha-env new file mode 100644 index 000000000..d0b511f60 --- /dev/null +++ b/radarr/rootfs/etc/cont-init.d/00-ha-env @@ -0,0 +1,5 @@ +#!/usr/bin/with-contenv bashio + +for k in $(bashio::jq "${__BASHIO_ADDON_CONFIG}" 'keys | .[]'); do + printf "$(bashio::config $k)" >/var/run/s6/container_environment/$k +done diff --git a/radarr/rootfs/etc/cont-init.d/20-folders b/radarr/rootfs/etc/cont-init.d/20-folders new file mode 100644 index 000000000..9fcadd756 --- /dev/null +++ b/radarr/rootfs/etc/cont-init.d/20-folders @@ -0,0 +1,19 @@ +#!/usr/bin/with-contenv bash + +if [ ! -d /share/storage/movies ]; then + echo "Creating /share/storage/movies" + mkdir -p /share/storage/movies + chown -R abc:abc /share/storage/movies +fi + +if [ ! -d /share/downloads ]; then + echo "Creating /share/downloads" + mkdir -p /share/downloads + chown -R abc:abc /share/downloads +fi + +if [ ! -d /config/radarr ]; then + echo "Creating /config/radarr" + mkdir -p /config/radarr + chown -R abc:abc /config/radarr +fi diff --git a/radarr/rootfs/etc/cont-init.d/92-local_mounts.sh b/radarr/rootfs/etc/cont-init.d/92-local_mounts.sh new file mode 100644 index 000000000..0920d68bd --- /dev/null +++ b/radarr/rootfs/etc/cont-init.d/92-local_mounts.sh @@ -0,0 +1,32 @@ +#!/usr/bin/with-contenv bashio + +###################### +# MOUNT LOCAL SHARES # +###################### + +# Mount local Share if configured +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + echo "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + + # Mount by device as default + devpath=/dev + + # Mount as label + [ ${disk:0:2} != "sd" ] && devpath=/dev/disk/by-label + + # Creates dir + mkdir -p /mnt/$disk + chown -R $(id -u):$(id -g) /mnt/$disk + # Legacy mounting : mount to share if still exists (avoid breaking changes) + [ -d /share/$disk ] && mount $devpath/$disk /share/$disk || true + # Mount + mount $devpath/$disk /mnt/$disk && bashio::log.info "Success! $disk mounted to /mnt/$disk" || (bashio::log.fatal "Unable to mount local drives! Please check the name." && rmdir /mnt/$disk) + + done + +fi diff --git a/radarr/rootfs/etc/cont-init.d/92-smb_mounts.sh b/radarr/rootfs/etc/cont-init.d/92-smb_mounts.sh new file mode 100644 index 000000000..06410e554 --- /dev/null +++ b/radarr/rootfs/etc/cont-init.d/92-smb_mounts.sh @@ -0,0 +1,83 @@ +#!/usr/bin/with-contenv bashio + +######################### +# MOUNT SMB SHARES v1.6 # +######################### +if bashio::config.has_value 'networkdisks'; then + + # Define variables + MOREDISKS=$(bashio::config 'networkdisks') + CIFS_USERNAME=$(bashio::config 'cifsusername') + CIFS_PASSWORD=$(bashio::config 'cifspassword') + MOUNTED=false + SMBVERS="" + SECVERS="" + + # Mount CIFS Share if configured and if Protection Mode is active + echo 'Mounting smb share(s)...' + + if bashio::config.has_value 'cifsdomain'; then + DOMAIN=",domain=$(bashio::config 'cifsdomain')" + else + DOMAIN="" + fi + + # Mounting disks + for disk in ${MOREDISKS//,/ }; do # Separate comma separated values + + # Clean name of network share + disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name + diskname=${disk//\\//} #replace \ with / + diskname=${diskname##*/} # Get only last part of the name + + # Data validation + if [[ ! $disk =~ ^.*+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[/]+.*+$ ]]; then + bashio::log.fatal "The structure of your \"networkdisks\" option : \"$disk\" doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2. If you don't use it, you can simply remove the text, this will avoid this error message in the future." + exit 0 + fi + + # Prepare mount point + mkdir -p /mnt/$diskname + chown -R root:root /mnt/$diskname + + #Tries to mount with default options + mount -t cifs -o rw,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname 2>ERRORCODE && MOUNTED=true || MOUNTED=false + + # if Fail test different smb and sec versions + if [ $MOUNTED = false ]; then + for SMBVERS in ",vers=3" ",vers=1.0" ",vers=2.1" ",vers=3.0" ",nodfs" ",uid=0,gid=0,forceuid,forcegid" ",noforceuid,noforcegid" ",${DOMAIN:-WORKGROUP}"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS $disk /mnt/$diskname 2>/dev/null && MOUNTED=true && break || MOUNTED=false + for SECVERS in ",sec=ntlmi" ",sec=ntlmv2" ",sec=ntlmv2i" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=ntlm" ",sec=krb5i" ",sec=krb5" ",iocharset=utf8"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS$SECVERS $disk /mnt/$disk name 2>/dev/null && MOUNTED=true && break 2 && break || MOUNTED=false + done + done + fi + + # Messages + if [ $MOUNTED = true ] && [ "mountpoint -q /mnt/$diskname" ]; then + #Test write permissions + touch /mnt/$diskname/testaze && rm /mnt/$diskname/testaze && + bashio::log.info "... $disk successfully mounted to /mnt/$diskname with options $SMBVERS$SECVERS" || + bashio::log.fatal "Disk is mounted, however unable to write in the shared disk. Please check UID/GID for permissions, and if the share is rw" + + else + # Mounting failed messages + bashio::log.fatal "Error, unable to mount $disk to /mnt/$diskname with username $CIFS_USERNAME, $CIFS_PASSWORD. Please check your remote share path, username, password, domain, try putting 0 in UID and GID" + bashio::log.fatal "Here is some debugging info :" + + # Provide debugging info + smbclient -V &>/dev/null || apt-get install smbclient || apk add --no-cache samba-client + #smbclient $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + smbclient -L $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + + # Error code + bashio::log.fatal "Error read : $(/dev/null || true + rmdir /mnt/$diskname || true + fi + + done +fi diff --git a/readarr/CHANGELOG.md b/readarr/CHANGELOG.md index c7ff437ae..5761a44d1 100644 --- a/readarr/CHANGELOG.md +++ b/readarr/CHANGELOG.md @@ -1,3 +1,7 @@ + +## nightly-0.1.0.1117-ls52 (12-12-2021) +- Update to latest version from linuxserver/docker-readarr +- New standardized logic for Dockerfile build and packages installation - Allow to define the config location ## nightly-0.1.0.1095-ls51 (09-12-2021) diff --git a/readarr/Dockerfile b/readarr/Dockerfile index 05b184403..fc75c8b4c 100644 --- a/readarr/Dockerfile +++ b/readarr/Dockerfile @@ -1,15 +1,15 @@ -############### -# Build Image # -############### +################# +# 1 Build Image # +################# ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} ENV BASHIO_VERSION=0.14.3 -################ -# Modify Image # -################ +################## +# 2 Modify Image # +################## RUN sed -i "s|/config|/config/readarr|g" /etc/services.d/readarr/run \ && sed -i "s|/config|/config/readarr|g" /etc/cont-init.d/30-config \ @@ -19,9 +19,9 @@ RUN sed -i "s|/config|/config/readarr|g" /etc/services.d/readarr/run \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser -################ -# Install apps # -################ +################## +# 3 Install apps # +################## # Copy local files COPY rootfs/ / @@ -30,25 +30,25 @@ COPY rootfs/ / ENV PACKAGES="" # Automatic apps & bashio -RUN $(ls /bin/bash &>/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl || apk add --no-cache curl) && \ +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); 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); fi && \ curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ chmod 777 /automatic_packages.sh && \ /automatic_packages.sh "${PACKAGES:-}" && \ rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE - -############## -# Entrypoint # -############## + +################ +# 4 Entrypoint # +################ #RUN chmod 777 /entrypoint.sh #WORKDIR / #ENTRYPOINT [ "/usr/bin/env" ] #CMD [ "/entrypoint.sh" ] - -########## -# Labels # -########## + +############ +# 5 Labels # +############ ARG BUILD_ARCH ARG BUILD_DATE diff --git a/readarr/config.json b/readarr/config.json index 48f6a0a59..32896897b 100644 --- a/readarr/config.json +++ b/readarr/config.json @@ -73,8 +73,8 @@ "CONFIG_LOCATION": "str" }, "slug": "readarr_nas", - "upstream": "nightly-0.1.0.1095-ls51", + "upstream": "nightly-0.1.0.1117-ls52", "url": "https://github.com/alexbelgium/hassio-addons", - "version": "nightly-0.1.0.1095-ls51-4", + "version": "nightly-0.1.0.1117-ls52", "webui": "http://[HOST]:[PORT:8787]" } diff --git a/readarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/readarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh index e33f7f063..4f9ed9c51 100644 --- a/readarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ b/readarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -2,18 +2,17 @@ # If dockerfile failed install manually if [ -e "/ENVFILE" ]; then echo "Executing script" - PACKAGES=$(< /ENVFILE) + PACKAGES=$(/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl &>/dev/null || apk add --no-cache curl) && \ - curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ - chmod 777 /automatic_packages.sh && \ - eval /./automatic_packages.sh "$PACKAGES" && \ - rm /automatic_packages.sh - + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/requestrr/CHANGELOG.md b/requestrr/CHANGELOG.md index 71f658149..0fb9302ca 100644 --- a/requestrr/CHANGELOG.md +++ b/requestrr/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 2.1.1 (15-10-2021) - Update to latest version from linuxserver/docker-requestrr diff --git a/requestrr/Dockerfile b/requestrr/Dockerfile index f7432f6b0..c423dd8bd 100644 --- a/requestrr/Dockerfile +++ b/requestrr/Dockerfile @@ -1,34 +1,18 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="jq \ - curl \ - cifs-utils \ - keyutils \ - samba \ - smbclient" + +################## +# 2 Modify Image # +################## RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio \ - \ # use /data instead of /config for hass.io environment - && sed -i "s|/config|/data|g" /etc/services.d/requestrr/run \ + sed -i "s|/config|/data|g" /etc/services.d/requestrr/run \ && sed -i "s|/config|/data|g" /etc/cont-init.d/30-config \ \ # Allow UID and GID setting @@ -36,10 +20,43 @@ RUN \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser -# copy local files -COPY root/ / +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + curl \ + cifs-utils \ + keyutils \ + samba \ + smbclient" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/requestrr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/requestrr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/requestrr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/requestrr/rootfs/etc/cont-init.d/00-banner.sh b/requestrr/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/requestrr/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/requestrr/rootfs/etc/cont-init.d/00-ha-env b/requestrr/rootfs/etc/cont-init.d/00-ha-env new file mode 100644 index 000000000..342068f41 --- /dev/null +++ b/requestrr/rootfs/etc/cont-init.d/00-ha-env @@ -0,0 +1,5 @@ +#!/usr/bin/with-contenv bashio + +for k in $(bashio::jq "${__BASHIO_ADDON_CONFIG}" 'keys | .[]'); do + printf "$(bashio::config $k)" > /var/run/s6/container_environment/$k +done diff --git a/resiliosync/CHANGELOG.md b/resiliosync/CHANGELOG.md index 111d2751b..f71437092 100644 --- a/resiliosync/CHANGELOG.md +++ b/resiliosync/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation - Add local & smb mounts (see readme) - Config changed from /config/resiliosync to /share/resiliosync_config diff --git a/resiliosync/Dockerfile b/resiliosync/Dockerfile index b61fbed9c..f0c0ea59a 100644 --- a/resiliosync/Dockerfile +++ b/resiliosync/Dockerfile @@ -1,36 +1,15 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="jq \ - curl \ - cifs-utils \ - keyutils \ - samba \ - smbclient" -RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && curl -J -L -o /tmp/bashio.tar.gz \ - "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - && mkdir /tmp/bashio \ - && tar zxvf \ - /tmp/bashio.tar.gz \ - --strip 1 -C /tmp/bashio \ - \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -fr \ - /tmp/* + +################## +# 2 Modify Image # +################## RUN \ ############### @@ -51,12 +30,43 @@ RUN \ && grep -rl " /sync" /etc/cont-init.d | xargs sed -i 's| /sync| /share/resiliosync|g' || true \ && sed -i 's=/sync/=/share/resiliosync/=g' /defaults/* -# Copy root filesystem -COPY rootfs / +################## +# 3 Install apps # +################## -VOLUME [ "/data" ] +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + curl \ + cifs-utils \ + keyutils \ + samba \ + smbclient" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/resiliosync/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/resiliosync/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh index 612e26d7e..4f9ed9c51 100644 --- a/resiliosync/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ b/resiliosync/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -1,29 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - + ####################### + # Automatic installer # + ####################### + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/scrutiny/CHANGELOG.md b/scrutiny/CHANGELOG.md index 48a50a9be..a7d46134e 100644 --- a/scrutiny/CHANGELOG.md +++ b/scrutiny/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation - Added : "/dev/nvme0" ## 0.3.13 (26-10-2021) diff --git a/scrutiny/Dockerfile b/scrutiny/Dockerfile index 19e641ab1..200ef9a52 100644 --- a/scrutiny/Dockerfile +++ b/scrutiny/Dockerfile @@ -1,31 +1,14 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -# Copy root filesystem -COPY rootfs / - -# Base system -ENV BASHIO_VERSION=0.14.3 -ARG BUILD_ARCH -ENV PACKAGES="jq \ - curl \ - cifs-utils \ - nginx" - -RUN \ - # Add apps - apk add --no-cache ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio || true +################## +# 2 Modify Image # +################## RUN \ # Install script @@ -35,23 +18,49 @@ RUN \ && sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser \ - # Correct visualization bug on mobile - # && sed -i 's|content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0"|content="width=980, initial-scale=1.0"|g' /app/scrutiny-web/index.html \ # use /data instead of /config for database && sed -i 's| /config| /data|g' /defaults/scrutiny.yaml \ && sed -i 's| /config| /data|g' /etc/cont-init.d/* \ && sed -i 's| /config| /data|g' /etc/logrotate.d/scrutiny \ && sed -i 's| /config| /data|g' /etc/crontabs/root \ - # analyse local devices at reboot - # && sed -i '$d' /etc/crontabs/root \ - # && sed -i -e '$a @reboot /run.sh' /etc/crontabs/root \ - # && sed -i -e '$a 0 * * * * /run.sh' /etc/crontabs/root \ # correct url paths && grep -rl '/web/' /app/scrutiny-web/ | xargs sed -i 's|/web/|./|g' -VOLUME [ "/data" ] +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + curl \ + cifs-utils \ + nginx" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/scrutiny/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/scrutiny/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh index 612e26d7e..4f9ed9c51 100644 --- a/scrutiny/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ b/scrutiny/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -1,29 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - + ####################### + # Automatic installer # + ####################### + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/sonarr/CHANGELOG.md b/sonarr/CHANGELOG.md index d29530e56..0e87ee67b 100644 --- a/sonarr/CHANGELOG.md +++ b/sonarr/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation - Allow mounting local drives by label. Just pust the label instead of sda1 for example - Allow mounting local drives by label. Just pust the label instead of sda1 for example - Improve SMB mount code to v1.5 ; accepts several network disks separated by commas (//123.12.12.12/share,//123.12.12.12/hello) that are mount to /mnt/$sharename diff --git a/sonarr/Dockerfile b/sonarr/Dockerfile index 6576aeb86..317982dd9 100644 --- a/sonarr/Dockerfile +++ b/sonarr/Dockerfile @@ -1,35 +1,19 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION ARG BUILD_UPSTREAM="3.0.6.1342" FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="jq \ - curl \ - cifs-utils \ - keyutils \ - samba \ - smbclient" + +################## +# 2 Modify Image # +################## RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio \ - \ # use /data instead of /config for hass.io environment - && sed -i "s|/config|/config/sonarr|g" /etc/services.d/sonarr/run \ + sed -i "s|/config|/config/sonarr|g" /etc/services.d/sonarr/run \ && sed -i "s|/config|/config/sonarr|g" /etc/cont-init.d/30-config \ \ # Allow UID and GID setting @@ -37,10 +21,43 @@ RUN \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser -# copy local files -COPY root/ / +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="jq \ + curl \ + cifs-utils \ + keyutils \ + samba \ + smbclient" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/sonarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/sonarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/sonarr/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/sonarr/rootfs/etc/cont-init.d/00-banner.sh b/sonarr/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/sonarr/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/sonarr/rootfs/etc/cont-init.d/00-ha-env b/sonarr/rootfs/etc/cont-init.d/00-ha-env new file mode 100644 index 000000000..3b3e69246 --- /dev/null +++ b/sonarr/rootfs/etc/cont-init.d/00-ha-env @@ -0,0 +1,5 @@ +#!/usr/bin/with-contenv bashio + +for k in $(bashio::jq "${__BASHIO_ADDON_CONFIG}" 'keys | .[]'); do + printf "$(bashio::config $k)" > /var/run/s6/container_environment/$k +done \ No newline at end of file diff --git a/sonarr/rootfs/etc/cont-init.d/20-folders b/sonarr/rootfs/etc/cont-init.d/20-folders new file mode 100644 index 000000000..17b3689df --- /dev/null +++ b/sonarr/rootfs/etc/cont-init.d/20-folders @@ -0,0 +1,19 @@ +#!/usr/bin/with-contenv bash + +if [ ! -d /share/storage/movies ]; then + echo "Creating /share/storage/movies" + mkdir -p /share/storage/movies + chown -R abc:abc /share/storage/movies +fi + +if [ ! -d /share/downloads ]; then + echo "Creating /share/downloads" + mkdir -p /share/downloads + chown -R abc:abc /share/downloads +fi + +if [ ! -d /config/sonarr ]; then + echo "Creating /config/sonarr" + mkdir -p /config/sonarr + chown -R abc:abc /config/sonarr +fi diff --git a/sonarr/rootfs/etc/cont-init.d/92-local_mounts.sh b/sonarr/rootfs/etc/cont-init.d/92-local_mounts.sh new file mode 100644 index 000000000..0920d68bd --- /dev/null +++ b/sonarr/rootfs/etc/cont-init.d/92-local_mounts.sh @@ -0,0 +1,32 @@ +#!/usr/bin/with-contenv bashio + +###################### +# MOUNT LOCAL SHARES # +###################### + +# Mount local Share if configured +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + echo "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + + # Mount by device as default + devpath=/dev + + # Mount as label + [ ${disk:0:2} != "sd" ] && devpath=/dev/disk/by-label + + # Creates dir + mkdir -p /mnt/$disk + chown -R $(id -u):$(id -g) /mnt/$disk + # Legacy mounting : mount to share if still exists (avoid breaking changes) + [ -d /share/$disk ] && mount $devpath/$disk /share/$disk || true + # Mount + mount $devpath/$disk /mnt/$disk && bashio::log.info "Success! $disk mounted to /mnt/$disk" || (bashio::log.fatal "Unable to mount local drives! Please check the name." && rmdir /mnt/$disk) + + done + +fi diff --git a/sonarr/rootfs/etc/cont-init.d/92-smb_mounts.sh b/sonarr/rootfs/etc/cont-init.d/92-smb_mounts.sh new file mode 100644 index 000000000..06410e554 --- /dev/null +++ b/sonarr/rootfs/etc/cont-init.d/92-smb_mounts.sh @@ -0,0 +1,83 @@ +#!/usr/bin/with-contenv bashio + +######################### +# MOUNT SMB SHARES v1.6 # +######################### +if bashio::config.has_value 'networkdisks'; then + + # Define variables + MOREDISKS=$(bashio::config 'networkdisks') + CIFS_USERNAME=$(bashio::config 'cifsusername') + CIFS_PASSWORD=$(bashio::config 'cifspassword') + MOUNTED=false + SMBVERS="" + SECVERS="" + + # Mount CIFS Share if configured and if Protection Mode is active + echo 'Mounting smb share(s)...' + + if bashio::config.has_value 'cifsdomain'; then + DOMAIN=",domain=$(bashio::config 'cifsdomain')" + else + DOMAIN="" + fi + + # Mounting disks + for disk in ${MOREDISKS//,/ }; do # Separate comma separated values + + # Clean name of network share + disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name + diskname=${disk//\\//} #replace \ with / + diskname=${diskname##*/} # Get only last part of the name + + # Data validation + if [[ ! $disk =~ ^.*+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[/]+.*+$ ]]; then + bashio::log.fatal "The structure of your \"networkdisks\" option : \"$disk\" doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2. If you don't use it, you can simply remove the text, this will avoid this error message in the future." + exit 0 + fi + + # Prepare mount point + mkdir -p /mnt/$diskname + chown -R root:root /mnt/$diskname + + #Tries to mount with default options + mount -t cifs -o rw,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname 2>ERRORCODE && MOUNTED=true || MOUNTED=false + + # if Fail test different smb and sec versions + if [ $MOUNTED = false ]; then + for SMBVERS in ",vers=3" ",vers=1.0" ",vers=2.1" ",vers=3.0" ",nodfs" ",uid=0,gid=0,forceuid,forcegid" ",noforceuid,noforcegid" ",${DOMAIN:-WORKGROUP}"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS $disk /mnt/$diskname 2>/dev/null && MOUNTED=true && break || MOUNTED=false + for SECVERS in ",sec=ntlmi" ",sec=ntlmv2" ",sec=ntlmv2i" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=ntlm" ",sec=krb5i" ",sec=krb5" ",iocharset=utf8"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS$SECVERS $disk /mnt/$disk name 2>/dev/null && MOUNTED=true && break 2 && break || MOUNTED=false + done + done + fi + + # Messages + if [ $MOUNTED = true ] && [ "mountpoint -q /mnt/$diskname" ]; then + #Test write permissions + touch /mnt/$diskname/testaze && rm /mnt/$diskname/testaze && + bashio::log.info "... $disk successfully mounted to /mnt/$diskname with options $SMBVERS$SECVERS" || + bashio::log.fatal "Disk is mounted, however unable to write in the shared disk. Please check UID/GID for permissions, and if the share is rw" + + else + # Mounting failed messages + bashio::log.fatal "Error, unable to mount $disk to /mnt/$diskname with username $CIFS_USERNAME, $CIFS_PASSWORD. Please check your remote share path, username, password, domain, try putting 0 in UID and GID" + bashio::log.fatal "Here is some debugging info :" + + # Provide debugging info + smbclient -V &>/dev/null || apt-get install smbclient || apk add --no-cache samba-client + #smbclient $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + smbclient -L $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + + # Error code + bashio::log.fatal "Error read : $(/dev/null || true + rmdir /mnt/$diskname || true + fi + + done +fi diff --git a/teamspeak/CHANGELOG.md b/teamspeak/CHANGELOG.md index 8372cb6c5..c62b3b963 100644 --- a/teamspeak/CHANGELOG.md +++ b/teamspeak/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## debian (04-12-2021) - Update to latest version from mbentley/teamspeak diff --git a/teamspeak/Dockerfile b/teamspeak/Dockerfile index 83210007a..68167a772 100644 --- a/teamspeak/Dockerfile +++ b/teamspeak/Dockerfile @@ -1,6 +1,14 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM FROM ${BUILD_FROM} +################## +# 2 Modify Image # +################## + RUN mkdir -p /data \ && chown -R 503:503 /data @@ -8,7 +16,24 @@ ENV PATH "${PATH}:/data" VOLUME [ "/data:/var/ts3server/" ] -### LABELS +################## +# 3 Install apps # +################## + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ + ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/teamspeak/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/teamspeak/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/teamspeak/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/teamspeak/rootfs/etc/cont-init.d/00-banner.sh b/teamspeak/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/teamspeak/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/transmission/CHANGELOG.md b/transmission/CHANGELOG.md index abdcd7305..ca78ee965 100644 --- a/transmission/CHANGELOG.md +++ b/transmission/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation - Removal of requirement for unprotected mode - Addition of local disks mount - Addition of repair capabilities for the json diff --git a/transmission/Dockerfile b/transmission/Dockerfile index 65f488df7..0e69964af 100644 --- a/transmission/Dockerfile +++ b/transmission/Dockerfile @@ -1,35 +1,14 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="curl \ - jq \ - samba \ - samba-client" -# Add bashio -RUN apk add --no-cache ${PACKAGES} \ - \ - && curl -J -L -o /tmp/bashio.tar.gz \ - "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - && mkdir /tmp/bashio \ - && tar zxvf \ - /tmp/bashio.tar.gz \ - --strip 1 -C /tmp/bashio \ - \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -fr /tmp/bashio.tar.gz || true - -RUN \ - ln -s /usr/share/transmission/web/style /transmission-web-control && \ - ln -s /usr/share/transmission/web/images /transmission-web-control && \ - ln -s /usr/share/transmission/web/javascript /transmission-web-control && \ - ln -s /usr/share/transmission/web/index.html /transmission-web-control/index.original.html - - -# Copy root filesystem -COPY rootfs / +################## +# 2 Modify Image # +################## # MOFIFY DATA PATH RUN sed -i "s|config|config/transmission|g" /etc/services.d/transmission/run \ @@ -37,11 +16,45 @@ RUN sed -i "s|config|config/transmission|g" /etc/services.d/transmission/run \ # Allow UID and GID setting && sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ && sed -i 's/{PUID:-911}/(bashio::config "PUID")/g' /etc/cont-init.d/10-adduser \ - && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser + && sed -i 's/{PGID:-911}/(bashio::config "PGID")/g' /etc/cont-init.d/10-adduser \ + # Allow return to original UI + && ln -s /usr/share/transmission/web/style /transmission-web-control && \ + ln -s /usr/share/transmission/web/images /transmission-web-control && \ + ln -s /usr/share/transmission/web/javascript /transmission-web-control && \ + ln -s /usr/share/transmission/web/index.html /transmission-web-control/index.original.html -VOLUME [ "/data" ] +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/transmission/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/transmission/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh index 612e26d7e..4f9ed9c51 100644 --- a/transmission/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ b/transmission/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -1,29 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - + ####################### + # Automatic installer # + ####################### + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/ubooquity/CHANGELOG.md b/ubooquity/CHANGELOG.md index 991d1d961..04321bac2 100644 --- a/ubooquity/CHANGELOG.md +++ b/ubooquity/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation - Improve SMB mount code to v1.5 ; accepts several network disks separated by commas (//123.12.12.12/share,//123.12.12.12/hello) that are mount to /mnt/$sharename - Add local drives mounts : used localdisks with the text "sda1, sdb1" according to your needs - Add ssl diff --git a/ubooquity/Dockerfile b/ubooquity/Dockerfile index 8cd04cc9a..e30f46e3d 100644 --- a/ubooquity/Dockerfile +++ b/ubooquity/Dockerfile @@ -1,30 +1,15 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION ARG BUILD_UPSTREAM="2.1.2" FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="curl \ - jq \ - moreutils \ - samba \ - nginx" -# Add bashio -RUN apk add --no-cache ${PACKAGES} \ - \ - && curl -J -L -o /tmp/bashio.tar.gz \ - "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - && mkdir /tmp/bashio \ - && tar zxvf \ - /tmp/bashio.tar.gz \ - --strip 1 -C /tmp/bashio \ - \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -fr /tmp/bashio.tar.gz || true - -# Copy root filesystem -COPY rootfs / +################## +# 2 Modify Image # +################## RUN \ # Set config directory @@ -43,9 +28,42 @@ RUN \ && sed -i 's|bash|bashio|g' /etc/services.d/ubooquity/run \ && sed -i 's|{MAXMEM:-512}|(bashio::config "maxmem")|g' /etc/services.d/ubooquity/run -VOLUME [ "/data" ] +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="curl \ + jq \ + moreutils \ + samba \ + nginx" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/ubooquity/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/ubooquity/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh index 612e26d7e..4f9ed9c51 100644 --- a/ubooquity/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh +++ b/ubooquity/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -1,29 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - + ####################### + # Automatic installer # + ####################### + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/webtop/CHANGELOG.md b/webtop/CHANGELOG.md index 66f7e8b76..4ef647bc0 100644 --- a/webtop/CHANGELOG.md +++ b/webtop/CHANGELOG.md @@ -1 +1,2 @@ +- New standardized logic for Dockerfile build and packages installation - Initial release diff --git a/webtop/Dockerfile b/webtop/Dockerfile index 048226a6e..728e776d9 100644 --- a/webtop/Dockerfile +++ b/webtop/Dockerfile @@ -1,29 +1,15 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION FROM ${BUILD_FROM} -ENV BASHIO_VERSION=0.14.3 -ENV PACKAGES="curl \ - jq \ - cifs-utils \ - keyutils \ - samba" -RUN \ - ################ - # Install apps # - ################ - apk add --no-cache ${PACKAGES} \ - \ -################### -# Install bashio # ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | \ - tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - rm -rf /tmp/bashio || true +# 2 Modify Image # +################## # Allow UID and GID setting RUN sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ @@ -34,10 +20,42 @@ RUN sed -i 's/bash/bashio/g' /etc/cont-init.d/10-adduser \ && sed -i 's|/config|/data|g' /etc/cont-init.d/* \ && sed -i 's|/config|/data|g' /etc/services.d/*/run -# copy local files -COPY root/ / +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps +ENV PACKAGES="curl \ + jq \ + cifs-utils \ + keyutils \ + samba" + +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION @@ -46,20 +64,20 @@ 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} + 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} diff --git a/webtop/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/webtop/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/webtop/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/webtop/rootfs/etc/cont-init.d/00-banner.sh b/webtop/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/webtop/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/webtop/rootfs/etc/cont-init.d/90-dns_set.sh b/webtop/rootfs/etc/cont-init.d/90-dns_set.sh new file mode 100644 index 000000000..dd80ef417 --- /dev/null +++ b/webtop/rootfs/etc/cont-init.d/90-dns_set.sh @@ -0,0 +1,28 @@ +#!/usr/bin/with-contenv bashio + +############### +# DNS SETTING # +############### + +# Avoid usage of local dns such as adguard home or pihole\n" + +if bashio::config.has_value 'DNS_server'; then + # Define variables + DNSSERVER=$(bashio::config 'DNS_server') + DNS="" + DNSLIST="" + + # Get DNS servers + for server in ${DNSSERVER//,/ } # Separate comma separated values + do + DNS="${DNS}nameserver $server\n" + DNSLIST="$server $DNSLIST" + done + + # Write resolv.conf + printf "${DNS}" > /etc/resolv.conf + chmod 644 /etc/resolv.conf + bashio::log.info "DNS SERVERS set to $DNSLIST" +else + bashio::log.info "DNS Servers option empty. Using default router (or HA) dns servers." +fi diff --git a/webtop/rootfs/etc/cont-init.d/92-local_mounts.sh b/webtop/rootfs/etc/cont-init.d/92-local_mounts.sh new file mode 100644 index 000000000..0920d68bd --- /dev/null +++ b/webtop/rootfs/etc/cont-init.d/92-local_mounts.sh @@ -0,0 +1,32 @@ +#!/usr/bin/with-contenv bashio + +###################### +# MOUNT LOCAL SHARES # +###################### + +# Mount local Share if configured +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + echo "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + + # Mount by device as default + devpath=/dev + + # Mount as label + [ ${disk:0:2} != "sd" ] && devpath=/dev/disk/by-label + + # Creates dir + mkdir -p /mnt/$disk + chown -R $(id -u):$(id -g) /mnt/$disk + # Legacy mounting : mount to share if still exists (avoid breaking changes) + [ -d /share/$disk ] && mount $devpath/$disk /share/$disk || true + # Mount + mount $devpath/$disk /mnt/$disk && bashio::log.info "Success! $disk mounted to /mnt/$disk" || (bashio::log.fatal "Unable to mount local drives! Please check the name." && rmdir /mnt/$disk) + + done + +fi diff --git a/webtop/rootfs/etc/cont-init.d/92-smb_mounts.sh b/webtop/rootfs/etc/cont-init.d/92-smb_mounts.sh new file mode 100644 index 000000000..06410e554 --- /dev/null +++ b/webtop/rootfs/etc/cont-init.d/92-smb_mounts.sh @@ -0,0 +1,83 @@ +#!/usr/bin/with-contenv bashio + +######################### +# MOUNT SMB SHARES v1.6 # +######################### +if bashio::config.has_value 'networkdisks'; then + + # Define variables + MOREDISKS=$(bashio::config 'networkdisks') + CIFS_USERNAME=$(bashio::config 'cifsusername') + CIFS_PASSWORD=$(bashio::config 'cifspassword') + MOUNTED=false + SMBVERS="" + SECVERS="" + + # Mount CIFS Share if configured and if Protection Mode is active + echo 'Mounting smb share(s)...' + + if bashio::config.has_value 'cifsdomain'; then + DOMAIN=",domain=$(bashio::config 'cifsdomain')" + else + DOMAIN="" + fi + + # Mounting disks + for disk in ${MOREDISKS//,/ }; do # Separate comma separated values + + # Clean name of network share + disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name + diskname=${disk//\\//} #replace \ with / + diskname=${diskname##*/} # Get only last part of the name + + # Data validation + if [[ ! $disk =~ ^.*+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[/]+.*+$ ]]; then + bashio::log.fatal "The structure of your \"networkdisks\" option : \"$disk\" doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2. If you don't use it, you can simply remove the text, this will avoid this error message in the future." + exit 0 + fi + + # Prepare mount point + mkdir -p /mnt/$diskname + chown -R root:root /mnt/$diskname + + #Tries to mount with default options + mount -t cifs -o rw,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname 2>ERRORCODE && MOUNTED=true || MOUNTED=false + + # if Fail test different smb and sec versions + if [ $MOUNTED = false ]; then + for SMBVERS in ",vers=3" ",vers=1.0" ",vers=2.1" ",vers=3.0" ",nodfs" ",uid=0,gid=0,forceuid,forcegid" ",noforceuid,noforcegid" ",${DOMAIN:-WORKGROUP}"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS $disk /mnt/$diskname 2>/dev/null && MOUNTED=true && break || MOUNTED=false + for SECVERS in ",sec=ntlmi" ",sec=ntlmv2" ",sec=ntlmv2i" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=ntlm" ",sec=krb5i" ",sec=krb5" ",iocharset=utf8"; do + mount -t cifs -o rw,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$SMBVERS$SECVERS $disk /mnt/$disk name 2>/dev/null && MOUNTED=true && break 2 && break || MOUNTED=false + done + done + fi + + # Messages + if [ $MOUNTED = true ] && [ "mountpoint -q /mnt/$diskname" ]; then + #Test write permissions + touch /mnt/$diskname/testaze && rm /mnt/$diskname/testaze && + bashio::log.info "... $disk successfully mounted to /mnt/$diskname with options $SMBVERS$SECVERS" || + bashio::log.fatal "Disk is mounted, however unable to write in the shared disk. Please check UID/GID for permissions, and if the share is rw" + + else + # Mounting failed messages + bashio::log.fatal "Error, unable to mount $disk to /mnt/$diskname with username $CIFS_USERNAME, $CIFS_PASSWORD. Please check your remote share path, username, password, domain, try putting 0 in UID and GID" + bashio::log.fatal "Here is some debugging info :" + + # Provide debugging info + smbclient -V &>/dev/null || apt-get install smbclient || apk add --no-cache samba-client + #smbclient $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + smbclient -L $disk -U $CIFS_USERNAME%$CIFS_PASSWORD || true + + # Error code + bashio::log.fatal "Error read : $(/dev/null || true + rmdir /mnt/$diskname || true + fi + + done +fi diff --git a/webtrees/CHANGELOG.md b/webtrees/CHANGELOG.md index c192dadfc..eae95dfe9 100644 --- a/webtrees/CHANGELOG.md +++ b/webtrees/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 2.0.19 (07-12-2021) - Update to latest version from nathanvaughn/webtrees-docker diff --git a/webtrees/Dockerfile b/webtrees/Dockerfile index ff7a63193..9504a3af6 100644 --- a/webtrees/Dockerfile +++ b/webtrees/Dockerfile @@ -1,53 +1,55 @@ +################# +# 1 Build Image # +################# + ARG BUILD_VERSION FROM nathanvaughn/webtrees:latest +################## +# 2 Modify Image # +################## + # Global variables -ENV BASHIO_VERSION=0.14.3 ENV WEBTREES_HOME="/data/webtrees" WORKDIR $WEBTREES_HOME -VOLUME ["/data"] +RUN \ + # Change data location + grep -rl "/var/www/webtrees" /etc/ | xargs sed -i 's|/var/www/webtrees|/data/webtrees|g' \ + # Add end script + && sed -i '$ d' /docker-entrypoint.sh + +################## +# 3 Install apps # +################## + +# Add rootfs +COPY rootfs/ / + +# Manual apps ENV PACKAGES="jq \ curl \ yamllint" -RUN \ - ################ - # Install apps # - ################ - apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends ${PACKAGES} \ - && apt-get clean \ - \ - ################## - # Install bashio # - ################## - && mkdir -p /tmp/bashio \ - && curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" \ - | tar -xzf - --strip 1 -C /tmp/bashio \ - && mv /tmp/bashio/lib /usr/lib/bashio \ - && ln -s /usr/lib/bashio/bashio /usr/bin/bashio \ - && rm -rf /tmp/bashio || true +# 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); 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); fi && \ + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ + chmod 777 /automatic_packages.sh && \ + /automatic_packages.sh "${PACKAGES:-}" && \ + rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE -# Copy root filesystem -COPY rootfs/ / +################ +# 4 Entrypoint # +################ -RUN \ - ################ - # Modify image # - ################ - # Change data location - sed -i 's|/etc/services.d/*/run|/scripts/99-run.sh|g' /scripts/90-config_yaml.sh \ - && grep -rl "/var/www/webtrees" /etc/ | xargs sed -i 's|/var/www/webtrees|/data/webtrees|g' \ - # Add entry script - && chown root:root /entrypoint.sh \ - && chmod 777 /entrypoint.sh \ - # Add end script - && sed -i '$ d' /docker-entrypoint.sh +RUN chmod 777 /entrypoint.sh +ENTRYPOINT [ "/usr/bin/env" ] +CMD [ "/entrypoint.sh" ] -ENTRYPOINT ["/entrypoint.sh"] +############ +# 5 Labels # +############ -### LABELS ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/webtrees/rootfs/entrypoint.sh b/webtrees/rootfs/entrypoint.sh index bf5da4a6c..35ccb7382 100644 --- a/webtrees/rootfs/entrypoint.sh +++ b/webtrees/rootfs/entrypoint.sh @@ -2,34 +2,6 @@ echo "Starting..." -################################### -# Export all addon options as env # -################################### - -# For all keys in options.json -JSONSOURCE="/data/options.json" - -# Export keys as env variables -echo "All addon options were exported as variables" -mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE}) -for KEYS in ${arr[@]}; do - # export key - VALUE=$(jq .$KEYS ${JSONSOURCE}) - export ${KEYS}=${VALUE//[\"\']/} &>/dev/null -done - -################ -# Set timezone # -################ -if [ ! -z "TZ" ] && [ -f /etc/localtime ]; then - if [ -f /usr/share/zoneinfo/$TZ ]; then - echo "Timezone set from $(cat /etc/timezone) to $TZ" - ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ >/etc/timezone - else - echo "WARNING : Timezone $TZ is invalid, it will be kept to default value of $(cat /etc/timezone)" - fi -fi - #################### # Starting scripts # #################### diff --git a/webtrees/rootfs/scripts/00-aaa_dockerfile_backup.sh b/webtrees/rootfs/scripts/00-aaa_dockerfile_backup.sh index 612e26d7e..4f9ed9c51 100644 --- a/webtrees/rootfs/scripts/00-aaa_dockerfile_backup.sh +++ b/webtrees/rootfs/scripts/00-aaa_dockerfile_backup.sh @@ -1,29 +1,18 @@ #!/bin/bash # If dockerfile failed install manually -if [ ! -f "/usr/bin/bashio" ]; then - echo "Bashio does not exist, executing script" +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null \ - || apk add --no-cache ${PACKAGES} - - ################### - # Install bashio # - ################## - - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | - tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio - + ####################### + # Automatic installer # + ####################### + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null fi diff --git a/webtrees/rootfs/scripts/90-config_yaml.sh b/webtrees/rootfs/scripts/90-config_yaml.sh index 00646fc3f..e37468ce2 100644 --- a/webtrees/rootfs/scripts/90-config_yaml.sh +++ b/webtrees/rootfs/scripts/90-config_yaml.sh @@ -83,8 +83,8 @@ while IFS= read -r line; do if [[ $line =~ ^.+[=].+$ ]]; then export $line # Export the variable - sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || sed -i "1a export $line" /scripts/*run* - + sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || true + sed -i "1a export $line" /scripts/*run* 2>/dev/null || true # Show in log bashio::log.blue "$line" else diff --git a/wger/Dockerfile b/wger/Dockerfile index 50d6e7f7d..12b751461 100644 --- a/wger/Dockerfile +++ b/wger/Dockerfile @@ -1,15 +1,39 @@ +################# +# 1 Build Image # +################# + ARG BUILD_VERSION FROM wger/devel:latest -VOLUME [ "/data" ] +################## +# 2 Modify Image # +################## +VOLUME [ "/data" ] USER root RUN touch /data/database.sqlite \ && chown wger /data/database.sqlite \ && ln -s /data/database.sqlite /home/wger/db -### LABELS +################## +# 3 Install apps # +################## + +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ + ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/wger/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/wger/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/wger/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/wger/rootfs/etc/cont-init.d/00-banner.sh b/wger/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/wger/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/xteve/CHANGELOG.md b/xteve/CHANGELOG.md index beb46de24..4bdf996ed 100644 --- a/xteve/CHANGELOG.md +++ b/xteve/CHANGELOG.md @@ -1,3 +1,4 @@ +- New standardized logic for Dockerfile build and packages installation ## 2.2.0.200 (29-09-2021) - Update to latest version from xteve-project/xTeVe diff --git a/xteve/Dockerfile b/xteve/Dockerfile index a0bd0588d..32f74245c 100644 --- a/xteve/Dockerfile +++ b/xteve/Dockerfile @@ -1,13 +1,34 @@ +################# +# 1 Build Image # +################# + ARG BUILD_FROM ARG BUILD_VERSION ARG BUILD_UPSTREAM="2.2.0.200" FROM collelog/xteve:latest-alpine +################## +# 2 Modify Image # +################## + RUN cp -vnpr /etc/opt/xteve* /data || true CMD ["-config", "/data", "-port", "34400"] -### LABELS +################ +# 4 Entrypoint # +################ + +#RUN chmod 777 /entrypoint.sh +#WORKDIR / +#ENTRYPOINT [ "/usr/bin/env" ] +#CMD [ "/entrypoint.sh" ] +#SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +############ +# 5 Labels # +############ + ARG BUILD_ARCH ARG BUILD_DATE ARG BUILD_DESCRIPTION diff --git a/xteve/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh b/xteve/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh new file mode 100644 index 000000000..4f9ed9c51 --- /dev/null +++ b/xteve/rootfs/etc/cont-init.d/00-aaa_dockerfile_backup.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# If dockerfile failed install manually +if [ -e "/ENVFILE" ]; then + echo "Executing script" + PACKAGES=$(/dev/null 2>/dev/null; then (apt-get update && apt-get install -yqq --no-install-recommends bash || apk add --no-cache bash); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh + ) >/dev/null + +fi diff --git a/xteve/rootfs/etc/cont-init.d/00-banner.sh b/xteve/rootfs/etc/cont-init.d/00-banner.sh new file mode 100644 index 000000000..0ac294e9a --- /dev/null +++ b/xteve/rootfs/etc/cont-init.d/00-banner.sh @@ -0,0 +1,39 @@ +#!/usr/bin/with-contenv bashio +# ============================================================================== +# Displays a simple add-on banner on startup +# ============================================================================== + +if bashio::supervisor.ping; then + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue " Add-on: $(bashio::addon.name)" + bashio::log.blue " $(bashio::addon.description)" + bashio::log.blue \ + '-----------------------------------------------------------' + + bashio::log.blue " Add-on version: $(bashio::addon.version)" + if bashio::var.true "$(bashio::addon.update_available)"; then + bashio::log.magenta ' There is an update available for this add-on!' + bashio::log.magenta \ + " Latest add-on version: $(bashio::addon.version_latest)" + bashio::log.magenta ' Please consider upgrading as soon as possible.' + else + bashio::log.green ' You are running the latest version of this add-on.' + fi + + bashio::log.blue " System: $(bashio::info.operating_system)" \ + " ($(bashio::info.arch) / $(bashio::info.machine))" + bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" + bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" + + bashio::log.blue \ + '-----------------------------------------------------------' + bashio::log.blue \ + ' Please, share the above information when looking for help' + bashio::log.blue \ + ' or support in, e.g., GitHub, forums' + bashio::log.green \ + ' https://github.com/alexbelgium/hassio-addons' + bashio::log.blue \ + '-----------------------------------------------------------' +fi diff --git a/zzz_templates/00-aaa_dockerfile_backup.sh b/zzz_templates/00-aaa_dockerfile_backup.sh index e33f7f063..ad7d5b3a3 100644 --- a/zzz_templates/00-aaa_dockerfile_backup.sh +++ b/zzz_templates/00-aaa_dockerfile_backup.sh @@ -2,17 +2,17 @@ # If dockerfile failed install manually if [ -e "/ENVFILE" ]; then echo "Executing script" - PACKAGES=$(< /ENVFILE) + PACKAGES=$(/dev/null) || (apt-get install -y --no-install-recommends bash || apk add --no-cache bash) && \ - $(curl --help &>/dev/null) || (apt-get install -y --no-install-recommends curl &>/dev/null || apk add --no-cache curl) && \ - curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && \ - chmod 777 /automatic_packages.sh && \ - eval /./automatic_packages.sh "$PACKAGES" && \ - rm /automatic_packages.sh + 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); 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); fi && + curl -L -f -s "https://raw.githubusercontent.com/alexbelgium/hassio-addons/master/zzz_templates/automatic_packages.sh" --output /automatic_packages.sh && + chmod 777 /automatic_packages.sh && + eval /./automatic_packages.sh "$PACKAGES" && + rm /automatic_packages.sh ) >/dev/null diff --git a/zzz_templates/00-banner.sh b/zzz_templates/00-banner.sh index 0ac294e9a..54d7d491a 100644 --- a/zzz_templates/00-banner.sh +++ b/zzz_templates/00-banner.sh @@ -5,35 +5,35 @@ if bashio::supervisor.ping; then bashio::log.blue \ - '-----------------------------------------------------------' + '-----------------------------------------------------------' bashio::log.blue " Add-on: $(bashio::addon.name)" bashio::log.blue " $(bashio::addon.description)" bashio::log.blue \ - '-----------------------------------------------------------' + '-----------------------------------------------------------' bashio::log.blue " Add-on version: $(bashio::addon.version)" if bashio::var.true "$(bashio::addon.update_available)"; then bashio::log.magenta ' There is an update available for this add-on!' bashio::log.magenta \ - " Latest add-on version: $(bashio::addon.version_latest)" + " Latest add-on version: $(bashio::addon.version_latest)" bashio::log.magenta ' Please consider upgrading as soon as possible.' else bashio::log.green ' You are running the latest version of this add-on.' fi bashio::log.blue " System: $(bashio::info.operating_system)" \ - " ($(bashio::info.arch) / $(bashio::info.machine))" + " ($(bashio::info.arch) / $(bashio::info.machine))" bashio::log.blue " Home Assistant Core: $(bashio::info.homeassistant)" bashio::log.blue " Home Assistant Supervisor: $(bashio::info.supervisor)" bashio::log.blue \ - '-----------------------------------------------------------' + '-----------------------------------------------------------' bashio::log.blue \ - ' Please, share the above information when looking for help' + ' Please, share the above information when looking for help' bashio::log.blue \ - ' or support in, e.g., GitHub, forums' + ' or support in, e.g., GitHub, forums' bashio::log.green \ - ' https://github.com/alexbelgium/hassio-addons' + ' https://github.com/alexbelgium/hassio-addons' bashio::log.blue \ - '-----------------------------------------------------------' + '-----------------------------------------------------------' fi diff --git a/zzz_templates/90-config_yaml.sh b/zzz_templates/90-config_yaml.sh index 00646fc3f..e37468ce2 100644 --- a/zzz_templates/90-config_yaml.sh +++ b/zzz_templates/90-config_yaml.sh @@ -83,8 +83,8 @@ while IFS= read -r line; do if [[ $line =~ ^.+[=].+$ ]]; then export $line # Export the variable - sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || sed -i "1a export $line" /scripts/*run* - + sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || true + sed -i "1a export $line" /scripts/*run* 2>/dev/null || true # Show in log bashio::log.blue "$line" else diff --git a/zzz_templates/automatic_packages.sh b/zzz_templates/automatic_packages.sh index 253f423b7..94d68af27 100644 --- a/zzz_templates/automatic_packages.sh +++ b/zzz_templates/automatic_packages.sh @@ -4,27 +4,27 @@ # INIT # ######## +VERBOSE=false set +u 2>/dev/null -PACKAGES="${1:-}" -VERBOSE="${2:-}" +PACKAGES="${*:-}" [ "$VERBOSE" = true ] && echo "ENV : $PACKAGES" ############################ # CHECK WHICH BASE IS USED # ############################ -if [[ "$(apk -h 2>/dev/null)" ]]; then -# If apk based -[ "$VERBOSE" = true ] && echo "apk based" -PACKMANAGER="apk" -PACKAGES="apk add --no-cache $PACKAGES" +COMMAND="apk" +if command -v $COMMAND &>/dev/null; then + # If apk based + [ "$VERBOSE" = true ] && echo "apk based" + PACKMANAGER="apk" + PACKAGES="apk add --no-cache $PACKAGES" else -# If apt-get based -[ "$VERBOSE" = true ] && echo "apt based" -PACKMANAGER="apt" -PACKAGES="apt-get clean \ - && apt-get update \ - && apt-get install -y --no-install-recommends $PACKAGES" + # If apt-get based + [ "$VERBOSE" = true ] && echo "apt based" + PACKMANAGER="apt" + PACKAGES="apt-get update \ + && apt-get install -yqq --no-install-recommends $PACKAGES" fi ################### @@ -42,85 +42,85 @@ PACKAGES="$PACKAGES jq curl" # Scripts for files in "/etc/cont-init.d" "/etc/services.d" "/scripts"; do # Next directory if does not exists - if ! ls $files 1> /dev/null 2>&1; then continue; fi + if ! ls $files 1>/dev/null 2>&1; then continue; fi # Test each possible command COMMAND="nginx" - if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then - [ "$VERBOSE" = true ] && echo "$COMMAND required" - [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES nginx" - [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES nginx" - if ls /etc/nginx 1> /dev/null 2>&1; then mv /etc/nginx /etc/nginx2; fi + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES nginx" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES nginx" + if ls /etc/nginx 1>/dev/null 2>&1; then mv /etc/nginx /etc/nginx2; fi fi COMMAND="cifs" - if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then - [ "$VERBOSE" = true ] && echo "$COMMAND required" - [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES cifs-utils keyutils samba" - [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES cifs-utils keyutils samba" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES cifs-utils keyutils" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES cifs-utils keyutils" fi COMMAND="smbclient" - if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then - [ "$VERBOSE" = true ] && echo "$COMMAND required" - [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES samba samba-client" - [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES samba smbclient" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES samba samba-client" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES samba smbclient" fi COMMAND="openvpn" - if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then - [ "$VERBOSE" = true ] && echo "$COMMAND required" - [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES coreutils openvpn" - [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES coreutils openvpn" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES coreutils openvpn" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES coreutils openvpn" fi COMMAND="jq" - if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then - [ "$VERBOSE" = true ] && echo "$COMMAND required" - [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES jq" - [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES jq" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES jq" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES jq" fi COMMAND="yamllint" - if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then - [ "$VERBOSE" = true ] && echo "$COMMAND required" - [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES yamllint" - [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES yamllint" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES yamllint" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES yamllint" fi COMMAND="git" - if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then - [ "$VERBOSE" = true ] && echo "$COMMAND required" - [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES git" - [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES git" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES git" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES git" fi COMMAND="sponge" - if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then - [ "$VERBOSE" = true ] && echo "$COMMAND required" - [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES moreutils" - [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES moreutils" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES moreutils" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES moreutils" fi COMMAND="sqlite" - if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then - [ "$VERBOSE" = true ] && echo "$COMMAND required" - [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES sqlite" - [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES sqlite3" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES sqlite" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES sqlite3" fi COMMAND="pip" - if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then - [ "$VERBOSE" = true ] && echo "$COMMAND required" - [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES py3-pip" - [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES python-pip" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES py3-pip" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES python-pip" fi COMMAND="wget" - if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &> /dev/null; then - [ "$VERBOSE" = true ] && echo "$COMMAND required" - [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES wget" - [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES wget" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && PACKAGES="$PACKAGES wget" + [ "$PACKMANAGER" = "apt" ] && PACKAGES="$PACKAGES wget" fi done @@ -130,15 +130,19 @@ done #################### # Install apps -[ "$VERBOSE" = true ] && echo "installing packages $PACKAGES" -eval "$PACKAGES" +[ "$VERBOSE" = true ] && echo "installing packages $PACKAGES" +eval "$PACKAGES" + +# Clean after install +[ "$VERBOSE" = true ] && echo "Cleaning apt cache" +[ "$PACKMANAGER" = "apt" ] && apt-get clean || true # Replace nginx if installed -if ls /etc/nginx2 1> /dev/null 2>&1; then +if ls /etc/nginx2 1>/dev/null 2>&1; then [ "$VERBOSE" = true ] && echo "replace nginx2" rm -r /etc/nginx mv /etc/nginx2 /etc/nginx - mkdir -p /var/log/nginx + mkdir -p /var/log/nginx touch /var/log/nginx/error.log fi @@ -148,33 +152,48 @@ fi for files in "/scripts" "/etc/services.d" "/etc/cont-init.d"; do -# Next directory if does not exists - if ! ls $files 1> /dev/null 2>&1; then continue; fi + # Next directory if does not exists + if ! ls $files 1>/dev/null 2>&1; then continue; fi -# Bashio + # Bashio if grep -q -rnw "$files/" -e 'bashio' && [ ! -f "/usr/bin/bashio" ]; then - [ "$VERBOSE" = true ] && echo "install bashio" - BASHIO_VERSION="0.14.3" - mkdir -p /tmp/bashio - curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | tar -xzf - --strip 1 -C /tmp/bashio - mv /tmp/bashio/lib /usr/lib/bashio - ln -s /usr/lib/bashio/bashio /usr/bin/bashio - rm -rf /tmp/bashio + [ "$VERBOSE" = true ] && echo "install bashio" + BASHIO_VERSION="0.14.3" + mkdir -p /tmp/bashio + curl -L -f -s "https://github.com/hassio-addons/bashio/archive/v${BASHIO_VERSION}.tar.gz" | tar -xzf - --strip 1 -C /tmp/bashio + mv /tmp/bashio/lib /usr/lib/bashio + ln -s /usr/lib/bashio/bashio /usr/bin/bashio + rm -rf /tmp/bashio fi -# Lastversion + # Lastversion if grep -q -rnw "$files/" -e 'lastversion'; then - [ "$VERBOSE" = true ] && echo "install lastversion" - pip install lastversion + [ "$VERBOSE" = true ] && echo "install lastversion" + pip install lastversion fi -# Tempio + # Tempio if grep -q -rnw "$files/" -e 'tempio' && [ ! -f "/usr/bin/tempio" ]; then - [ "$VERBOSE" = true ] && echo "install tempio" - TEMPIO_VERSION="2021.09.0" - BUILD_ARCH="$(bashio::info.arch)" - curl -L -f -s -o /usr/bin/tempio "https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}" - chmod a+x /usr/bin/tempio + [ "$VERBOSE" = true ] && echo "install tempio" + TEMPIO_VERSION="2021.09.0" + BUILD_ARCH="$(bashio::info.arch)" + curl -L -f -s -o /usr/bin/tempio "https://github.com/home-assistant/tempio/releases/download/${TEMPIO_VERSION}/tempio_${BUILD_ARCH}" + chmod a+x /usr/bin/tempio fi - + + # Mustache + COMMAND="mustache" + if grep -q -rnw "$files/" -e "$COMMAND" && ! command -v $COMMAND &>/dev/null; then + [ "$VERBOSE" = true ] && echo "$COMMAND required" + [ "$PACKMANAGER" = "apk" ] && apk add --no-cache go npm && + apk upgrade --no-cache && + apk add --no-cache --virtual .build-deps build-base git go && + go get -u github.com/quantumew/mustache-cli && + cp "$GOPATH"/bin/* /usr/bin/ && + rm -rf "$GOPATH" /var/cache/apk/* /tmp/src && + apk del .build-deps xz build-base + [ "$PACKMANAGER" = "apt" ] && apt-get update && + apt-get install -yqq go npm node-mustache + fi + done