List drives

This commit is contained in:
Alexandre
2023-03-04 10:03:04 +01:00
committed by GitHub
parent bce4e4bc11
commit 291adb5c26

View File

@@ -5,19 +5,21 @@
# LIST LOCAL DISKS # # LIST LOCAL DISKS #
#################### ####################
bashio::log.info "List of available labels (@dianlight) function list_drives (
bashio::log.blue "---------------------------------------------------" bashio::log.info "List of available labels (@dianlight)"
#autodisks=($(lsblk -E label -n -o label | sed -r '/^\s*$/d' | grep -v hassos | grep pp)) bashio::log.blue "---------------------------------------------------"
readarray -t autodisks < <(lsblk -E label -n -o label -i | sed -r '/^\s*$/d' | grep -v hassos) #autodisks=($(lsblk -E label -n -o label | sed -r '/^\s*$/d' | grep -v hassos | grep pp))
if [ ${#autodisks[@]} -eq 0 ]; then readarray -t autodisks < <(lsblk -E label -n -o label -i | sed -r '/^\s*$/d' | grep -v hassos)
bashio::log.info "No Disk with labels." if [ ${#autodisks[@]} -eq 0 ]; then
else bashio::log.info "No Disk with labels."
bashio::log.info "Available Disk Labels:" else
for disk in ${autodisks[@]}; do bashio::log.info "Available Disk Labels:"
bashio::log.info "\t${disk}[$(lsblk $(blkid -L "$disk") -no fstype)]" for disk in ${autodisks[@]}; do
done bashio::log.info "\t${disk}[$(lsblk $(blkid -L "$disk") -no fstype)]"
fi done
bashio::log.blue "---------------------------------------------------" fi
bashio::log.blue "---------------------------------------------------"
)
###################### ######################
# MOUNT LOCAL SHARES # # MOUNT LOCAL SHARES #
@@ -88,7 +90,10 @@ if bashio::config.has_value 'localdisks'; then
# shellcheck disable=SC2015 # shellcheck disable=SC2015
mount -t $type "$devpath"/"$disk" "$dirpath"/"$disk" -o $options && bashio::log.info "Success! $disk mounted to /mnt/$disk" || \ mount -t $type "$devpath"/"$disk" "$dirpath"/"$disk" -o $options && bashio::log.info "Success! $disk mounted to /mnt/$disk" || \
(bashio::log.fatal "Unable to mount local drives! Please check the name." && rmdir /mnt/$disk && bashio::addon.stop) (bashio::log.fatal "Unable to mount local drives! Please check the name."
rmdir /mnt/$disk
list_drives
bashio::addon.stop)
done done
fi fi