From d71db46a39f9eed2345e1aa324d5b4cbb2715101 Mon Sep 17 00:00:00 2001 From: Brennan Kinney <5098581+polarathene@users.noreply.github.com> Date: Thu, 16 May 2024 12:34:45 +1200 Subject: [PATCH] fix: `/var/mail-state` should ensure service dir exists before symlinking The Getmail service doesn't have a directory in `/var/lib/` by default, yet `mail-state` is configured to symlink it, and the service in DMS is configured to expect `/var/lib/getmail` exists. Handled in `mail-state` logic to ensure it doesn't silently fail. --- target/scripts/startup/setup.d/mail_state.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/target/scripts/startup/setup.d/mail_state.sh b/target/scripts/startup/setup.d/mail_state.sh index 5acf6762..4a86b873 100644 --- a/target/scripts/startup/setup.d/mail_state.sh +++ b/target/scripts/startup/setup.d/mail_state.sh @@ -70,7 +70,10 @@ function _setup_save_states() { rm -rf "${SERVICEDIR}" elif [[ -d ${SERVICEDIR} ]]; then _log 'trace' "Moving contents of ${SERVICEDIR} to ${DEST}" - # Empty volume was mounted, or new content from enabling a feature ENV: + # An empty volume was mounted, or new content exists from enabling a feature ENV: + # Ensure the original directory exists before mv, otherwise with nothing to move + # the symlink created afterwards is invalid. + mkdir -p "${SERVICEDIR}" mv "${SERVICEDIR}" "${DEST}" # Apply SELinux security context to match the state directory, so access # is not restricted to the current running container: