From ed8b7a3f07ec527201165831b41e941aac68aa84 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Thu, 13 Jan 2022 21:29:26 +0100 Subject: [PATCH] Modulization --- addons_updater/rootfs/scripts/00-banner.sh | 39 --------- arpspoof/Dockerfile | 4 +- arpspoof/rootfs/scripts/00-banner.sh | 39 --------- arpspoof/rootfs/scripts/00-global_var.sh | 34 -------- bazarr/Dockerfile | 2 +- bazarr/rootfs/etc/cont-init.d/00-banner.sh | 39 --------- bazarr/rootfs/etc/cont-init.d/00-ha-env.sh | 5 -- .../rootfs/etc/cont-init.d/92-local_mounts.sh | 32 ------- .../rootfs/etc/cont-init.d/92-smb_mounts.sh | 83 ------------------- booksonic_air/Dockerfile | 4 +- .../rootfs/etc/cont-init.d/00-banner.sh | 39 --------- .../rootfs/etc/cont-init.d/92-local_mounts.sh | 32 ------- .../rootfs/etc/cont-init.d/92-smb_mounts.sh | 83 ------------------- cloudcommander/Dockerfile | 4 +- cloudcommander/rootfs/scripts/00-banner.sh | 39 --------- .../rootfs/scripts/92-local_mounts.sh | 32 ------- .../rootfs/scripts/92-smb_mounts.sh | 83 ------------------- .../rootfs/scripts/93-mount_partitions.sh | 4 - code-server/Dockerfile | 4 +- .../rootfs/etc/cont-init.d/00-banner.sh | 39 --------- .../rootfs/etc/cont-init.d/92-local_mounts.sh | 32 ------- .../rootfs/etc/cont-init.d/92-smb_mounts.sh | 83 ------------------- .../rootfs/etc/cont-init.d/00-banner.sh | 39 --------- emby/Dockerfile | 2 +- emby/rootfs/etc/cont-init.d/00-banner.sh | 39 --------- .../rootfs/etc/cont-init.d/92-local_mounts.sh | 32 ------- emby/rootfs/etc/cont-init.d/92-smb_mounts.sh | 83 ------------------- enedisgateway2mqtt/Dockerfile | 2 +- .../rootfs/scripts/00-banner.sh | 39 --------- enedisgateway2mqtt_dev/Dockerfile | 2 +- .../rootfs/scripts/00-banner.sh | 39 --------- .../rootfs/scripts/00-global_var.sh | 34 -------- filebrowser/Dockerfile | 4 +- filebrowser/rootfs/scripts/00-banner.sh | 39 --------- filebrowser/rootfs/scripts/92-local_mounts.sh | 32 ------- filebrowser/rootfs/scripts/92-smb_mounts.sh | 83 ------------------- .../00-global_var.sh | 2 +- 37 files changed, 15 insertions(+), 1211 deletions(-) delete mode 100644 addons_updater/rootfs/scripts/00-banner.sh delete mode 100644 arpspoof/rootfs/scripts/00-banner.sh delete mode 100644 arpspoof/rootfs/scripts/00-global_var.sh delete mode 100644 bazarr/rootfs/etc/cont-init.d/00-banner.sh delete mode 100644 bazarr/rootfs/etc/cont-init.d/00-ha-env.sh delete mode 100644 bazarr/rootfs/etc/cont-init.d/92-local_mounts.sh delete mode 100644 bazarr/rootfs/etc/cont-init.d/92-smb_mounts.sh delete mode 100644 booksonic_air/rootfs/etc/cont-init.d/00-banner.sh delete mode 100644 booksonic_air/rootfs/etc/cont-init.d/92-local_mounts.sh delete mode 100644 booksonic_air/rootfs/etc/cont-init.d/92-smb_mounts.sh delete mode 100644 cloudcommander/rootfs/scripts/00-banner.sh delete mode 100644 cloudcommander/rootfs/scripts/92-local_mounts.sh delete mode 100644 cloudcommander/rootfs/scripts/92-smb_mounts.sh delete mode 100644 cloudcommander/rootfs/scripts/93-mount_partitions.sh delete mode 100644 code-server/rootfs/etc/cont-init.d/00-banner.sh delete mode 100644 code-server/rootfs/etc/cont-init.d/92-local_mounts.sh delete mode 100644 code-server/rootfs/etc/cont-init.d/92-smb_mounts.sh delete mode 100644 elasticsearch/rootfs/etc/cont-init.d/00-banner.sh delete mode 100644 emby/rootfs/etc/cont-init.d/00-banner.sh delete mode 100644 emby/rootfs/etc/cont-init.d/92-local_mounts.sh delete mode 100644 emby/rootfs/etc/cont-init.d/92-smb_mounts.sh delete mode 100644 enedisgateway2mqtt/rootfs/scripts/00-banner.sh delete mode 100644 enedisgateway2mqtt_dev/rootfs/scripts/00-banner.sh delete mode 100644 enedisgateway2mqtt_dev/rootfs/scripts/00-global_var.sh delete mode 100644 filebrowser/rootfs/scripts/00-banner.sh delete mode 100644 filebrowser/rootfs/scripts/92-local_mounts.sh delete mode 100644 filebrowser/rootfs/scripts/92-smb_mounts.sh rename {enedisgateway2mqtt/rootfs/scripts => zzz_templates}/00-global_var.sh (92%) diff --git a/addons_updater/rootfs/scripts/00-banner.sh b/addons_updater/rootfs/scripts/00-banner.sh deleted file mode 100644 index 0ac294e9a..000000000 --- a/addons_updater/rootfs/scripts/00-banner.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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/arpspoof/Dockerfile b/arpspoof/Dockerfile index f46bf0204..bc1a2d6c1 100644 --- a/arpspoof/Dockerfile +++ b/arpspoof/Dockerfile @@ -40,7 +40,7 @@ RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE # Modules -ARG MODULES="00-banner.sh" +ARG MODULES="00-banner.sh 00-global_var.sh" # Automatic modules download RUN mkdir -p /tmpscripts /etc/cont-init.d && \ @@ -55,7 +55,7 @@ RUN mkdir -p /tmpscripts /etc/cont-init.d && \ RUN chmod 777 /entrypoint.sh ENTRYPOINT [ "/usr/bin/env" ] -CMD [ "/entrypoint.sh" ] +CMD [ "/entrypoint.sh" ] ############ # 5 Labels # diff --git a/arpspoof/rootfs/scripts/00-banner.sh b/arpspoof/rootfs/scripts/00-banner.sh deleted file mode 100644 index 0ac294e9a..000000000 --- a/arpspoof/rootfs/scripts/00-banner.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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/arpspoof/rootfs/scripts/00-global_var.sh b/arpspoof/rootfs/scripts/00-global_var.sh deleted file mode 100644 index b68e3f08b..000000000 --- a/arpspoof/rootfs/scripts/00-global_var.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/with-contenv bashio - -################################### -# 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}) - line="${KEYS}=${VALUE//[\"\']/}" - # Use locally - if ! bashio::config.false "verbose"; then bashio::log.blue "$line"; fi - export $line - # Export the variable to run scripts - line="${KEYS}=${VALUE//[\"\']/} &>/dev/null" - sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || sed -i "1a export $line" /scripts/*run* -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 - fi -fi - diff --git a/bazarr/Dockerfile b/bazarr/Dockerfile index 29d4d755d..936631cf4 100644 --- a/bazarr/Dockerfile +++ b/bazarr/Dockerfile @@ -50,7 +50,7 @@ RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE # Modules -ARG MODULES="00-banner.sh" +ARG MODULES="00-banner.sh 92-local_mounts.sh 92-smb_mounts.sh" # Automatic modules download RUN mkdir -p /tmpscripts /etc/cont-init.d && \ diff --git a/bazarr/rootfs/etc/cont-init.d/00-banner.sh b/bazarr/rootfs/etc/cont-init.d/00-banner.sh deleted file mode 100644 index 54d7d491a..000000000 --- a/bazarr/rootfs/etc/cont-init.d/00-banner.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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.sh b/bazarr/rootfs/etc/cont-init.d/00-ha-env.sh deleted file mode 100644 index 3b3e69246..000000000 --- a/bazarr/rootfs/etc/cont-init.d/00-ha-env.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/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/92-local_mounts.sh b/bazarr/rootfs/etc/cont-init.d/92-local_mounts.sh deleted file mode 100644 index 0920d68bd..000000000 --- a/bazarr/rootfs/etc/cont-init.d/92-local_mounts.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/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 deleted file mode 100644 index 06410e554..000000000 --- a/bazarr/rootfs/etc/cont-init.d/92-smb_mounts.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/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/booksonic_air/Dockerfile b/booksonic_air/Dockerfile index 65edc4262..3581d9686 100644 --- a/booksonic_air/Dockerfile +++ b/booksonic_air/Dockerfile @@ -50,7 +50,7 @@ RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE # Modules -ARG MODULES="00-banner.sh" +ARG MODULES="00-banner.sh 92-local_mounts.sh 92-smb_mounts.sh" # Automatic modules download RUN mkdir -p /tmpscripts /etc/cont-init.d && \ @@ -66,7 +66,7 @@ RUN mkdir -p /tmpscripts /etc/cont-init.d && \ #RUN chmod 777 /entrypoint.sh #WORKDIR / #ENTRYPOINT [ "/usr/bin/env" ] -#CMD [ "/entrypoint.sh" ] +#CMD [ "/entrypoint.sh" ] #SHELL ["/bin/bash", "-o", "pipefail", "-c"] ############ diff --git a/booksonic_air/rootfs/etc/cont-init.d/00-banner.sh b/booksonic_air/rootfs/etc/cont-init.d/00-banner.sh deleted file mode 100644 index 54d7d491a..000000000 --- a/booksonic_air/rootfs/etc/cont-init.d/00-banner.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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 deleted file mode 100644 index 0920d68bd..000000000 --- a/booksonic_air/rootfs/etc/cont-init.d/92-local_mounts.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/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 deleted file mode 100644 index 06410e554..000000000 --- a/booksonic_air/rootfs/etc/cont-init.d/92-smb_mounts.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/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/Dockerfile b/cloudcommander/Dockerfile index 6eaa0e545..bd25643c3 100644 --- a/cloudcommander/Dockerfile +++ b/cloudcommander/Dockerfile @@ -29,7 +29,7 @@ COPY rootfs/ / # Manual apps ENV PACKAGES="jq \ - cifs-utils \ + cifs-utils \ keyutils \ nginx" @@ -42,7 +42,7 @@ RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE # Modules -ARG MODULES="00-banner.sh" +ARG MODULES="00-banner.sh 92-local_mounts.sh 92-smb_mounts.sh" # Automatic modules download RUN mkdir -p /tmpscripts /etc/cont-init.d && \ diff --git a/cloudcommander/rootfs/scripts/00-banner.sh b/cloudcommander/rootfs/scripts/00-banner.sh deleted file mode 100644 index 0ac294e9a..000000000 --- a/cloudcommander/rootfs/scripts/00-banner.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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/cloudcommander/rootfs/scripts/92-local_mounts.sh b/cloudcommander/rootfs/scripts/92-local_mounts.sh deleted file mode 100644 index 0920d68bd..000000000 --- a/cloudcommander/rootfs/scripts/92-local_mounts.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/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/cloudcommander/rootfs/scripts/92-smb_mounts.sh b/cloudcommander/rootfs/scripts/92-smb_mounts.sh deleted file mode 100644 index 06410e554..000000000 --- a/cloudcommander/rootfs/scripts/92-smb_mounts.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/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/rootfs/scripts/93-mount_partitions.sh b/cloudcommander/rootfs/scripts/93-mount_partitions.sh deleted file mode 100644 index b6114c83d..000000000 --- a/cloudcommander/rootfs/scripts/93-mount_partitions.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/with-contenv bashio - -mkdir -p /addons -mount /dev/mmcblk0p8 /addons &>/dev/null && bashio::log.info "Data drive mounted in /addons" diff --git a/code-server/Dockerfile b/code-server/Dockerfile index c7a962338..3d754f473 100644 --- a/code-server/Dockerfile +++ b/code-server/Dockerfile @@ -49,7 +49,7 @@ RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE # Modules -ARG MODULES="00-banner.sh" +ARG MODULES="00-banner.sh 92-local_mounts.sh 92-smb_mounts.sh" # Automatic modules download RUN mkdir -p /tmpscripts /etc/cont-init.d && \ @@ -65,7 +65,7 @@ RUN mkdir -p /tmpscripts /etc/cont-init.d && \ #RUN chmod 777 /entrypoint.sh #WORKDIR / #ENTRYPOINT [ "/usr/bin/env" ] -#CMD [ "/entrypoint.sh" ] +#CMD [ "/entrypoint.sh" ] #SHELL ["/bin/bash", "-o", "pipefail", "-c"] ############ diff --git a/code-server/rootfs/etc/cont-init.d/00-banner.sh b/code-server/rootfs/etc/cont-init.d/00-banner.sh deleted file mode 100644 index 0ac294e9a..000000000 --- a/code-server/rootfs/etc/cont-init.d/00-banner.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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/code-server/rootfs/etc/cont-init.d/92-local_mounts.sh b/code-server/rootfs/etc/cont-init.d/92-local_mounts.sh deleted file mode 100644 index 0920d68bd..000000000 --- a/code-server/rootfs/etc/cont-init.d/92-local_mounts.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/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 deleted file mode 100644 index 06410e554..000000000 --- a/code-server/rootfs/etc/cont-init.d/92-smb_mounts.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/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/elasticsearch/rootfs/etc/cont-init.d/00-banner.sh b/elasticsearch/rootfs/etc/cont-init.d/00-banner.sh deleted file mode 100644 index 0ac294e9a..000000000 --- a/elasticsearch/rootfs/etc/cont-init.d/00-banner.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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/Dockerfile b/emby/Dockerfile index 9e3c0f747..c354fc92d 100644 --- a/emby/Dockerfile +++ b/emby/Dockerfile @@ -53,7 +53,7 @@ RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE # Modules -ARG MODULES="00-banner.sh" +ARG MODULES="00-banner.sh 92-local_mounts.sh 92-smb_mounts.sh" # Automatic modules download RUN mkdir -p /tmpscripts /etc/cont-init.d && \ diff --git a/emby/rootfs/etc/cont-init.d/00-banner.sh b/emby/rootfs/etc/cont-init.d/00-banner.sh deleted file mode 100644 index 0ac294e9a..000000000 --- a/emby/rootfs/etc/cont-init.d/00-banner.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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/rootfs/etc/cont-init.d/92-local_mounts.sh b/emby/rootfs/etc/cont-init.d/92-local_mounts.sh deleted file mode 100644 index 0920d68bd..000000000 --- a/emby/rootfs/etc/cont-init.d/92-local_mounts.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/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/emby/rootfs/etc/cont-init.d/92-smb_mounts.sh b/emby/rootfs/etc/cont-init.d/92-smb_mounts.sh deleted file mode 100644 index 06410e554..000000000 --- a/emby/rootfs/etc/cont-init.d/92-smb_mounts.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/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/enedisgateway2mqtt/Dockerfile b/enedisgateway2mqtt/Dockerfile index 3edc2dfd2..d127e3a49 100644 --- a/enedisgateway2mqtt/Dockerfile +++ b/enedisgateway2mqtt/Dockerfile @@ -42,7 +42,7 @@ RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE # Modules -ARG MODULES="00-banner.sh" +ARG MODULES="00-banner.sh 00-global_var.sh" # Automatic modules download RUN mkdir -p /tmpscripts /etc/cont-init.d && \ diff --git a/enedisgateway2mqtt/rootfs/scripts/00-banner.sh b/enedisgateway2mqtt/rootfs/scripts/00-banner.sh deleted file mode 100644 index 0ac294e9a..000000000 --- a/enedisgateway2mqtt/rootfs/scripts/00-banner.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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/enedisgateway2mqtt_dev/Dockerfile b/enedisgateway2mqtt_dev/Dockerfile index e9e11a5ec..b8231299f 100644 --- a/enedisgateway2mqtt_dev/Dockerfile +++ b/enedisgateway2mqtt_dev/Dockerfile @@ -42,7 +42,7 @@ RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE # Modules -ARG MODULES="00-banner.sh" +ARG MODULES="00-banner.sh 00-global_var.sh" # Automatic modules download RUN mkdir -p /tmpscripts /etc/cont-init.d && \ diff --git a/enedisgateway2mqtt_dev/rootfs/scripts/00-banner.sh b/enedisgateway2mqtt_dev/rootfs/scripts/00-banner.sh deleted file mode 100644 index 0ac294e9a..000000000 --- a/enedisgateway2mqtt_dev/rootfs/scripts/00-banner.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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/enedisgateway2mqtt_dev/rootfs/scripts/00-global_var.sh b/enedisgateway2mqtt_dev/rootfs/scripts/00-global_var.sh deleted file mode 100644 index b68e3f08b..000000000 --- a/enedisgateway2mqtt_dev/rootfs/scripts/00-global_var.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/with-contenv bashio - -################################### -# 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}) - line="${KEYS}=${VALUE//[\"\']/}" - # Use locally - if ! bashio::config.false "verbose"; then bashio::log.blue "$line"; fi - export $line - # Export the variable to run scripts - line="${KEYS}=${VALUE//[\"\']/} &>/dev/null" - sed -i "1a export $line" /etc/services.d/*/*run* 2>/dev/null || sed -i "1a export $line" /scripts/*run* -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 - fi -fi - diff --git a/filebrowser/Dockerfile b/filebrowser/Dockerfile index 5a06aae7f..14545281e 100644 --- a/filebrowser/Dockerfile +++ b/filebrowser/Dockerfile @@ -42,7 +42,7 @@ RUN if ! command -v bash >/dev/null 2>/dev/null; then (apt-get update && apt-get rm /automatic_packages.sh || printf '%s\n' "${PACKAGES:-}" > /ENVFILE # Modules -ARG MODULES="00-banner.sh" +ARG MODULES="00-banner.sh 92-local_mounts.sh 92-smb_mounts.sh" # Automatic modules download RUN mkdir -p /tmpscripts /etc/cont-init.d && \ @@ -59,7 +59,7 @@ VOLUME [ "/data" ] WORKDIR / RUN chmod 777 /entrypoint.sh ENTRYPOINT [ "/usr/bin/env" ] -CMD [ "/entrypoint.sh" ] +CMD [ "/entrypoint.sh" ] ############ # 5 Labels # diff --git a/filebrowser/rootfs/scripts/00-banner.sh b/filebrowser/rootfs/scripts/00-banner.sh deleted file mode 100644 index 0ac294e9a..000000000 --- a/filebrowser/rootfs/scripts/00-banner.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/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/filebrowser/rootfs/scripts/92-local_mounts.sh b/filebrowser/rootfs/scripts/92-local_mounts.sh deleted file mode 100644 index 0920d68bd..000000000 --- a/filebrowser/rootfs/scripts/92-local_mounts.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/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/filebrowser/rootfs/scripts/92-smb_mounts.sh b/filebrowser/rootfs/scripts/92-smb_mounts.sh deleted file mode 100644 index 06410e554..000000000 --- a/filebrowser/rootfs/scripts/92-smb_mounts.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/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/enedisgateway2mqtt/rootfs/scripts/00-global_var.sh b/zzz_templates/00-global_var.sh similarity index 92% rename from enedisgateway2mqtt/rootfs/scripts/00-global_var.sh rename to zzz_templates/00-global_var.sh index 6de2954f0..e88ad363a 100644 --- a/enedisgateway2mqtt/rootfs/scripts/00-global_var.sh +++ b/zzz_templates/00-global_var.sh @@ -15,7 +15,7 @@ for KEYS in ${arr[@]}; do VALUE=$(jq .$KEYS ${JSONSOURCE}) line="${KEYS}=${VALUE//[\"\']/}" # Use locally - if ! bashio::config.false "verbose";then bashio::log.blue "$line"; fi + if ! bashio::config.false "verbose"; then bashio::log.blue "$line"; fi export $line # Export the variable to run scripts line="${KEYS}=${VALUE//[\"\']/} &>/dev/null"