#!/command/with-contenv bashio # shellcheck shell=bash # ============================================================================== # Amoutomount Shares with new system! # ============================================================================== if [ -f /tmp/cifs_network ]; then #bashio::log.level all bashio::log.info "Automount Shares..." ipaddress=$(bashio::addon.ip_address) #username=$(bashio::config 'username') #password=$(bashio::config 'password') username=$(jq -r '.username' >/dev/null >>/dev/tcp/$0/$1; do sleep 1; done' ${ipaddress/\/*/} 445 bashio::net.wait_for 445 ${ipaddress/\/*/} 60 # smbstatus while read -r -a device; do [[ ${device,,} == @(share|config|addons|ssl|backup|media|addon_configs|homeassistant) ]] && continue usage=$(jq -r --arg xshare "$device" '.acl[] | select(.share==$xshare) | .usage // "media"' <<<"$(bashio::addon.config)") cmdshare=$(jq -nrc --arg usage "${usage:-media}" --arg share "$device" --arg ip "${ipaddress/\/*/}" --arg user "$username" --arg pwd "$password" '.name=$share|.usage=$usage|.type="cifs"|.server=$ip|.share=$share|.username=$user|.password=$pwd') #bashio::log.info $(jq '.password="********"' <<<${cmdshare}) #bashio::log.info $(bashio::api.supervisor GET /mounts) #bashio::log.info $(bashio::api.supervisor GET /mounts | jq -r --arg xshare "$device" '.mounts[] | select(.name == $xshare ) // empty') if [[ ! -z $(bashio::api.supervisor GET /mounts | jq -r --arg xshare "$device" '.mounts[] | select(.name == $xshare ) // empty') ]]; then bashio::log.info "Share Already Found ${device} - Remove!" bashio::api.supervisor DELETE /mounts/${device} || true fi for rt in {1..3}; do status=$(bashio::api.supervisor POST /mounts "${cmdshare}") && break bashio::log.warning "Retry ${rt}/3 Error Automount ${device} Msg: $(jq -c '.password="********"' <<<${cmdshare})" sleep 3 done done <<<"${available_shares}" fi