fix: Add SELinux warning for shared folder (#1522)
Some checks failed
Update / dockerHubDescription (push) Has been cancelled

This commit is contained in:
Kroese 2025-10-20 14:50:37 +02:00 committed by GitHub
parent fa606aec53
commit 9236127a86
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -46,10 +46,14 @@ addShare() {
local cfg="$5" local cfg="$5"
local owner="" local owner=""
mkdir -p "$dir" || return 1 if ! mkdir -p "$dir"; then
error "Failed to create directory $dir." && return 1
fi
if ! ls -A "$dir" >/dev/null 2>&1; then if ! ls -A "$dir" >/dev/null 2>&1; then
error "Failed to access directory $dir" && return 1 msg="Failed to access directory $dir."
msg+=" If SELinux is active, you need to add the \":Z\" flag to the bind mount."
error "$msg" && return 1
fi fi
if [ -z "$(ls -A "$dir")" ]; then if [ -z "$(ls -A "$dir")" ]; then
@ -136,26 +140,21 @@ share="/shared"
[ ! -d "$share" ] && [ -d "$STORAGE/data" ] && share="$STORAGE/data" [ ! -d "$share" ] && [ -d "$STORAGE/data" ] && share="$STORAGE/data"
[ ! -d "$share" ] && share="$tmp" [ ! -d "$share" ] && share="$tmp"
m1="Failed to add shared folder" ! addShare "$share" "/shared" "Data" "Shared" "$SAMBA_CONFIG" && return 0
m2="Please check its permissions."
if ! addShare "$share" "/shared" "Data" "Shared" "$SAMBA_CONFIG"; then
error "$m1 '$share'. $m2" && return 0
fi
if [ -d "/shared2" ]; then if [ -d "/shared2" ]; then
addShare "/shared2" "/shared2" "Data2" "Shared" "$SAMBA_CONFIG" || error "$m1 '/shared2'. $m2" addShare "/shared2" "/shared2" "Data2" "Shared" "$SAMBA_CONFIG" || :
else else
if [ -d "/data2" ]; then if [ -d "/data2" ]; then
addShare "/data2" "/shared2" "Data2" "Shared" "$SAMBA_CONFIG" || error "$m1 '/data2'. $m2." addShare "/data2" "/shared2" "Data2" "Shared" "$SAMBA_CONFIG" || :
fi fi
fi fi
if [ -d "/shared3" ]; then if [ -d "/shared3" ]; then
addShare "/shared3" "/shared3" "Data3" "Shared" "$SAMBA_CONFIG" || error "$m1 '/shared3'. $m2" addShare "/shared3" "/shared3" "Data3" "Shared" "$SAMBA_CONFIG" || :
else else
if [ -d "/data3" ]; then if [ -d "/data3" ]; then
addShare "/data3" "/shared3" "Data3" "Shared" "$SAMBA_CONFIG" || error "$m1 '/data3'. $m2" addShare "/data3" "/shared3" "Data3" "Shared" "$SAMBA_CONFIG" || :
fi fi
fi fi