3 Commits

Author SHA1 Message Date
github-actions
b1f85a37e2 GitHub bot: changelog 2026-01-06 16:16:11 +00:00
Alexandre
9a678a5e78 Update config.yaml 2026-01-06 17:11:58 +01:00
Alexandre
5fbf733a68 Refactor SMB mount script for clarity and error handling
Refactor SMB mount script to improve readability and error handling. Added cleanup for credential files and enhanced logging for mount operations.
2026-01-06 17:11:28 +01:00
3 changed files with 180 additions and 149 deletions

View File

@@ -1,6 +1,7 @@
#!/usr/bin/with-contenv bashio #!/usr/bin/with-contenv bashio
# shellcheck shell=bash # shellcheck shell=bash
# shellcheck disable= # shellcheck disable=SC2086,SC2001,SC2015,SC2154
set -e set -e
if ! bashio::supervisor.ping 2>/dev/null; then if ! bashio::supervisor.ping 2>/dev/null; then
@@ -14,65 +15,72 @@ bashio::log.notice "This script is used to mount remote smb/cifs/nfs shares. Ins
# DEFINE FUNCTIONS # # DEFINE FUNCTIONS #
#################### ####################
test_mount() { cleanup_cred() {
if [[ -n "${CRED_FILE:-}" && -f "${CRED_FILE:-}" ]]; then
rm -f "$CRED_FILE" || true
fi
CRED_FILE=""
}
test_mount() {
# Set initial test # Set initial test
MOUNTED=false MOUNTED=false
ERROR_MOUNT=false ERROR_MOUNT=false
# Exit if not mounted # Exit if not mounted
if ! mountpoint -q /mnt/"$diskname"; then if ! mountpoint -q "/mnt/$diskname"; then
return 0 return 0
fi fi
# Exit if can't write # Exit if can't write
[[ -e "/mnt/$diskname/testaze" ]] && rm -r "/mnt/$diskname/testaze" [[ -e "/mnt/$diskname/testaze" ]] && rm -rf "/mnt/$diskname/testaze"
# shellcheck disable=SC2015 mkdir "/mnt/$diskname/testaze" && touch "/mnt/$diskname/testaze/testaze" && rm -rf "/mnt/$diskname/testaze" || ERROR_MOUNT=true
mkdir "/mnt/$diskname/testaze" && touch "/mnt/$diskname/testaze/testaze" && rm -r "/mnt/$diskname/testaze" || ERROR_MOUNT=true
# Only CIFS has the noserverino fallback # Only CIFS has the noserverino fallback
if [[ "$ERROR_MOUNT" == "true" && "$FSTYPE" == "cifs" ]]; then if [[ "$ERROR_MOUNT" == "true" && "$FSTYPE" == "cifs" ]]; then
# Test write permissions
if [[ "$MOUNTOPTIONS" == *"noserverino"* ]]; then if [[ "$MOUNTOPTIONS" == *"noserverino"* ]]; then
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" 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 else
MOUNTOPTIONS="$MOUNTOPTIONS,noserverino" MOUNTOPTIONS="${MOUNTOPTIONS},noserverino"
echo "... testing with noserverino" echo "... testing with noserverino"
mount_drive "$MOUNTOPTIONS" mount_drive "$MOUNTOPTIONS"
return 0 return 0
fi fi
fi fi
# CRITICAL: for non-CIFS too, do not claim success if mounted but not writable
if [[ "$ERROR_MOUNT" == "true" ]]; then
MOUNTED=false
bashio::log.fatal "Disk is mounted, however unable to write in the shared disk. Please check permissions/export options (rw), and UID/GID mapping."
return 0
fi
# Set correctly mounted bit # Set correctly mounted bit
MOUNTED=true MOUNTED=true
return 0 return 0
} }
mount_drive() { mount_drive() {
# Define options # Define options
MOUNTED=true MOUNTED=true
MOUNTOPTIONS="$1" MOUNTOPTIONS="$1"
# Try mounting (type depends on detected FSTYPE) # Try mounting (type depends on (detected) FSTYPE)
if [[ "$FSTYPE" == "cifs" ]]; then if [[ "$FSTYPE" == "cifs" ]]; then
mount -t cifs -o "$MOUNTOPTIONS" "$disk" /mnt/"$diskname" 2> ERRORCODE || MOUNTED=false mount -t cifs -o "$MOUNTOPTIONS" "$disk" "/mnt/$diskname" 2>"$ERRORCODE_FILE" || MOUNTED=false
elif [[ "$FSTYPE" == "nfs" ]]; then elif [[ "$FSTYPE" == "nfs" ]]; then
mount -t nfs -o "$MOUNTOPTIONS" "$disk" /mnt/"$diskname" 2> ERRORCODE || MOUNTED=false mount -t nfs -o "$MOUNTOPTIONS" "$disk" "/mnt/$diskname" 2>"$ERRORCODE_FILE" || MOUNTED=false
fi fi
# Test if successful # Test if successful
if [[ "$MOUNTED" == "true" ]]; then if [[ "$MOUNTED" == "true" ]]; then
# shellcheck disable=SC2015
test_mount test_mount
fi fi
} }
#################### ########################
# MOUNT NETWORK SHARES # # MOUNT NETWORK SHARES #
#################### ########################
if bashio::config.has_value 'networkdisks'; then if bashio::config.has_value 'networkdisks'; then
@@ -83,16 +91,16 @@ if bashio::config.has_value 'networkdisks'; then
bashio::log.warning "------------------------" bashio::log.warning "------------------------"
fi fi
echo 'Mounting network share(s)...' echo "Mounting network share(s)..."
#################### ####################
# Define variables # # Define variables #
#################### ####################
# Set variables MOREDISKS="$(bashio::config 'networkdisks')"
MOREDISKS=$(bashio::config 'networkdisks') USERNAME="$(bashio::config 'cifsusername')"
USERNAME=$(bashio::config 'cifsusername') PASSWORD="$(bashio::config 'cifspassword')"
PASSWORD=$(bashio::config 'cifspassword')
SMBVERS="" SMBVERS=""
SECVERS="" SECVERS=""
CHARSET=",iocharset=utf8" CHARSET=",iocharset=utf8"
@@ -103,15 +111,15 @@ if bashio::config.has_value 'networkdisks'; then
MOREDISKS=${MOREDISKS// /"\040"} MOREDISKS=${MOREDISKS// /"\040"}
# Is domain set (CIFS only) # Is domain set (CIFS only)
DOMAIN=""
DOMAINCLIENT="" DOMAINCLIENT=""
CIFSDOMAIN=""
if bashio::config.has_value 'cifsdomain'; then if bashio::config.has_value 'cifsdomain'; then
echo "... using domain $(bashio::config 'cifsdomain')" CIFSDOMAIN="$(bashio::config 'cifsdomain')"
DOMAIN=",domain=$(bashio::config 'cifsdomain')" echo "... using domain $CIFSDOMAIN"
DOMAINCLIENT="--workgroup=$(bashio::config 'cifsdomain')" DOMAINCLIENT="--workgroup=$CIFSDOMAIN"
fi fi
# Is UID/GID set (used for CIFS mount options) # UID/GID (used for CIFS mount options)
PUID=",uid=$(id -u)" PUID=",uid=$(id -u)"
PGID=",gid=$(id -g)" PGID=",gid=$(id -g)"
if bashio::config.has_value 'PUID' && bashio::config.has_value 'PGID'; then if bashio::config.has_value 'PUID' && bashio::config.has_value 'PGID'; then
@@ -124,15 +132,15 @@ if bashio::config.has_value 'networkdisks'; then
# Mounting disks # # Mounting disks #
################## ##################
# shellcheck disable=SC2086 for disk in ${MOREDISKS//,/ }; do
for disk in ${MOREDISKS//,/ }; do # Separate comma separated values CRED_FILE=""
cleanup_cred
# Clean name of network share # Clean name of network share
# shellcheck disable=SC2116,SC2001 disk="$(echo "$disk" | sed "s,/$,,")" # Remove trailing /
disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name
disk="${disk//"\040"/ }" # replace \040 with space disk="${disk//"\040"/ }" # replace \040 with space
# Detect filesystem type by pattern (CIFS: //ip/share ; NFS: ip:/export[/path] or nfs://ip:/export[/path]) # Detect filesystem type by pattern
FSTYPE="cifs" FSTYPE="cifs"
if [[ "$disk" =~ ^nfs:// ]]; then if [[ "$disk" =~ ^nfs:// ]]; then
FSTYPE="nfs" FSTYPE="nfs"
@@ -143,78 +151,98 @@ if bashio::config.has_value 'networkdisks'; then
# Determine server for reachability checks # Determine server for reachability checks
if [[ "$FSTYPE" == "cifs" ]]; then if [[ "$FSTYPE" == "cifs" ]]; then
server="$(echo "$disk" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+")" server="$(echo "$disk" | grep -E -o "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" | head -n 1)"
else else
server="${disk%%:*}" server="${disk%%:*}"
fi fi
diskname="$disk" diskname="$disk"
diskname="${diskname//\\//}" # replace \ with / diskname="${diskname//\\//}" # replace \ with /
diskname="${diskname##*/}" # Get only last part of the name diskname="${diskname##*/}" # keep only last part of the name
# CRITICAL: per-disk error file (avoid collisions / missing file reads)
ERRORCODE_FILE="/tmp/mount_error_${diskname//[^a-zA-Z0-9._-]/_}.log"
: >"$ERRORCODE_FILE" || true
MOUNTED=false MOUNTED=false
SMBVERS_FORCE="" SMBVERS_FORCE=""
SECVERS_FORCE="" SECVERS_FORCE=""
SMBVERS=""
SECVERS=""
# Start
echo "... mounting ($FSTYPE) $disk" echo "... mounting ($FSTYPE) $disk"
# Data validation # Data validation
if [[ "$FSTYPE" == "cifs" ]]; then if [[ "$FSTYPE" == "cifs" ]]; then
if [[ ! "$disk" =~ ^.*+[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+[/]+.*+$ ]]; then 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." 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."
touch ERRORCODE echo "Invalid CIFS path structure: $disk" >"$ERRORCODE_FILE" || true
continue continue
fi fi
else else
if [[ ! "$disk" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:/.+ ]]; then if [[ ! "$disk" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+:/.+ ]]; then
bashio::log.fatal "...... invalid NFS path \"$disk\". Use a structure like 123.12.12.12:/export/path" bashio::log.fatal "...... invalid NFS path \"$disk\". Use a structure like 123.12.12.12:/export/path"
touch ERRORCODE echo "Invalid NFS path structure: $disk" >"$ERRORCODE_FILE" || true
continue continue
fi fi
fi fi
# Prepare mount point # Prepare mount point
mkdir -p /mnt/"$diskname" mkdir -p "/mnt/$diskname"
chown root:root /mnt/"$diskname" chown root:root "/mnt/$diskname"
# Create credentials file only for CIFS (avoids comma/special-char issues in -o)
if [[ "$FSTYPE" == "cifs" ]]; then
CRED_FILE="$(mktemp /tmp/cifs-cred.XXXXXX)"
chmod 600 "$CRED_FILE"
{
printf 'username=%s\n' "$USERNAME"
printf 'password=%s\n' "$PASSWORD"
if [[ -n "${CIFSDOMAIN:-}" ]]; then
printf 'domain=%s\n' "$CIFSDOMAIN"
fi
} >"$CRED_FILE"
fi
# Quickly try to mount with defaults # Quickly try to mount with defaults
if [[ "$FSTYPE" == "cifs" ]]; then if [[ "$FSTYPE" == "cifs" ]]; then
mount_drive "rw,file_mode=0775,dir_mode=0775,username=${USERNAME},password=${PASSWORD},nobrl,mfsymlinks${SMBVERS}${SECVERS}${PUID}${PGID}${CHARSET}${DOMAIN}" mount_drive "rw,file_mode=0775,dir_mode=0775,credentials=${CRED_FILE},nobrl,mfsymlinks${SMBVERS}${SECVERS}${PUID}${PGID}${CHARSET}"
elif [[ "$FSTYPE" == "nfs" ]]; then else
mount_drive "rw,nfsvers=4.2,proto=tcp,hard,timeo=600,retrans=2" mount_drive "rw,nfsvers=4.2,proto=tcp,hard,timeo=600,retrans=2"
fi fi
# Deeper analysis if failed # Deeper analysis if failed
if [ "$MOUNTED" = false ]; then if [[ "$MOUNTED" == "false" ]]; then
if [[ "$FSTYPE" == "cifs" ]]; then if [[ "$FSTYPE" == "cifs" ]]; then
# Does server exist (SMB port 445) # Does server exist (SMB port 445)
output="$(nmap -F $server -T5 -oG -)" if command -v nmap >/dev/null 2>&1; then
if ! echo "$output" | grep 445/open &> /dev/null; then output="$(nmap -F "$server" -T5 -oG - 2>/dev/null || true)"
if echo "$output" | grep /open &> /dev/null; then if ! echo "$output" | grep -q "445/open"; then
if echo "$output" | grep -q "/open"; then
bashio::log.fatal "...... $server is reachable but SMB port not opened, stopping script" bashio::log.fatal "...... $server is reachable but SMB port not opened, stopping script"
touch ERRORCODE
continue
else else
bashio::log.fatal "...... fatal : $server not reachable, is it correct" bashio::log.fatal "...... fatal : $server not reachable, is it correct"
touch ERRORCODE
continue
fi fi
cleanup_cred
continue
else else
echo "...... $server is confirmed reachable" echo "...... $server is confirmed reachable"
fi fi
else
bashio::log.warning "...... nmap not available; skipping SMB port reachability test"
fi
# Are credentials correct (use server, not share path)
if command -v smbclient >/dev/null 2>&1; then
OUTPUT="$(smbclient -t 2 -L "$server" -U "$USERNAME"%"$PASSWORD" -c "exit" $DOMAINCLIENT 2>&1 || true)"
# Are credentials correct
OUTPUT="$(smbclient -t 2 -L "$disk" -U "$USERNAME"%"$PASSWORD" -c "exit" $DOMAINCLIENT 2>&1 || true)"
if echo "$OUTPUT" | grep -q "LOGON_FAILURE"; then if echo "$OUTPUT" | grep -q "LOGON_FAILURE"; then
bashio::log.fatal "...... incorrect Username, Password, or Domain! Script will stop." bashio::log.fatal "...... incorrect Username, Password, or Domain! Script will stop."
touch ERRORCODE if ! smbclient -t 2 -L "$server" -N $DOMAINCLIENT -c "exit" &>/dev/null; then
# Should there be a workgroup
if ! smbclient -t 2 -L $disk -N $DOMAINCLIENT -c "exit" &> /dev/null; then
bashio::log.fatal "...... perhaps a workgroup must be specified" bashio::log.fatal "...... perhaps a workgroup must be specified"
touch ERRORCODE
fi fi
cleanup_cred
continue continue
elif echo "$OUTPUT" | grep -q "tree connect failed" || echo "$OUTPUT" | grep -q "NT_STATUS_CONNECTION_DISCONNECTED"; then elif echo "$OUTPUT" | grep -q "tree connect failed" || echo "$OUTPUT" | grep -q "NT_STATUS_CONNECTION_DISCONNECTED"; then
echo "... using SMBv1" echo "... using SMBv1"
@@ -227,35 +255,35 @@ if bashio::config.has_value 'networkdisks'; then
else else
echo "...... credentials are valid" echo "...... credentials are valid"
fi fi
else
bashio::log.warning "...... smbclient not available; skipping SMB credential test"
fi
# Extracting SMB versions and normalize output # Extract SMB dialect from nmap and map to mount.cifs vers=
# shellcheck disable=SC2210,SC2094 SMBRAW=""
SMBVERS="$(nmap --script smb-protocols "$server" -p 445 2> 1 | awk '/ [0-9]/' | awk '{print $NF}' | cut -c -3 | sort -V | tail -n 1 || true)" if command -v nmap >/dev/null 2>&1; then
# Avoid : SMBRAW="$(
SMBVERS="${SMBVERS/:/.}" nmap --script smb-protocols -p 445 "$server" 2>/dev/null \
# Manage output | awk '/SMB2_DIALECT_/ {print $NF}' \
if [ -n "$SMBVERS" ]; then | sed 's/SMB2_DIALECT_//' \
case $SMBVERS in | tr -d '_' \
"202" | "200" | "20") | sort -V | tail -n 1 || true
SMBVERS="2.0" )"
;; fi
21)
SMBVERS="2.1" SMBVERS=""
;; case "$SMBRAW" in
302) 311) SMBVERS=",vers=3.1.1" ;;
SMBVERS="3.02" 302) SMBVERS=",vers=3.02" ;;
;; 300) SMBVERS=",vers=3.0" ;;
311) 210) SMBVERS=",vers=2.1" ;;
SMBVERS="3.1.1" 202|200) SMBVERS=",vers=2.0" ;;
;; *) SMBVERS="" ;;
"3.1")
echo "SMB 3.1 detected, converting to 3.0"
SMBVERS="3.0"
;;
esac esac
echo "...... SMB version detected : $SMBVERS"
SMBVERS=",vers=$SMBVERS" if [[ -n "$SMBVERS" ]]; then
elif smbclient -t 2 -L "$server" -m NT1 -N $DOMAINCLIENT &> /dev/null; then echo "...... SMB version detected : ${SMBVERS#,vers=}"
elif command -v smbclient >/dev/null 2>&1 && smbclient -t 2 -L "$server" -m NT1 -N $DOMAINCLIENT &>/dev/null; then
echo "...... SMB version : only SMBv1 is supported, this can lead to issues" echo "...... SMB version : only SMBv1 is supported, this can lead to issues"
SECVERS=",sec=ntlm" SECVERS=",sec=ntlm"
SMBVERS=",vers=1.0" SMBVERS=",vers=1.0"
@@ -264,94 +292,95 @@ if bashio::config.has_value 'networkdisks'; then
SMBVERS="" SMBVERS=""
fi fi
# Apply forced SMBv1 options when initial connection required NT1 fallback # Apply forced SMBv1 options when needed
if [[ -n "$SMBVERS_FORCE" ]]; then if [[ -n "$SMBVERS_FORCE" ]]; then
if [[ -z "$SMBVERS" ]]; then [[ -z "$SMBVERS" ]] && SMBVERS="$SMBVERS_FORCE"
SMBVERS="$SMBVERS_FORCE" [[ -z "$SECVERS" ]] && SECVERS="$SECVERS_FORCE"
fi
if [[ -z "$SECVERS" ]]; then
SECVERS="$SECVERS_FORCE"
fi
fi fi
# Ensure the Samba client allows SMBv1 when those options are required # Ensure Samba client allows SMBv1 when required
if [[ "${SMBVERS}${SMBVERS_FORCE}" == *"vers=1.0"* ]]; then if [[ "${SMBVERS}${SMBVERS_FORCE}" == *"vers=1.0"* ]]; then
if [[ -f /etc/samba/smb.conf ]]; then if [[ -f /etc/samba/smb.conf ]]; then
bashio::log.warning "...... enabling SMBv1 support in Samba client configuration" bashio::log.warning "...... enabling SMBv1 support in Samba client configuration"
sed -i '/\[global\]/!b;n;/client min protocol = NT1/!a\ sed -i '/\[global\]/!b;n;/client min protocol = NT1/!a\
client min protocol = NT1' /etc/samba/smb.conf client min protocol = NT1' /etc/samba/smb.conf || true
fi fi
fi fi
# Test with different security versions # Try with different security modes (do not overwrite SECVERS base accidentally)
####################################### SECVERS_BASE="$SECVERS"
for SECVERS in "$SECVERS" ",sec=ntlmv2" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=krb5i" ",sec=krb5" ",sec=ntlm" ",sec=ntlmv2i"; do for SECTRY in "$SECVERS_BASE" ",sec=ntlmv2" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=krb5i" ",sec=krb5" ",sec=ntlm" ",sec=ntlmv2i"; do
if [ "$MOUNTED" = false ]; then if [[ "$MOUNTED" == "false" ]]; then
mount_drive "rw,file_mode=0775,dir_mode=0775,username=${USERNAME},password=${PASSWORD},nobrl${SMBVERS}${SECVERS}${PUID}${PGID}${CHARSET}${DOMAIN}" mount_drive "rw,file_mode=0775,dir_mode=0775,credentials=${CRED_FILE},nobrl,mfsymlinks${SMBVERS}${SECTRY}${PUID}${PGID}${CHARSET}"
fi fi
done done
elif [[ "$FSTYPE" == "nfs" ]]; then else
# Add NFS-specific port check (2049) similar to SMB (445) # NFS: check ports (111/2049) and try common versions
output="$(nmap -F $server -T5 -oG -)" if command -v nmap >/dev/null 2>&1; then
if ! echo "$output" | grep -E '(2049|111)/open' &> /dev/null; then output="$(nmap -F "$server" -T5 -oG - 2>/dev/null || true)"
if ! echo "$output" | grep -Eq '(2049|111)/open'; then
bashio::log.fatal "...... $server is reachable but NFS ports not open" bashio::log.fatal "...... $server is reachable but NFS ports not open"
continue continue
fi fi
# NFS fallback attempts: try common versions until one works else
bashio::log.warning "...... nmap not available; skipping NFS port reachability test"
fi
for NFVER in 4.2 4.1 4 3; do for NFVER in 4.2 4.1 4 3; do
if [ "$MOUNTED" = false ]; then if [[ "$MOUNTED" == "false" ]]; then
mount_drive "rw,nfsvers=${NFVER},proto=tcp" mount_drive "rw,nfsvers=${NFVER},proto=tcp"
fi fi
done done
fi fi
fi fi
# Messages # Messages / finalization
if [ "$MOUNTED" = true ]; then if [[ "$MOUNTED" == "true" ]]; then
bashio::log.info "...... $disk successfully mounted to /mnt/$diskname with options ${MOUNTOPTIONS/$PASSWORD/XXXXXXXXXX}" bashio::log.info "...... $disk successfully mounted to /mnt/$diskname with options ${MOUNTOPTIONS/$PASSWORD/XXXXXXXXXX}"
# Remove errorcode rm -f "$ERRORCODE_FILE" 2>/dev/null || true
if [ -f ERRORCODE ]; then
rm ERRORCODE
fi
# Alert if smbv1 if [[ "$FSTYPE" == "cifs" && "$MOUNTOPTIONS" == *"vers=1.0"* ]]; then
if [[ "$FSTYPE" == "cifs" && "$MOUNTOPTIONS" == *"1.0"* ]]; then
bashio::log.warning "" bashio::log.warning ""
bashio::log.warning "Your smb system requires smbv1. This is an obsolete protocol. Please correct this to prevent issues." bashio::log.warning "Your SMB system requires SMBv1. This is an obsolete protocol. Please correct this to prevent issues."
bashio::log.warning "" bashio::log.warning ""
fi fi
cleanup_cred
else else
# Mounting failed messages # Mounting failed messages
if [[ "$FSTYPE" == "cifs" ]]; then if [[ "$FSTYPE" == "cifs" ]]; then
bashio::log.fatal "Error, unable to mount $disk to /mnt/$diskname with username $USERNAME, $PASSWORD. Please check your remote share path, username, password, domain, try putting 0 in UID and GID" bashio::log.fatal "Error, unable to mount $disk to /mnt/$diskname with username $USERNAME. Please check remote share path, username, password, domain; try UID/GID 0."
bashio::log.fatal "Here is some debugging info :" bashio::log.fatal "Here is some debugging info :"
smbclient -t 2 -L $disk -U "$USERNAME%$PASSWORD" -c "exit" if command -v smbclient >/dev/null 2>&1; then
smbclient -t 2 -L "$server" -U "$USERNAME%$PASSWORD" -c "exit" $DOMAINCLIENT || true
else
bashio::log.warning "smbclient not available; cannot print SMB debugging info"
fi
# last-ditch try: minimal options (still uses credentials file)
SMBVERS="" SMBVERS=""
SECVERS="" SECVERS=""
PUID="" PUID=""
PGID="" PGID=""
CHARSET="" CHARSET=""
mount_drive "rw,file_mode=0775,dir_mode=0775,username=${USERNAME},password=${PASSWORD},nobrl${SMBVERS}${SECVERS}${PUID}${PGID}${CHARSET}${DOMAIN}" mount_drive "rw,file_mode=0775,dir_mode=0775,credentials=${CRED_FILE},nobrl,mfsymlinks${SMBVERS}${SECVERS}${PUID}${PGID}${CHARSET}"
elif [[ "$FSTYPE" == "nfs" ]]; then else
bashio::log.fatal "Error, unable to mount NFS share $disk to /mnt/$diskname. Please check the export path and that NFS server allows this client (and NFSv4)." bashio::log.fatal "Error, unable to mount NFS share $disk to /mnt/$diskname. Please check the export path and that the NFS server allows this client (and NFSv4)."
# last-ditch try with very basic options
mount_drive "rw" mount_drive "rw"
fi fi
bashio::log.fatal "Error read : $(< ERRORCODE), addon will stop in 1 min" ERR_READ="$(cat "$ERRORCODE_FILE" 2>/dev/null || true)"
bashio::log.fatal "Error read : ${ERR_READ:-unknown error}, addon will stop in 1 min"
# clean folder # clean folder
umount "/mnt/$diskname" 2>/dev/null || true umount "/mnt/$diskname" 2>/dev/null || true
rmdir "/mnt/$diskname" || true rmdir "/mnt/$diskname" 2>/dev/null || true
cleanup_cred
rm -f "$ERRORCODE_FILE" 2>/dev/null || true
# Stop addon # Stop addon
bashio::addon.stop bashio::addon.stop
fi fi
done done
fi fi

View File

@@ -1,3 +1,5 @@
## 32.0.3-2 (06-01-2026)
- Minor bugs fixed
## 32.0.3 (13-12-2025) ## 32.0.3 (13-12-2025)
- Update to latest version from linuxserver/docker-nextcloud (changelog : https://github.com/linuxserver/docker-nextcloud/releases) - Update to latest version from linuxserver/docker-nextcloud (changelog : https://github.com/linuxserver/docker-nextcloud/releases)

View File

@@ -151,5 +151,5 @@ slug: nextcloud_ocr
uart: true uart: true
udev: true udev: true
url: https://github.com/alexbelgium/hassio-addons/tree/master/nextcloud url: https://github.com/alexbelgium/hassio-addons/tree/master/nextcloud
version: "32.0.3" version: 32.0.3-2
webui: https://[HOST]:[PORT:443] webui: https://[HOST]:[PORT:443]