mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-04 06:44:06 +02:00
Update 00-smb_mounts.sh
This commit is contained in:
@@ -16,6 +16,8 @@ if bashio::config.has_value 'networkdisks'; then
|
|||||||
SMBVERS=""
|
SMBVERS=""
|
||||||
SMBDEFAULT=""
|
SMBDEFAULT=""
|
||||||
SECVERS=""
|
SECVERS=""
|
||||||
|
CHARSET=""
|
||||||
|
DOMAINVAR=""
|
||||||
|
|
||||||
# Clean data
|
# Clean data
|
||||||
MOREDISKS=${MOREDISKS// \/\//,\/\/}
|
MOREDISKS=${MOREDISKS// \/\//,\/\/}
|
||||||
@@ -60,9 +62,13 @@ if bashio::config.has_value 'networkdisks'; then
|
|||||||
break 2
|
break 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Prepare mount point
|
||||||
|
mkdir -p /mnt/"$diskname"
|
||||||
|
chown root:root /mnt/"$diskname"
|
||||||
|
|
||||||
# Extract ip part of server for further manipulation
|
# Extract ip part of server for further manipulation
|
||||||
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]+")"
|
||||||
|
|
||||||
# Does server exists
|
# Does server exists
|
||||||
if command -v "nc" &>/dev/null; then
|
if command -v "nc" &>/dev/null; then
|
||||||
# test if smb port is open
|
# test if smb port is open
|
||||||
@@ -79,17 +85,20 @@ if bashio::config.has_value 'networkdisks'; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Quickly try to mount with defaults
|
||||||
|
mount -t cifs -o "rw,file_mode=0775,dir_mode=0775,username=$CIFS_USERNAME,password=${CIFS_PASSWORD},nobrl$SMBVERS$SECVERS$PUID$PGID$CHARSET$DOMAINVAR" "$disk" /mnt/"$diskname" 2>ERRORCODE \
|
||||||
|
&& MOUNTED=true && MOUNTOPTIONS="$SMBVERS$SECVERS$PUID$PGID$CHARSET$DOMAINVAR" || MOUNTED=false
|
||||||
|
|
||||||
|
# Deeper analysis if failed
|
||||||
|
if [ "$MOUNTED" = false ]; then
|
||||||
|
|
||||||
# Try smbv1
|
# Try smbv1
|
||||||
if smbclient -t 2 -L "$server" -m NT1 -N &>/dev/null; then
|
if smbclient -t 2 -L "$server" -m NT1 -N &>/dev/null; then
|
||||||
echo "... only SMBv1 is supported, trying it"
|
echo "... only SMBv1 is supported, trying it"
|
||||||
SMBDEFAULT=",vers=1.0"
|
SMBDEFAULT=",vers=1.0"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Prepare mount point
|
|
||||||
mkdir -p /mnt/"$diskname"
|
|
||||||
chown root:root /mnt/"$diskname"
|
|
||||||
|
|
||||||
# if Fail test different smb and sec versions
|
# if Fail test different smb and sec versions
|
||||||
echo "... looking for the optimal parameters for mounting"
|
echo "... looking for the optimal parameters for mounting"
|
||||||
if [ "$MOUNTED" = false ]; then
|
if [ "$MOUNTED" = false ]; then
|
||||||
@@ -128,6 +137,8 @@ if bashio::config.has_value 'networkdisks'; then
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
# Messages
|
# Messages
|
||||||
if [ "$MOUNTED" = true ] && mountpoint -q /mnt/"$diskname"; then
|
if [ "$MOUNTED" = true ] && mountpoint -q /mnt/"$diskname"; then
|
||||||
#Test write permissions
|
#Test write permissions
|
||||||
|
|||||||
Reference in New Issue
Block a user