Create the var directory before trying to chown.

During cold start, var directory may not exist and we try to chown
the var directory which fails if it doesn't exist. We want to make
and chown the var directory in that case otherwise, mailman will not
be able to write to path `/opt/mailman` to create it's own var
directory.
This commit is contained in:
Abhilash Raj
2024-08-31 15:09:15 +00:00
parent ccbf86daa9
commit fcf719625c

View File

@@ -247,7 +247,17 @@ echo "HYPERKITTY_API_KEY not defined, skipping HyperKitty setup..."
fi fi
# Now chown the places where mailman wants to write stuff. # Now chown the places where mailman wants to write stuff.
chown -R mailman /opt/mailman/var VAR_DIR="/opt/mailman/var"
# Check if the directory exists
if [ ! -d "$VAR_DIR" ]; then
# Directory does not exist, so create it
mkdir -p "$VAR_DIR"
echo "Directory $VAR_DIR created."
else
echo "Directory $VAR_DIR already exists."
fi
chown -R mailman $VAR_DIR
# Generate the LMTP files for postfix if needed. # Generate the LMTP files for postfix if needed.
su-exec mailman mailman aliases su-exec mailman mailman aliases