fix: Make failed chown non-fatal (#1265)

This commit is contained in:
Kroese
2026-07-15 17:39:05 +02:00
committed by GitHub
parent 0813494ee0
commit cf8cdbf0c1
3 changed files with 12 additions and 11 deletions
-1
View File
@@ -634,7 +634,6 @@ addDisk () {
if [ -f "$DISK_FILE" ]; then
if ! setOwner "$DISK_FILE"; then
error "Failed to set the owner for \"$DISK_FILE\" !"
exit 77
fi
fi
+10 -7
View File
@@ -1495,23 +1495,26 @@ configureMAC() {
container=$(containerID)
if [ -z "$MAC" ]; then
file="$STORAGE/dsm.mac"
[ -s "$file" ] && MAC=$(<"$file")
MAC="${MAC//[![:print:]]/}"
if [ -s "$file" ]; then
if ! MAC=$(readFile "$file"); then
error "Failed to read MAC address from \"$file\" !"
exit 28
fi
fi
if [ -z "$MAC" ]; then
# Generate a Synology-style MAC address based on a stable container identifier when possible.
MAC=$(echo "$container" | md5sum | sed 's/^\(..\)\(..\)\(..\)\(..\)\(..\).*$/02:11:32:\3:\4:\5/')
if ! echo "${MAC^^}" > "$file"; then
if ! writeFile "${MAC^^}" "$file"; then
error "Failed to write MAC address to \"$file\" !"
exit 28
fi
if ! setOwner "$file"; then
error "Failed to set the owner for \"$file\" !"
exit 28
fi
fi
fi
+2 -3
View File
@@ -248,14 +248,13 @@ writeFile() {
local txt="$1"
local path="$2"
if ! printf '%s\n' "$txt" >"$path"; then
if ! printf '%s\n' "$txt" > "$path"; then
error "Failed to write file \"$path\" !"
return 1
fi
if ! setOwner "$path"; then
error "Failed to set the owner for \"$path\" !"
return 1
warn "failed to set the owner for \"$path\"."
fi
return 0