mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-06-26 01:06:04 +02:00
Update 92-mounts
This commit is contained in:
@@ -1,31 +1,25 @@
|
|||||||
#!/usr/bin/with-contenv bashio
|
#!/usr/bin/with-contenv bashio
|
||||||
|
|
||||||
####################
|
#########################
|
||||||
# MOUNT SMB SHARES #
|
# MOUNT SMB SHARES v1.0 #
|
||||||
####################
|
#########################
|
||||||
# Mount CIFS Share if configured and if Protection Mode is active
|
|
||||||
if bashio::config.has_value 'networkdisks'; then
|
if bashio::config.has_value 'networkdisks'; then
|
||||||
bashio::log.info 'Mounting smb share...'
|
# Mount CIFS Share if configured and if Protection Mode is active
|
||||||
|
bashio::log.info 'Mounting smb share(s)...'
|
||||||
|
|
||||||
|
# Define variables
|
||||||
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')
|
||||||
bashio::log.info "Network Disks mounting.. ${MOREDISKS}" && \
|
|
||||||
for disk in $MOREDISKS
|
# Mounting disks
|
||||||
|
for disk in ${MOREDISKS//,/ } # Separate comma separated values
|
||||||
do
|
do
|
||||||
bashio::log.info "Mount ${disk}"
|
disk=$(echo $disk | sed "s,/$,,") # Remove / at end of name
|
||||||
echo "Creating /mnt/storagecifs"
|
diskname=${disk##*/} # Get only last part of the name
|
||||||
mkdir -p /mnt/storagecifs
|
mkdir -p /mnt/$diskname # Create dir
|
||||||
chown -R abc:abc /mnt/storagecifs
|
chown -R root:root /mnt/$diskname # Permissions
|
||||||
mount -t cifs -o username=$CIFS_USERNAME,password=$CIFS_PASSWORD $disk /mnt/storagecifs && \
|
mount -t cifs -o username=$CIFS_USERNAME,password=$CIFS_PASSWORD $disk /mnt/$diskname && \
|
||||||
bashio::log.info "SMB share was successfully mapped to /mnt/storagecifs"
|
bashio::log.info "... $disk successfully mounted to /mnt/$diskname" || bashio::log.error "Unable to mount $disk to /mnt/$diskname with username $CIFS_USERNAME, $CIFS_PASSWORD" # Mount share
|
||||||
done || \
|
done || true
|
||||||
bashio::log.warning "Protection mode is ON. Unable to mount external drives!"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#variable=abc,def,ghij
|
|
||||||
#for i in ${variable//,/ }
|
|
||||||
#do
|
|
||||||
# # call your procedure/other scripts here below
|
|
||||||
# echo "$i"
|
|
||||||
#done
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user