correct failure test logic

This commit is contained in:
Alexandre
2021-04-29 13:20:32 +02:00
committed by GitHub
parent 8645a8ef74
commit f1365c565a

View File

@@ -11,6 +11,7 @@ if bashio::config.has_value 'networkdisks'; then
MOREDISKS=$(bashio::config 'networkdisks') MOREDISKS=$(bashio::config 'networkdisks')
CIFS_USERNAME=$(bashio::config 'cifsusername') CIFS_USERNAME=$(bashio::config 'cifsusername')
CIFS_PASSWORD=$(bashio::config 'cifspassword') CIFS_PASSWORD=$(bashio::config 'cifspassword')
MOUNTED=false
if bashio::config.has_value 'cifsdomain'; then if bashio::config.has_value 'cifsdomain'; then
DOMAIN=",domain=$(bashio::config 'cifsdomain')" DOMAIN=",domain=$(bashio::config 'cifsdomain')"
@@ -31,30 +32,30 @@ if bashio::config.has_value 'networkdisks'; then
#Tries to mount with default options #Tries to mount with default options
bashio::log.info "... trying to mount with default options" bashio::log.info "... trying to mount with default options"
mount -t cifs -o rw,iocharset=utf8,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname mount -t cifs -o rw,iocharset=utf8,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname && MOUNTFAIL=false || MOUNTED=false
#If mounting failed, tries to force uid/gid 0/0 #If mounting failed, tries to force uid/gid 0/0
if [ $? != 0 ]; then if [ $MOUNTFAIL = true ]; then
bashio::log.info "... trying to force uid 0 gid 0" bashio::log.info "... trying to force uid 0 gid 0"
mount -t cifs -o rw,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=0,gid=0,forceuid,forcegid,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname mount -t cifs -o rw,iocharset=utf8,file_mode=0777,dir_mode=0777,uid=0,gid=0,forceuid,forcegid,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN $disk /mnt/$diskname && MOUNTFAIL=false || MOUNTED=false
fi fi
# if Fail test different smb and sec versions # if Fail test different smb and sec versions
if [ $? != 0 ]; then if [ $MOUNTFAIL=true ]; then
for SMBVERS in ",vers=2.1" ",vers=3.0" ",vers=1.0" ",vers=3.1.1" ",vers=2.0" ",vers=3.0.2" for SMBVERS in ",vers=2.1" ",vers=3.0" ",vers=1.0" ",vers=3.1.1" ",vers=2.0" ",vers=3.0.2"
do do
bashio::log.warning "... trying to mount with $SMBVERS" bashio::log.warning "... trying to mount with $SMBVERS"
mount -t cifs -o rw,iocharset=utf8,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN$SMBVERS $disk /mnt/$diskname && break mount -t cifs -o rw,iocharset=utf8,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN$SMBVERS $disk /mnt/$diskname && MOUNTED=true && break || MOUNTED=false
for SECVERS in ",sec=ntlmi" ",sec=ntlmv2" ",sec=ntlmv2i" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=ntlm" ",sec=krb5i" ",sec=krb5" for SECVERS in ",sec=ntlmi" ",sec=ntlmv2" ",sec=ntlmv2i" ",sec=ntlmssp" ",sec=ntlmsspi" ",sec=ntlm" ",sec=krb5i" ",sec=krb5"
do do
bashio::log.warning "... trying to mount with $SMBVERS $SECVERS" bashio::log.warning "... trying to mount with $SMBVERS $SECVERS"
mount -t cifs -o rw,iocharset=utf8,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN$SMBVERS$SECVERS $disk /mnt/$diskname && break 2 && break mount -t cifs -o rw,iocharset=utf8,file_mode=0777,dir_mode=0777,username=$CIFS_USERNAME,password=${CIFS_PASSWORD}$DOMAIN$SMBVERS$SECVERS $disk /mnt/$diskname && MOUNTED=true && break 2 && break || MOUNTED=false
done done
done done
fi fi
# Messages # Messages
if [ $? = 0 ]; then if [ $MOUNTED = true ]; then
#Test write permissions #Test write permissions
touch /mnt/$diskname/testaze && rm /mnt/$diskname/testaze && bashio::log.info "... $disk successfully mounted to /mnt/$diskname" || bashio::log.fatal "Unable to write in the shared disk. Please check UID/GID for permissions, and if the share is rw" touch /mnt/$diskname/testaze && rm /mnt/$diskname/testaze && bashio::log.info "... $disk successfully mounted to /mnt/$diskname" || bashio::log.fatal "Unable to write in the shared disk. Please check UID/GID for permissions, and if the share is rw"
else else