From 98faea5ed018d7eac75403888d8d46bd1fbc8a13 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Sat, 23 Oct 2021 20:21:21 +0200 Subject: [PATCH] clean code --- .../root/etc/cont-init.d/92-local_mounts.sh | 28 +++--- cloudcommander/rootfs/92-local_mounts.sh | 29 ++++--- code-server/root/etc/cont-init.d/50-mounts | 43 ---------- .../root/etc/cont-init.d/92-local_mounts.sh | 27 ++++++ .../root/etc/cont-init.d/92-smb_mounts.sh | 86 +++++++++++++++++++ emby/root/etc/cont-init.d/92-local_mounts.sh | 28 +++--- filebrowser/rootfs/92-local_mounts.sh | 29 ++++--- jackett/root/etc/cont-init.d/50-mounts | 45 ---------- .../root/etc/cont-init.d/92-local_mounts.sh | 27 ++++++ jackett/root/etc/cont-init.d/92-smb_mounts.sh | 86 +++++++++++++++++++ .../root/etc/cont-init.d/92-local_mounts.sh | 28 +++--- photoprism/rootfs/92-local_mounts.sh | 29 ++++--- piwigo/rootfs/etc/cont-init.d/11-mounts | 44 ---------- .../cont-init.d/{41-folders => 41-folders.sh} | 0 .../rootfs/etc/cont-init.d/92-local_mounts.sh | 27 ++++++ .../rootfs/etc/cont-init.d/92-smb_mounts.sh | 86 +++++++++++++++++++ plex/root/etc/cont-init.d/92-local_mounts.sh | 28 +++--- .../rootfs/etc/cont-init.d/92-local_mounts.sh | 28 +++--- radarr/root/etc/cont-init.d/00-ha-env | 4 +- .../root/etc/cont-init.d/92-local_mounts.sh | 28 +++--- .../root/etc/cont-init.d/92-local_mounts.sh | 28 +++--- .../etc/cont-init.d/{31-run => 31-run.sh} | 0 .../etc/cont-init.d/{32-nginx => 32-nginx.sh} | 0 .../root/etc/cont-init.d/92-local_mounts.sh | 28 +++--- .../{93-custom_webUI => 93-custom_webUI.sh} | 0 25 files changed, 498 insertions(+), 288 deletions(-) delete mode 100644 code-server/root/etc/cont-init.d/50-mounts create mode 100644 code-server/root/etc/cont-init.d/92-local_mounts.sh create mode 100644 code-server/root/etc/cont-init.d/92-smb_mounts.sh delete mode 100644 jackett/root/etc/cont-init.d/50-mounts create mode 100644 jackett/root/etc/cont-init.d/92-local_mounts.sh create mode 100644 jackett/root/etc/cont-init.d/92-smb_mounts.sh delete mode 100644 piwigo/rootfs/etc/cont-init.d/11-mounts rename piwigo/rootfs/etc/cont-init.d/{41-folders => 41-folders.sh} (100%) create mode 100644 piwigo/rootfs/etc/cont-init.d/92-local_mounts.sh create mode 100644 piwigo/rootfs/etc/cont-init.d/92-smb_mounts.sh rename scrutiny/rootfs/etc/cont-init.d/{31-run => 31-run.sh} (100%) rename scrutiny/rootfs/etc/cont-init.d/{32-nginx => 32-nginx.sh} (100%) rename ubooquity/rootfs/etc/cont-init.d/{93-custom_webUI => 93-custom_webUI.sh} (100%) diff --git a/bazarr/root/etc/cont-init.d/92-local_mounts.sh b/bazarr/root/etc/cont-init.d/92-local_mounts.sh index f29116820..c6eb07628 100644 --- a/bazarr/root/etc/cont-init.d/92-local_mounts.sh +++ b/bazarr/root/etc/cont-init.d/92-local_mounts.sh @@ -9,19 +9,19 @@ bashio::log.info 'Mounting external hdd...' # Mount local Share if configured and if Protection Mode is active if bashio::config.has_value 'localdisks'; then + MOREDISKS=$(bashio::config 'localdisks') - bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && - # Separate comma separated values - for disk in ${MOREDISKS//,/ }; do - bashio::log.info "Mount ${disk}" - mkdir -p /$MOUNTPOINTS/$disk && - if [ ! -d /$MOUNTPOINTS/$disk ]; then - echo "Creating /$MOUNTPOINTS/$disk" - mkdir -p /$MOUNTPOINTS/$disk - chown -R abc:abc /$MOUNTPOINTS/$disk - fi - mount /dev/$disk /$MOUNTPOINTS/$disk && - bashio::log.info "Success! Mounted to /$MOUNTPOINTS/$disk" - done || - bashio::log.warning "Unable to mount local drives!" + bashio::log.info "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + # Mount each disk + mkdir -p /$MOUNTPOINTS/$disk + chown -R $(id -u):$(id -g) /$MOUNTPOINTS/$disk + mount /dev/$disk /$MOUNTPOINTS/$disk + bashio::log.info "Success! $disk mounted to /$MOUNTPOINTS/$disk" || + # Error message and clean remaining folder + (bashio::log.warning "Unable to mount local drives!" && + rmdir /$MOUNTPOINTS/$disk) + done fi diff --git a/cloudcommander/rootfs/92-local_mounts.sh b/cloudcommander/rootfs/92-local_mounts.sh index 96dd3d2f1..c6eb07628 100644 --- a/cloudcommander/rootfs/92-local_mounts.sh +++ b/cloudcommander/rootfs/92-local_mounts.sh @@ -3,24 +3,25 @@ ###################### # MOUNT LOCAL SHARES # ###################### +MOUNTPOINTS="share" bashio::log.info 'Mounting external hdd...' # Mount local Share if configured and if Protection Mode is active if bashio::config.has_value 'localdisks'; then + MOREDISKS=$(bashio::config 'localdisks') - bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && - # Separate comma separated values - for disk in ${MOREDISKS//,/ }; do - bashio::log.info "Mount ${disk}" - mkdir -p /share/$disk && - if [ ! -d /share/$disk ]; then - echo "Creating /share/$disk" - mkdir -p /share/$disk - chown -R abc:abc /share/$disk - fi - mount /dev/$disk /share/$disk && - bashio::log.info "Success!" - done || - bashio::log.warning "Protection mode is ON. Unable to mount local drives!" + bashio::log.info "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + # Mount each disk + mkdir -p /$MOUNTPOINTS/$disk + chown -R $(id -u):$(id -g) /$MOUNTPOINTS/$disk + mount /dev/$disk /$MOUNTPOINTS/$disk + bashio::log.info "Success! $disk mounted to /$MOUNTPOINTS/$disk" || + # Error message and clean remaining folder + (bashio::log.warning "Unable to mount local drives!" && + rmdir /$MOUNTPOINTS/$disk) + done fi diff --git a/code-server/root/etc/cont-init.d/50-mounts b/code-server/root/etc/cont-init.d/50-mounts deleted file mode 100644 index 14dd93a02..000000000 --- a/code-server/root/etc/cont-init.d/50-mounts +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/with-contenv bashio -bashio::log.info 'Mounting external hdd...' - -# Mount local Share if configured and if Protection Mode is active -if bashio::config.has_value 'localdisks'; then - MOREDISKS=$(bashio::config 'localdisks') - bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && \ - for disk in $MOREDISKS - do - bashio::log.info "Mount ${disk}" - mkdir -p /share/$disk && \ - if [ ! -d /share/$disk ]; then - echo "Creating /share/$disk" - mkdir -p /share/$disk - chown -R abc:abc /share/$disk - fi - mount /dev/$disk /share/$disk && \ - bashio::log.info "Success!" - done || \ - bashio::log.warning "Unable to mount local drives!" -fi - -# Mount CIFS Share if configured and if Protection Mode is active -if bashio::config.has_value 'networkdisks'; then - MOREDISKS=$(bashio::config 'networkdisks') - CIFS_USERNAME=$(bashio::config 'cifsusername') - CIFS_PASSWORD=$(bashio::config 'cifspassword') - bashio::log.info "Network Disks mounting.. ${MOREDISKS}" && \ - for disk in $MOREDISKS - do - bashio::log.info "Mount ${disk}" - mkdir -p /share/storagecifs && \ - if [ ! -d /storage/storagecifs ]; then - echo "Creating /storage/storagecifs" - mkdir -p /storage/storagecifs - chown -R abc:abc /storage/storagecifs - fi - - mount -t cifs -o username=$CIFS_USERNAME,password=$CIFS_PASSWORD $disk /storage/storagecifs && \ - bashio::log.info "Success!" - done || \ - bashio::log.warning "Protection mode is ON. Unable to mount external drives!" -fi diff --git a/code-server/root/etc/cont-init.d/92-local_mounts.sh b/code-server/root/etc/cont-init.d/92-local_mounts.sh new file mode 100644 index 000000000..c6eb07628 --- /dev/null +++ b/code-server/root/etc/cont-init.d/92-local_mounts.sh @@ -0,0 +1,27 @@ +#!/usr/bin/with-contenv bashio + +###################### +# MOUNT LOCAL SHARES # +###################### +MOUNTPOINTS="share" + +bashio::log.info 'Mounting external hdd...' + +# Mount local Share if configured and if Protection Mode is active +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + bashio::log.info "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + # Mount each disk + mkdir -p /$MOUNTPOINTS/$disk + chown -R $(id -u):$(id -g) /$MOUNTPOINTS/$disk + mount /dev/$disk /$MOUNTPOINTS/$disk + bashio::log.info "Success! $disk mounted to /$MOUNTPOINTS/$disk" || + # Error message and clean remaining folder + (bashio::log.warning "Unable to mount local drives!" && + rmdir /$MOUNTPOINTS/$disk) + done +fi diff --git a/code-server/root/etc/cont-init.d/92-smb_mounts.sh b/code-server/root/etc/cont-init.d/92-smb_mounts.sh new file mode 100644 index 000000000..eccb42d4e --- /dev/null +++ b/code-server/root/etc/cont-init.d/92-smb_mounts.sh @@ -0,0 +1,86 @@ +#!/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="" + + # Dont execute if still default + [ ${MOREDISKS::1} == "<" ] && exit 0 + + # Mount CIFS Share if configured and if Protection Mode is active + bashio::log.info '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 doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2" + exit 1 + 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/emby/root/etc/cont-init.d/92-local_mounts.sh b/emby/root/etc/cont-init.d/92-local_mounts.sh index f29116820..c6eb07628 100644 --- a/emby/root/etc/cont-init.d/92-local_mounts.sh +++ b/emby/root/etc/cont-init.d/92-local_mounts.sh @@ -9,19 +9,19 @@ bashio::log.info 'Mounting external hdd...' # Mount local Share if configured and if Protection Mode is active if bashio::config.has_value 'localdisks'; then + MOREDISKS=$(bashio::config 'localdisks') - bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && - # Separate comma separated values - for disk in ${MOREDISKS//,/ }; do - bashio::log.info "Mount ${disk}" - mkdir -p /$MOUNTPOINTS/$disk && - if [ ! -d /$MOUNTPOINTS/$disk ]; then - echo "Creating /$MOUNTPOINTS/$disk" - mkdir -p /$MOUNTPOINTS/$disk - chown -R abc:abc /$MOUNTPOINTS/$disk - fi - mount /dev/$disk /$MOUNTPOINTS/$disk && - bashio::log.info "Success! Mounted to /$MOUNTPOINTS/$disk" - done || - bashio::log.warning "Unable to mount local drives!" + bashio::log.info "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + # Mount each disk + mkdir -p /$MOUNTPOINTS/$disk + chown -R $(id -u):$(id -g) /$MOUNTPOINTS/$disk + mount /dev/$disk /$MOUNTPOINTS/$disk + bashio::log.info "Success! $disk mounted to /$MOUNTPOINTS/$disk" || + # Error message and clean remaining folder + (bashio::log.warning "Unable to mount local drives!" && + rmdir /$MOUNTPOINTS/$disk) + done fi diff --git a/filebrowser/rootfs/92-local_mounts.sh b/filebrowser/rootfs/92-local_mounts.sh index 96dd3d2f1..c6eb07628 100644 --- a/filebrowser/rootfs/92-local_mounts.sh +++ b/filebrowser/rootfs/92-local_mounts.sh @@ -3,24 +3,25 @@ ###################### # MOUNT LOCAL SHARES # ###################### +MOUNTPOINTS="share" bashio::log.info 'Mounting external hdd...' # Mount local Share if configured and if Protection Mode is active if bashio::config.has_value 'localdisks'; then + MOREDISKS=$(bashio::config 'localdisks') - bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && - # Separate comma separated values - for disk in ${MOREDISKS//,/ }; do - bashio::log.info "Mount ${disk}" - mkdir -p /share/$disk && - if [ ! -d /share/$disk ]; then - echo "Creating /share/$disk" - mkdir -p /share/$disk - chown -R abc:abc /share/$disk - fi - mount /dev/$disk /share/$disk && - bashio::log.info "Success!" - done || - bashio::log.warning "Protection mode is ON. Unable to mount local drives!" + bashio::log.info "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + # Mount each disk + mkdir -p /$MOUNTPOINTS/$disk + chown -R $(id -u):$(id -g) /$MOUNTPOINTS/$disk + mount /dev/$disk /$MOUNTPOINTS/$disk + bashio::log.info "Success! $disk mounted to /$MOUNTPOINTS/$disk" || + # Error message and clean remaining folder + (bashio::log.warning "Unable to mount local drives!" && + rmdir /$MOUNTPOINTS/$disk) + done fi diff --git a/jackett/root/etc/cont-init.d/50-mounts b/jackett/root/etc/cont-init.d/50-mounts deleted file mode 100644 index 380624675..000000000 --- a/jackett/root/etc/cont-init.d/50-mounts +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/with-contenv bashio -bashio::log.info 'Mounting external hdd...' - -# Mount local Share if configured and if Protection Mode is active -if bashio::config.has_value 'localdisks'; then - MOREDISKS=$(bashio::config 'localdisks') - bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && \ - for disk in $MOREDISKS - do - bashio::log.info "Mount ${disk}" - mkdir -p /share/$disk && \ - if [ ! -d /share/$disk ]; then - echo "Creating /share/$disk" - mkdir -p /share/$disk - chown -R abc:abc /share/$disk - fi - mount /dev/$disk /share/$disk && \ - bashio::log.info "Success!" - done || \ - bashio::log.warning "Protection mode is ON. Unable to mount local drives!" -fi - -# Mount CIFS Share if configured and if Protection Mode is active -if bashio::config.has_value 'networkdisks'; then - MOREDISKS=$(bashio::config 'networkdisks') - CIFS_USERNAME=$(bashio::config 'cifsusername') - CIFS_PASSWORD=$(bashio::config 'cifspassword') - bashio::log.info "Network Disks mounting.. ${MOREDISKS}" && \ - for disk in $MOREDISKS - do - disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name - disk=${disk//\\//} #replace \ with / - bashio::log.info "Mount ${disk}" - mkdir -p /share/storagecifs && \ - if [ ! -d /storage/storagecifs ]; then - echo "Creating /storage/storagecifs" - mkdir -p /storage/storagecifs - chown -R abc:abc /storage/storagecifs - fi - - mount -t cifs -o username=$CIFS_USERNAME,password=$CIFS_PASSWORD $disk /storage/storagecifs && \ - bashio::log.info "Success!" - done || \ - bashio::log.warning "Protection mode is ON. Unable to mount external drives!" -fi diff --git a/jackett/root/etc/cont-init.d/92-local_mounts.sh b/jackett/root/etc/cont-init.d/92-local_mounts.sh new file mode 100644 index 000000000..c6eb07628 --- /dev/null +++ b/jackett/root/etc/cont-init.d/92-local_mounts.sh @@ -0,0 +1,27 @@ +#!/usr/bin/with-contenv bashio + +###################### +# MOUNT LOCAL SHARES # +###################### +MOUNTPOINTS="share" + +bashio::log.info 'Mounting external hdd...' + +# Mount local Share if configured and if Protection Mode is active +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + bashio::log.info "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + # Mount each disk + mkdir -p /$MOUNTPOINTS/$disk + chown -R $(id -u):$(id -g) /$MOUNTPOINTS/$disk + mount /dev/$disk /$MOUNTPOINTS/$disk + bashio::log.info "Success! $disk mounted to /$MOUNTPOINTS/$disk" || + # Error message and clean remaining folder + (bashio::log.warning "Unable to mount local drives!" && + rmdir /$MOUNTPOINTS/$disk) + done +fi diff --git a/jackett/root/etc/cont-init.d/92-smb_mounts.sh b/jackett/root/etc/cont-init.d/92-smb_mounts.sh new file mode 100644 index 000000000..eccb42d4e --- /dev/null +++ b/jackett/root/etc/cont-init.d/92-smb_mounts.sh @@ -0,0 +1,86 @@ +#!/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="" + + # Dont execute if still default + [ ${MOREDISKS::1} == "<" ] && exit 0 + + # Mount CIFS Share if configured and if Protection Mode is active + bashio::log.info '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 doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2" + exit 1 + 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/lidarr/root/etc/cont-init.d/92-local_mounts.sh b/lidarr/root/etc/cont-init.d/92-local_mounts.sh index f29116820..c6eb07628 100644 --- a/lidarr/root/etc/cont-init.d/92-local_mounts.sh +++ b/lidarr/root/etc/cont-init.d/92-local_mounts.sh @@ -9,19 +9,19 @@ bashio::log.info 'Mounting external hdd...' # Mount local Share if configured and if Protection Mode is active if bashio::config.has_value 'localdisks'; then + MOREDISKS=$(bashio::config 'localdisks') - bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && - # Separate comma separated values - for disk in ${MOREDISKS//,/ }; do - bashio::log.info "Mount ${disk}" - mkdir -p /$MOUNTPOINTS/$disk && - if [ ! -d /$MOUNTPOINTS/$disk ]; then - echo "Creating /$MOUNTPOINTS/$disk" - mkdir -p /$MOUNTPOINTS/$disk - chown -R abc:abc /$MOUNTPOINTS/$disk - fi - mount /dev/$disk /$MOUNTPOINTS/$disk && - bashio::log.info "Success! Mounted to /$MOUNTPOINTS/$disk" - done || - bashio::log.warning "Unable to mount local drives!" + bashio::log.info "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + # Mount each disk + mkdir -p /$MOUNTPOINTS/$disk + chown -R $(id -u):$(id -g) /$MOUNTPOINTS/$disk + mount /dev/$disk /$MOUNTPOINTS/$disk + bashio::log.info "Success! $disk mounted to /$MOUNTPOINTS/$disk" || + # Error message and clean remaining folder + (bashio::log.warning "Unable to mount local drives!" && + rmdir /$MOUNTPOINTS/$disk) + done fi diff --git a/photoprism/rootfs/92-local_mounts.sh b/photoprism/rootfs/92-local_mounts.sh index 96dd3d2f1..c6eb07628 100644 --- a/photoprism/rootfs/92-local_mounts.sh +++ b/photoprism/rootfs/92-local_mounts.sh @@ -3,24 +3,25 @@ ###################### # MOUNT LOCAL SHARES # ###################### +MOUNTPOINTS="share" bashio::log.info 'Mounting external hdd...' # Mount local Share if configured and if Protection Mode is active if bashio::config.has_value 'localdisks'; then + MOREDISKS=$(bashio::config 'localdisks') - bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && - # Separate comma separated values - for disk in ${MOREDISKS//,/ }; do - bashio::log.info "Mount ${disk}" - mkdir -p /share/$disk && - if [ ! -d /share/$disk ]; then - echo "Creating /share/$disk" - mkdir -p /share/$disk - chown -R abc:abc /share/$disk - fi - mount /dev/$disk /share/$disk && - bashio::log.info "Success!" - done || - bashio::log.warning "Protection mode is ON. Unable to mount local drives!" + bashio::log.info "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + # Mount each disk + mkdir -p /$MOUNTPOINTS/$disk + chown -R $(id -u):$(id -g) /$MOUNTPOINTS/$disk + mount /dev/$disk /$MOUNTPOINTS/$disk + bashio::log.info "Success! $disk mounted to /$MOUNTPOINTS/$disk" || + # Error message and clean remaining folder + (bashio::log.warning "Unable to mount local drives!" && + rmdir /$MOUNTPOINTS/$disk) + done fi diff --git a/piwigo/rootfs/etc/cont-init.d/11-mounts b/piwigo/rootfs/etc/cont-init.d/11-mounts deleted file mode 100644 index 2e11daf3e..000000000 --- a/piwigo/rootfs/etc/cont-init.d/11-mounts +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/with-contenv bashio - -bashio::log.info 'Mounting external hdd...' - -# Mount local Share if configured and if Protection Mode is active -if bashio::config.has_value 'localdisks'; then - MOREDISKS=$(bashio::config 'localdisks') - bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && \ - for disk in $MOREDISKS - do - bashio::log.info "Mount ${disk}" - mkdir -p /share/$disk && \ - if [ ! -d /share/$disk ]; then - echo "Creating /share/$disk" - mkdir -p /share/$disk - chown -R abc:abc /share/$disk - fi - mount /dev/$disk /share/$disk && \ - bashio::log.info "Success!" - done || \ - bashio::log.warning "Unable to mount local drives!" -fi - -# Mount CIFS Share if configured and if Protection Mode is active -if bashio::config.has_value 'networkdisks'; then - MOREDISKS=$(bashio::config 'networkdisks') - CIFS_USERNAME=$(bashio::config 'cifsusername') - CIFS_PASSWORD=$(bashio::config 'cifspassword') - bashio::log.info "Network Disks mounting.. ${MOREDISKS}" && \ - for disk in $MOREDISKS - do - bashio::log.info "Mount ${disk}" - mkdir -p /share/storagecifs && \ - if [ ! -d /storage/storagecifs ]; then - echo "Creating /storage/storagecifs" - mkdir -p /storage/storagecifs - chown -R abc:abc /storage/storagecifs - fi - - mount -t cifs -o username=$CIFS_USERNAME,password=$CIFS_PASSWORD $disk /storage/storagecifs && \ - bashio::log.info "Success!" - done || \ - bashio::log.warning "Protection mode is ON. Unable to mount external drives!" -fi diff --git a/piwigo/rootfs/etc/cont-init.d/41-folders b/piwigo/rootfs/etc/cont-init.d/41-folders.sh similarity index 100% rename from piwigo/rootfs/etc/cont-init.d/41-folders rename to piwigo/rootfs/etc/cont-init.d/41-folders.sh diff --git a/piwigo/rootfs/etc/cont-init.d/92-local_mounts.sh b/piwigo/rootfs/etc/cont-init.d/92-local_mounts.sh new file mode 100644 index 000000000..c6eb07628 --- /dev/null +++ b/piwigo/rootfs/etc/cont-init.d/92-local_mounts.sh @@ -0,0 +1,27 @@ +#!/usr/bin/with-contenv bashio + +###################### +# MOUNT LOCAL SHARES # +###################### +MOUNTPOINTS="share" + +bashio::log.info 'Mounting external hdd...' + +# Mount local Share if configured and if Protection Mode is active +if bashio::config.has_value 'localdisks'; then + + MOREDISKS=$(bashio::config 'localdisks') + bashio::log.info "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + # Mount each disk + mkdir -p /$MOUNTPOINTS/$disk + chown -R $(id -u):$(id -g) /$MOUNTPOINTS/$disk + mount /dev/$disk /$MOUNTPOINTS/$disk + bashio::log.info "Success! $disk mounted to /$MOUNTPOINTS/$disk" || + # Error message and clean remaining folder + (bashio::log.warning "Unable to mount local drives!" && + rmdir /$MOUNTPOINTS/$disk) + done +fi diff --git a/piwigo/rootfs/etc/cont-init.d/92-smb_mounts.sh b/piwigo/rootfs/etc/cont-init.d/92-smb_mounts.sh new file mode 100644 index 000000000..eccb42d4e --- /dev/null +++ b/piwigo/rootfs/etc/cont-init.d/92-smb_mounts.sh @@ -0,0 +1,86 @@ +#!/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="" + + # Dont execute if still default + [ ${MOREDISKS::1} == "<" ] && exit 0 + + # Mount CIFS Share if configured and if Protection Mode is active + bashio::log.info '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 doesn't seem correct, please use a structure like //123.12.12.12/sharedfolder,//123.12.12.12/sharedfolder2" + exit 1 + 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/plex/root/etc/cont-init.d/92-local_mounts.sh b/plex/root/etc/cont-init.d/92-local_mounts.sh index f29116820..c6eb07628 100644 --- a/plex/root/etc/cont-init.d/92-local_mounts.sh +++ b/plex/root/etc/cont-init.d/92-local_mounts.sh @@ -9,19 +9,19 @@ bashio::log.info 'Mounting external hdd...' # Mount local Share if configured and if Protection Mode is active if bashio::config.has_value 'localdisks'; then + MOREDISKS=$(bashio::config 'localdisks') - bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && - # Separate comma separated values - for disk in ${MOREDISKS//,/ }; do - bashio::log.info "Mount ${disk}" - mkdir -p /$MOUNTPOINTS/$disk && - if [ ! -d /$MOUNTPOINTS/$disk ]; then - echo "Creating /$MOUNTPOINTS/$disk" - mkdir -p /$MOUNTPOINTS/$disk - chown -R abc:abc /$MOUNTPOINTS/$disk - fi - mount /dev/$disk /$MOUNTPOINTS/$disk && - bashio::log.info "Success! Mounted to /$MOUNTPOINTS/$disk" - done || - bashio::log.warning "Unable to mount local drives!" + bashio::log.info "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + # Mount each disk + mkdir -p /$MOUNTPOINTS/$disk + chown -R $(id -u):$(id -g) /$MOUNTPOINTS/$disk + mount /dev/$disk /$MOUNTPOINTS/$disk + bashio::log.info "Success! $disk mounted to /$MOUNTPOINTS/$disk" || + # Error message and clean remaining folder + (bashio::log.warning "Unable to mount local drives!" && + rmdir /$MOUNTPOINTS/$disk) + done fi diff --git a/qbittorrent/rootfs/etc/cont-init.d/92-local_mounts.sh b/qbittorrent/rootfs/etc/cont-init.d/92-local_mounts.sh index 47b6822ae..ba2654aff 100644 --- a/qbittorrent/rootfs/etc/cont-init.d/92-local_mounts.sh +++ b/qbittorrent/rootfs/etc/cont-init.d/92-local_mounts.sh @@ -9,19 +9,19 @@ bashio::log.info 'Mounting external hdd...' # Mount local Share if configured and if Protection Mode is active if bashio::config.has_value 'localdisks'; then + MOREDISKS=$(bashio::config 'localdisks') - bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && - # Separate comma separated values - for disk in ${MOREDISKS//,/ }; do - bashio::log.info "Mount ${disk}" - mkdir -p /$MOUNTPOINTS/$disk && - if [ ! -d /$MOUNTPOINTS/$disk ]; then - echo "Creating /$MOUNTPOINTS/$disk" - mkdir -p /$MOUNTPOINTS/$disk - chown -R abc:abc /$MOUNTPOINTS/$disk - fi - mount /dev/$disk /$MOUNTPOINTS/$disk && - bashio::log.info "Success! Mounted to /$MOUNTPOINTS/$disk" - done || - bashio::log.warning "Unable to mount local drives!" + bashio::log.info "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + # Mount each disk + mkdir -p /$MOUNTPOINTS/$disk + chown -R $(id -u):$(id -g) /$MOUNTPOINTS/$disk + mount /dev/$disk /$MOUNTPOINTS/$disk + bashio::log.info "Success! $disk mounted to /$MOUNTPOINTS/$disk" || + # Error message and clean remaining folder + (bashio::log.warning "Unable to mount local drives!" && + rmdir /$MOUNTPOINTS/$disk) + done fi diff --git a/radarr/root/etc/cont-init.d/00-ha-env b/radarr/root/etc/cont-init.d/00-ha-env index 3b3e69246..d0b511f60 100644 --- a/radarr/root/etc/cont-init.d/00-ha-env +++ b/radarr/root/etc/cont-init.d/00-ha-env @@ -1,5 +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 + printf "$(bashio::config $k)" >/var/run/s6/container_environment/$k +done diff --git a/radarr/root/etc/cont-init.d/92-local_mounts.sh b/radarr/root/etc/cont-init.d/92-local_mounts.sh index f29116820..c6eb07628 100644 --- a/radarr/root/etc/cont-init.d/92-local_mounts.sh +++ b/radarr/root/etc/cont-init.d/92-local_mounts.sh @@ -9,19 +9,19 @@ bashio::log.info 'Mounting external hdd...' # Mount local Share if configured and if Protection Mode is active if bashio::config.has_value 'localdisks'; then + MOREDISKS=$(bashio::config 'localdisks') - bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && - # Separate comma separated values - for disk in ${MOREDISKS//,/ }; do - bashio::log.info "Mount ${disk}" - mkdir -p /$MOUNTPOINTS/$disk && - if [ ! -d /$MOUNTPOINTS/$disk ]; then - echo "Creating /$MOUNTPOINTS/$disk" - mkdir -p /$MOUNTPOINTS/$disk - chown -R abc:abc /$MOUNTPOINTS/$disk - fi - mount /dev/$disk /$MOUNTPOINTS/$disk && - bashio::log.info "Success! Mounted to /$MOUNTPOINTS/$disk" - done || - bashio::log.warning "Unable to mount local drives!" + bashio::log.info "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + # Mount each disk + mkdir -p /$MOUNTPOINTS/$disk + chown -R $(id -u):$(id -g) /$MOUNTPOINTS/$disk + mount /dev/$disk /$MOUNTPOINTS/$disk + bashio::log.info "Success! $disk mounted to /$MOUNTPOINTS/$disk" || + # Error message and clean remaining folder + (bashio::log.warning "Unable to mount local drives!" && + rmdir /$MOUNTPOINTS/$disk) + done fi diff --git a/readarr/root/etc/cont-init.d/92-local_mounts.sh b/readarr/root/etc/cont-init.d/92-local_mounts.sh index f29116820..c6eb07628 100644 --- a/readarr/root/etc/cont-init.d/92-local_mounts.sh +++ b/readarr/root/etc/cont-init.d/92-local_mounts.sh @@ -9,19 +9,19 @@ bashio::log.info 'Mounting external hdd...' # Mount local Share if configured and if Protection Mode is active if bashio::config.has_value 'localdisks'; then + MOREDISKS=$(bashio::config 'localdisks') - bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && - # Separate comma separated values - for disk in ${MOREDISKS//,/ }; do - bashio::log.info "Mount ${disk}" - mkdir -p /$MOUNTPOINTS/$disk && - if [ ! -d /$MOUNTPOINTS/$disk ]; then - echo "Creating /$MOUNTPOINTS/$disk" - mkdir -p /$MOUNTPOINTS/$disk - chown -R abc:abc /$MOUNTPOINTS/$disk - fi - mount /dev/$disk /$MOUNTPOINTS/$disk && - bashio::log.info "Success! Mounted to /$MOUNTPOINTS/$disk" - done || - bashio::log.warning "Unable to mount local drives!" + bashio::log.info "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + # Mount each disk + mkdir -p /$MOUNTPOINTS/$disk + chown -R $(id -u):$(id -g) /$MOUNTPOINTS/$disk + mount /dev/$disk /$MOUNTPOINTS/$disk + bashio::log.info "Success! $disk mounted to /$MOUNTPOINTS/$disk" || + # Error message and clean remaining folder + (bashio::log.warning "Unable to mount local drives!" && + rmdir /$MOUNTPOINTS/$disk) + done fi diff --git a/scrutiny/rootfs/etc/cont-init.d/31-run b/scrutiny/rootfs/etc/cont-init.d/31-run.sh similarity index 100% rename from scrutiny/rootfs/etc/cont-init.d/31-run rename to scrutiny/rootfs/etc/cont-init.d/31-run.sh diff --git a/scrutiny/rootfs/etc/cont-init.d/32-nginx b/scrutiny/rootfs/etc/cont-init.d/32-nginx.sh similarity index 100% rename from scrutiny/rootfs/etc/cont-init.d/32-nginx rename to scrutiny/rootfs/etc/cont-init.d/32-nginx.sh diff --git a/sonarr/root/etc/cont-init.d/92-local_mounts.sh b/sonarr/root/etc/cont-init.d/92-local_mounts.sh index f29116820..c6eb07628 100644 --- a/sonarr/root/etc/cont-init.d/92-local_mounts.sh +++ b/sonarr/root/etc/cont-init.d/92-local_mounts.sh @@ -9,19 +9,19 @@ bashio::log.info 'Mounting external hdd...' # Mount local Share if configured and if Protection Mode is active if bashio::config.has_value 'localdisks'; then + MOREDISKS=$(bashio::config 'localdisks') - bashio::log.info "Local Disks mounting.. ${MOREDISKS}" && - # Separate comma separated values - for disk in ${MOREDISKS//,/ }; do - bashio::log.info "Mount ${disk}" - mkdir -p /$MOUNTPOINTS/$disk && - if [ ! -d /$MOUNTPOINTS/$disk ]; then - echo "Creating /$MOUNTPOINTS/$disk" - mkdir -p /$MOUNTPOINTS/$disk - chown -R abc:abc /$MOUNTPOINTS/$disk - fi - mount /dev/$disk /$MOUNTPOINTS/$disk && - bashio::log.info "Success! Mounted to /$MOUNTPOINTS/$disk" - done || - bashio::log.warning "Unable to mount local drives!" + bashio::log.info "Local Disks mounting..." + + # Separate comma separated values + for disk in ${MOREDISKS//,/ }; do + # Mount each disk + mkdir -p /$MOUNTPOINTS/$disk + chown -R $(id -u):$(id -g) /$MOUNTPOINTS/$disk + mount /dev/$disk /$MOUNTPOINTS/$disk + bashio::log.info "Success! $disk mounted to /$MOUNTPOINTS/$disk" || + # Error message and clean remaining folder + (bashio::log.warning "Unable to mount local drives!" && + rmdir /$MOUNTPOINTS/$disk) + done fi diff --git a/ubooquity/rootfs/etc/cont-init.d/93-custom_webUI b/ubooquity/rootfs/etc/cont-init.d/93-custom_webUI.sh similarity index 100% rename from ubooquity/rootfs/etc/cont-init.d/93-custom_webUI rename to ubooquity/rootfs/etc/cont-init.d/93-custom_webUI.sh