mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-07-08 23:10:59 +02:00
Github bot : script beautyshied
This commit is contained in:
@@ -84,7 +84,7 @@ if bashio::config.has_value 'networkdisks'; then
|
|||||||
|
|
||||||
# Quickly try to mount with defaults
|
# Quickly try to mount with defaults
|
||||||
mount -t cifs -o "rw,file_mode=0775,dir_mode=0775,username=$USERNAME,password=${PASSWORD},nobrl$SMBVERS$SECVERS$PUID$PGID$CHARSET$DOMAIN" "$disk" /mnt/"$diskname" 2>/dev/null \
|
mount -t cifs -o "rw,file_mode=0775,dir_mode=0775,username=$USERNAME,password=${PASSWORD},nobrl$SMBVERS$SECVERS$PUID$PGID$CHARSET$DOMAIN" "$disk" /mnt/"$diskname" 2>/dev/null \
|
||||||
&& MOUNTED=true && MOUNTOPTIONS="$SMBVERS$SECVERS$PUID$PGID$CHARSET$DOMAIN" || MOUNTED=false
|
&& MOUNTED=true && MOUNTOPTIONS="$SMBVERS$SECVERS$PUID$PGID$CHARSET$DOMAIN" || MOUNTED=false
|
||||||
|
|
||||||
# Deeper analysis if failed
|
# Deeper analysis if failed
|
||||||
if [ "$MOUNTED" = false ]; then
|
if [ "$MOUNTED" = false ]; then
|
||||||
@@ -113,7 +113,7 @@ if bashio::config.has_value 'networkdisks'; then
|
|||||||
bashio::log.fatal "A workgroup must perhaps be specified"
|
bashio::log.fatal "A workgroup must perhaps be specified"
|
||||||
touch ERRORCODE
|
touch ERRORCODE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Are credentials correct
|
# Are credentials correct
|
||||||
echo "... testing credentials"
|
echo "... testing credentials"
|
||||||
OUTPUT="$(smbclient -t 2 -L "$disk" -U "$USERNAME"%"$PASSWORD" -c "exit" $DOMAINCLIENT 2>&1 || true)"
|
OUTPUT="$(smbclient -t 2 -L "$disk" -U "$USERNAME"%"$PASSWORD" -c "exit" $DOMAINCLIENT 2>&1 || true)"
|
||||||
@@ -126,7 +126,7 @@ if bashio::config.has_value 'networkdisks'; then
|
|||||||
bashio::log.fatal "Invalid or inaccessible SMB path. Script will stop."
|
bashio::log.fatal "Invalid or inaccessible SMB path. Script will stop."
|
||||||
touch ERRORCODE
|
touch ERRORCODE
|
||||||
continue
|
continue
|
||||||
elif ! echo "$OUTPUT" | grep -q "Disk"; then
|
elif ! echo "$OUTPUT" | grep -q "Disk"; then
|
||||||
echo "... testing path"
|
echo "... testing path"
|
||||||
bashio::log.fatal "No shares found. Invalid or inaccessible SMB path?"
|
bashio::log.fatal "No shares found. Invalid or inaccessible SMB path?"
|
||||||
fi
|
fi
|
||||||
@@ -138,27 +138,27 @@ if bashio::config.has_value 'networkdisks'; then
|
|||||||
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)"
|
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)"
|
||||||
# Manage output
|
# Manage output
|
||||||
if [ -n "$SMBVERS" ]; then
|
if [ -n "$SMBVERS" ]; then
|
||||||
echo "... SMB version $SMBVERS detected"
|
echo "... SMB version $SMBVERS detected"
|
||||||
SMBVERS=",vers=$SMBVERS"
|
SMBVERS=",vers=$SMBVERS"
|
||||||
elif smbclient -t 2 -L "$server" -m NT1 -N $DOMAINCLIENT &>/dev/null; then
|
elif smbclient -t 2 -L "$server" -m NT1 -N $DOMAINCLIENT &>/dev/null; then
|
||||||
echo "... only SMBv1 is supported, this can lead to issues"
|
echo "... only SMBv1 is supported, this can lead to issues"
|
||||||
SECVERS=",sec=ntlm"
|
SECVERS=",sec=ntlm"
|
||||||
SMBVERS=",vers=1.0"
|
SMBVERS=",vers=1.0"
|
||||||
else
|
else
|
||||||
echo "... couldn't detect, default used"
|
echo "... couldn't detect, default used"
|
||||||
SMBVERS=""
|
SMBVERS=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test with different security versions
|
# Test with different security versions
|
||||||
#######################################
|
#######################################
|
||||||
for SECVERS in "$SECVERS" ",sec=ntlmv2" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=krb5i" ",sec=krb5" ",sec=ntlm" ",sec=ntlmv2i"; do
|
for SECVERS in "$SECVERS" ",sec=ntlmv2" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=krb5i" ",sec=krb5" ",sec=ntlm" ",sec=ntlmv2i"; do
|
||||||
if [ "$MOUNTED" = false ]; then
|
if [ "$MOUNTED" = false ]; then
|
||||||
mount -t cifs -o "rw,file_mode=0775,dir_mode=0775,username=$USERNAME,password=${PASSWORD},nobrl$SMBVERS$SECVERS$PUID$PGID$CHARSET$DOMAIN" "$disk" /mnt/"$diskname" 2>/dev/null \
|
mount -t cifs -o "rw,file_mode=0775,dir_mode=0775,username=$USERNAME,password=${PASSWORD},nobrl$SMBVERS$SECVERS$PUID$PGID$CHARSET$DOMAIN" "$disk" /mnt/"$diskname" 2>/dev/null \
|
||||||
&& MOUNTED=true && MOUNTOPTIONS="$SMBVERS$SECVERS$PUID$PGID$CHARSET$DOMAIN" || MOUNTED=false
|
&& MOUNTED=true && MOUNTOPTIONS="$SMBVERS$SECVERS$PUID$PGID$CHARSET$DOMAIN" || MOUNTED=false
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Messages
|
# Messages
|
||||||
if [ "$MOUNTED" = true ] && mountpoint -q /mnt/"$diskname"; then
|
if [ "$MOUNTED" = true ] && mountpoint -q /mnt/"$diskname"; then
|
||||||
|
|||||||
Reference in New Issue
Block a user