Add visual smoothing for snake game and systemd deployment
CSS animations for smoother 60fps feel despite 7Hz game ticks: - 130ms transitions on cell background/box-shadow - Head pop-in animation on direction changes - Food pulse animation - Smooth death state fade with grayscale Per-snake colored glow on head cells. Make server port configurable via PORT env var (default 8080). Add deploy/ with systemd service and scripts: - setup.sh: create games user, /opt/c4, install unit - deploy.sh: build and install binary, restart service - package.sh: cross-compile, tarball, base64 split for transfer - reassemble.sh: decode and extract on target server
This commit is contained in:
96
deploy/reassemble.sh
Executable file
96
deploy/reassemble.sh
Executable file
@@ -0,0 +1,96 @@
|
||||
#!/usr/bin/env bash
|
||||
# Reassembles base64 chunks and extracts the c4 deployment tarball.
|
||||
# Expects chunk files in the current directory.
|
||||
set -euo pipefail
|
||||
|
||||
cd "$HOME"
|
||||
|
||||
echo "=== C4 Deployment Reassembler ==="
|
||||
echo "Working directory: $HOME"
|
||||
echo ""
|
||||
|
||||
#==============================================================================
|
||||
# Find and validate chunk files
|
||||
#==============================================================================
|
||||
echo "--- Finding chunk files ---"
|
||||
|
||||
CHUNKS=($(ls -1 c4-deploy-*_b64_part*.txt 2>/dev/null | sort))
|
||||
|
||||
if [[ ${#CHUNKS[@]} -eq 0 ]]; then
|
||||
echo "ERROR: No chunk files found matching c4-deploy-*_b64_part*.txt"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Found ${#CHUNKS[@]} chunks:"
|
||||
for chunk in "${CHUNKS[@]}"; do
|
||||
echo " - $chunk ($(du -h "$chunk" | cut -f1))"
|
||||
done
|
||||
|
||||
#==============================================================================
|
||||
# Reassemble and decode
|
||||
#==============================================================================
|
||||
echo ""
|
||||
echo "--- Reassembling chunks ---"
|
||||
|
||||
TIMESTAMP=$(echo "${CHUNKS[0]}" | sed -E 's/c4-deploy-([0-9]+-[0-9]+)_b64_part.*/\1/')
|
||||
TARBALL="c4-deploy-${TIMESTAMP}.tar.gz"
|
||||
COMBINED="combined_b64.txt"
|
||||
|
||||
echo "Concatenating chunks..."
|
||||
cat "${CHUNKS[@]}" > "$COMBINED"
|
||||
echo " -> Created $COMBINED ($(du -h "$COMBINED" | cut -f1))"
|
||||
|
||||
echo "Decoding base64..."
|
||||
base64 -d "$COMBINED" > "$TARBALL"
|
||||
echo " -> Created $TARBALL ($(du -h "$TARBALL" | cut -f1))"
|
||||
|
||||
echo "Verifying tarball..."
|
||||
if tar -tzf "$TARBALL" > /dev/null 2>&1; then
|
||||
echo " -> Tarball is valid"
|
||||
else
|
||||
echo "ERROR: Tarball verification failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#==============================================================================
|
||||
# Archive existing source
|
||||
#==============================================================================
|
||||
echo ""
|
||||
echo "--- Archiving existing source ---"
|
||||
|
||||
if [[ -d c4 ]]; then
|
||||
rm -rf c4.bak
|
||||
mv c4 c4.bak
|
||||
echo " -> Moved c4 -> c4.bak"
|
||||
else
|
||||
echo " -> No existing c4 directory"
|
||||
fi
|
||||
|
||||
#==============================================================================
|
||||
# Extract
|
||||
#==============================================================================
|
||||
echo ""
|
||||
echo "--- Extracting tarball ---"
|
||||
|
||||
tar -xzf "$TARBALL"
|
||||
echo " -> Extracted to ~/c4"
|
||||
|
||||
#==============================================================================
|
||||
# Cleanup
|
||||
#==============================================================================
|
||||
echo ""
|
||||
echo "--- Cleaning up ---"
|
||||
|
||||
rm -f "$COMBINED" "$TARBALL" "${CHUNKS[@]}"
|
||||
echo " -> Removed chunks, combined base64, and tarball"
|
||||
|
||||
#==============================================================================
|
||||
# Next steps
|
||||
#==============================================================================
|
||||
echo ""
|
||||
echo "=== Reassembly Complete ==="
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " cd ~/c4"
|
||||
echo " sudo ./deploy/setup.sh # first time only"
|
||||
echo " sudo ./deploy/deploy.sh"
|
||||
Reference in New Issue
Block a user