mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-10-21 16:05:25 +00:00
fix: use a temp file instead of process substitution for POSIX sh compat
The restore script runs under /bin/sh, not bash. Process substitution
("< <(...)") is a bashism dash doesn't support, so the previous fix
failed at runtime with a syntax error and the restore never ran.
Write STOPPED_CONTAINERS to a temp file and read the while loops from
that instead — same effect, works under plain POSIX sh.
This commit is contained in:
@@ -106,6 +106,11 @@ export const restoreVolume = async (
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Use a temp file instead of process substitution ("< <(...)") so this
|
||||
# still works under a plain POSIX /bin/sh, not just bash.
|
||||
STOPPED_CONTAINERS_FILE=$(mktemp)
|
||||
printf '%s\\n' "$STOPPED_CONTAINERS" > "$STOPPED_CONTAINERS_FILE"
|
||||
|
||||
# Re-check each container's live state right before removing it: it may have
|
||||
# started running again since the "docker ps -a" snapshot above.
|
||||
ACTIVE_AGAIN=""
|
||||
@@ -116,9 +121,10 @@ export const restoreVolume = async (
|
||||
ACTIVE_AGAIN="$ACTIVE_AGAIN $container_name"
|
||||
;;
|
||||
esac
|
||||
done < <(printf '%s\\n' "$STOPPED_CONTAINERS")
|
||||
done < "$STOPPED_CONTAINERS_FILE"
|
||||
|
||||
if [ -n "$ACTIVE_AGAIN" ]; then
|
||||
rm -f "$STOPPED_CONTAINERS_FILE"
|
||||
echo ""
|
||||
echo "⚠️ WARNING: Container(s)$ACTIVE_AGAIN became active again, aborting restore"
|
||||
echo "❌ Volume restore aborted - volume is in use"
|
||||
@@ -134,7 +140,9 @@ export const restoreVolume = async (
|
||||
if ! docker rm -f "$container_id" >/dev/null 2>&1; then
|
||||
REMOVE_FAILED="$REMOVE_FAILED $container_name"
|
||||
fi
|
||||
done < <(printf '%s\\n' "$STOPPED_CONTAINERS")
|
||||
done < "$STOPPED_CONTAINERS_FILE"
|
||||
|
||||
rm -f "$STOPPED_CONTAINERS_FILE"
|
||||
|
||||
if [ -n "$REMOVE_FAILED" ]; then
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user