test
This commit is contained in:
112
.templates/00-local_mounts.sh
Normal file
112
.templates/00-local_mounts.sh
Normal file
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
set -e
|
||||
|
||||
if ! bashio::supervisor.ping 2> /dev/null; then
|
||||
echo "..."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
bashio::log.notice "This script is used to mount local USB/SATA/SD/NVMe drives. Instructions here : https://github.com/alexbelgium/hassio-addons/wiki/Mounting-Local-Drives-in-Addons"
|
||||
|
||||
######################
|
||||
# MOUNT LOCAL SHARES #
|
||||
######################
|
||||
|
||||
# Mount local Share if configured
|
||||
if bashio::config.has_value 'localdisks'; then
|
||||
|
||||
# Available devices
|
||||
blkid | awk '{print substr($1, 0, length($1) - 1)}' | awk -F'/' '{print $NF}' > availabledisks
|
||||
echo "NAME" >> availabledisks
|
||||
|
||||
## List available Disk with Labels and Id
|
||||
bashio::log.blue "---------------------------------------------------"
|
||||
bashio::log.info "Available Disks for mounting :"
|
||||
lsblk -o name,label,size,fstype,ro | awk '$4 != "" { print $0 }' | grep -f availabledisks
|
||||
bashio::log.blue "---------------------------------------------------"
|
||||
rm availabledisks
|
||||
|
||||
# Show support fs https://github.com/dianlight/hassio-addons/blob/2e903184254617ac2484fe7c03a6e33e6987151c/sambanas/rootfs/etc/s6-overlay/s6-rc.d/init-automount/run#L106
|
||||
fstypessupport=$(grep -v nodev < /proc/filesystems | awk '{$1=" "$1}1' | tr -d '\n\t')
|
||||
bashio::log.green "Supported fs : ${fstypessupport}"
|
||||
bashio::log.green "Inspired from : github.com/dianlight"
|
||||
bashio::log.blue "---------------------------------------------------"
|
||||
|
||||
MOREDISKS=$(bashio::config 'localdisks')
|
||||
echo "Local Disks mounting..."
|
||||
|
||||
# Separate comma separated values
|
||||
# shellcheck disable=SC2086
|
||||
for disk in ${MOREDISKS//,/ }; do
|
||||
|
||||
# Remove text until last slash
|
||||
disk="${disk##*/}"
|
||||
|
||||
# Function to check what is the type of device
|
||||
if [ -e /dev/"$disk" ]; then
|
||||
echo "... $disk is a physical device"
|
||||
devpath=/dev
|
||||
elif [ -e /dev/disk/by-uuid/"$disk" ] || lsblk -o UUID | grep -q "$disk"; then
|
||||
echo "... $disk is a device by UUID"
|
||||
devpath=/dev/disk/by-uuid
|
||||
elif [ -e /dev/disk/by-label/"$disk" ] || lsblk -o LABEL | grep -q "$disk"; then
|
||||
echo "... $disk is a device by label"
|
||||
devpath=/dev/disk/by-label
|
||||
else
|
||||
bashio::log.fatal "$disk does not match any known physical device, UUID, or label. "
|
||||
continue
|
||||
fi
|
||||
|
||||
# Creates dir
|
||||
mkdir -p /mnt/"$disk"
|
||||
if bashio::config.has_value 'PUID' && bashio::config.has_value 'PGID'; then
|
||||
PUID="$(bashio::config 'PUID')"
|
||||
PGID="$(bashio::config 'PGID')"
|
||||
chown "$PUID:$PGID" /mnt/"$disk"
|
||||
fi
|
||||
|
||||
# Check FS type and set relative options (thanks @https://github.com/dianlight/hassio-addons)
|
||||
fstype=$(lsblk "$devpath"/"$disk" -no fstype)
|
||||
options="nosuid,relatime,noexec"
|
||||
type="auto"
|
||||
|
||||
# Check if supported
|
||||
if [[ "${fstypessupport}" != *"${fstype}"* ]]; then
|
||||
bashio::log.fatal : "${fstype} type for ${disk} is not supported"
|
||||
break
|
||||
fi
|
||||
|
||||
# Mount drive
|
||||
bashio::log.info "Mounting ${disk} of type ${fstype}"
|
||||
case "$fstype" in
|
||||
exfat | vfat | msdos)
|
||||
bashio::log.warning "${fstype} permissions and ACL don't works and this is an EXPERIMENTAL support"
|
||||
options="${options},umask=000"
|
||||
;;
|
||||
ntfs)
|
||||
bashio::log.warning "${fstype} is an EXPERIMENTAL support"
|
||||
options="${options},umask=000"
|
||||
type="ntfs"
|
||||
;;
|
||||
squashfs)
|
||||
bashio::log.warning "${fstype} is an EXPERIMENTAL support"
|
||||
options="loop"
|
||||
type="squashfs"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Legacy mounting : mount to share if still exists (avoid breaking changes)
|
||||
dirpath="/mnt"
|
||||
if [ -d /share/"$disk" ]; then dirpath="/share"; fi
|
||||
|
||||
# shellcheck disable=SC2015
|
||||
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
|
||||
)
|
||||
done
|
||||
|
||||
fi
|
@@ -17,5 +17,8 @@ RUN \
|
||||
# Copy data
|
||||
COPY rootfs /
|
||||
|
||||
# Modules
|
||||
ARG MODULES="00-local_mounts.sh"
|
||||
|
||||
HEALTHCHECK \
|
||||
CMD smbclient -L '\\localhost' -U '%' -m SMB3
|
||||
|
@@ -11,6 +11,78 @@ arch:
|
||||
- aarch64
|
||||
- amd64
|
||||
- i386
|
||||
devices:
|
||||
- /dev/dri
|
||||
- /dev/dri/card0
|
||||
- /dev/dri/card1
|
||||
- /dev/dri/renderD128
|
||||
- /dev/vchiq
|
||||
- /dev/video10
|
||||
- /dev/video11
|
||||
- /dev/video12
|
||||
- /dev/video13
|
||||
- /dev/video14
|
||||
- /dev/video15
|
||||
- /dev/video16
|
||||
- /dev/ttyUSB0
|
||||
- /dev/sda
|
||||
- /dev/sdb
|
||||
- /dev/sdc
|
||||
- /dev/sdd
|
||||
- /dev/sde
|
||||
- /dev/sdf
|
||||
- /dev/sdg
|
||||
- /dev/nvme
|
||||
- /dev/nvme0
|
||||
- /dev/nvme0n1
|
||||
- /dev/nvme0n1p1
|
||||
- /dev/nvme0n1p2
|
||||
- /dev/nvme0n1p3
|
||||
- /dev/nvme1n1
|
||||
- /dev/nvme1n1p1
|
||||
- /dev/nvme1n1p2
|
||||
- /dev/nvme1n1p3
|
||||
- /dev/nvme2n1
|
||||
- /dev/nvme2n1p1
|
||||
- /dev/nvme2n1p2
|
||||
- /dev/nvme2n3p3
|
||||
- /dev/mmcblk
|
||||
- /dev/fuse
|
||||
- /dev/sda1
|
||||
- /dev/sdb1
|
||||
- /dev/sdc1
|
||||
- /dev/sdd1
|
||||
- /dev/sde1
|
||||
- /dev/sdf1
|
||||
- /dev/sdg1
|
||||
- /dev/sda2
|
||||
- /dev/sdb2
|
||||
- /dev/sdc2
|
||||
- /dev/sdd2
|
||||
- /dev/sde2
|
||||
- /dev/sdf2
|
||||
- /dev/sdg2
|
||||
- /dev/sda3
|
||||
- /dev/sdb3
|
||||
- /dev/sda4
|
||||
- /dev/sdb4
|
||||
- /dev/sda5
|
||||
- /dev/sda6
|
||||
- /dev/sda7
|
||||
- /dev/sda8
|
||||
- /dev/nvme0
|
||||
- /dev/nvme1
|
||||
- /dev/nvme2
|
||||
- /dev/md0
|
||||
- /dev/md1
|
||||
- /dev/md2
|
||||
- /dev/md3
|
||||
environment:
|
||||
PGID: 0
|
||||
PUID: 0
|
||||
privileged:
|
||||
- SYS_ADMIN
|
||||
- DAC_READ_SEARCH
|
||||
hassio_api: true
|
||||
host_network: true
|
||||
image: homeassistant/{arch}-addon-samba
|
||||
@@ -23,12 +95,12 @@ map:
|
||||
- media:rw
|
||||
- share:rw
|
||||
- ssl:rw
|
||||
- old_data:rw
|
||||
options:
|
||||
username: mezned
|
||||
password: null
|
||||
workgroup: WORKGROUP
|
||||
local_master: true
|
||||
localdisks: sda8
|
||||
enabled_shares:
|
||||
- addons
|
||||
- addon_configs
|
||||
@@ -37,7 +109,7 @@ options:
|
||||
- media
|
||||
- share
|
||||
- ssl
|
||||
- old_data
|
||||
- mnt
|
||||
compatibility_mode: false
|
||||
apple_compatibility_mode: true
|
||||
veto_files:
|
||||
@@ -55,8 +127,9 @@ schema:
|
||||
password: password
|
||||
workgroup: str
|
||||
local_master: bool
|
||||
localdisks: str
|
||||
enabled_shares:
|
||||
- "match(^(?i:(addons|addon_configs|backup|config|media|share|ssl|old_data))$)"
|
||||
- "match(^(?i:(addons|addon_configs|backup|config|media|share|ssl|mnt))$)"
|
||||
compatibility_mode: bool
|
||||
apple_compatibility_mode: bool
|
||||
veto_files:
|
||||
@@ -64,3 +137,4 @@ schema:
|
||||
allow_hosts:
|
||||
- str
|
||||
startup: services
|
||||
udev: true
|
||||
|
@@ -122,11 +122,11 @@
|
||||
delete veto files = {{ eq (len .veto_files) 0 | ternary "no" "yes" }}
|
||||
{{ end }}
|
||||
|
||||
{{ if (has "old_data" .enabled_shares) }}
|
||||
[old_data]
|
||||
{{ if (has "mnt" .enabled_shares) }}
|
||||
[mnt]
|
||||
browseable = yes
|
||||
writeable = yes
|
||||
path = /old_data
|
||||
path = /mnt
|
||||
|
||||
valid users = {{ .username }}
|
||||
force user = root
|
||||
|
Reference in New Issue
Block a user