Skip to content

Commit 1be3859

Browse files
committed
docker: guard auto-pull cronjob write, don't chmod a missing file
docker_setup_auto_pull_cronjob ran 'sudo chmod 600' on the cron file unconditionally, even when the preceding 'sudo tee' failed to create it — producing 'chmod: cannot access /etc/cron.d/armbian-docker-pull: No such file or directory'. The wrapper-script write just above already guards its tee and bails gracefully; the cron-file write did not. Guard the cron tee the same way: on failure, warn and return (best-effort, the feature is opt-in via ARMBIAN_DOCKER_AUTO_PULL), and only chmod when the file was actually created. Signed-off-by: Igor Pecovnik <igor@armbian.com>
1 parent 8dc413c commit 1be3859

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

lib/functions/host/docker.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -905,10 +905,18 @@ function docker_setup_auto_pull_cronjob() {
905905
fi
906906
sudo chmod +x "${wrapper_script}" || true
907907

908-
# Create/update cron file
908+
# Create/update cron file. Guard the write like the wrapper script above:
909+
# if the tee fails (sudo refused, /etc read-only, cron not really
910+
# present, ...) we must NOT go on to chmod a file that was never
911+
# created — that is what printed the confusing
912+
# "chmod: cannot access '${cron_file}': No such file or directory".
913+
# Treat it as best-effort and bail gracefully, same as the wrapper path.
909914
display_alert "Creating/updating Docker auto-pull cronjob" "${cron_file}" "info"
910-
echo "${cron_content}" | sudo tee "${cron_file}" > /dev/null
911-
sudo chmod 600 "${cron_file}"
915+
if ! echo "${cron_content}" | sudo tee "${cron_file}" > /dev/null 2>&1; then
916+
display_alert "Docker auto-pull" "failed to create cronjob ${cron_file} (sudo/permissions?)" "warn"
917+
return 0
918+
fi
919+
sudo chmod 600 "${cron_file}" || true
912920

913921
# Store hash for next time
914922
sudo mkdir -p "$(dirname "${hash_file}")"

0 commit comments

Comments
 (0)