50 lines
1.6 KiB
Bash
50 lines
1.6 KiB
Bash
#!/bin/sh
|
|
set -e
|
|
|
|
echo "=========================================="
|
|
echo "IoT PreTester V3 - Frontend Initialization"
|
|
echo "=========================================="
|
|
|
|
# Ensure required directories exist with proper permissions
|
|
echo "Ensuring directory structure..."
|
|
mkdir -p /app/public/filesAttachment 2>/dev/null || true
|
|
mkdir -p /app/public/wireshark_capture 2>/dev/null || true
|
|
mkdir -p /files 2>/dev/null || true
|
|
mkdir -p /files/firmware 2>/dev/null || true
|
|
mkdir -p /files/pcap 2>/dev/null || true
|
|
mkdir -p /files/wireshark_capture 2>/dev/null || true
|
|
|
|
# Check if running as correct user
|
|
CURRENT_UID=$(id -u)
|
|
CURRENT_GID=$(id -g)
|
|
echo "Running as UID:GID = $CURRENT_UID:$CURRENT_GID"
|
|
|
|
if [ "$CURRENT_UID" != "1000" ] || [ "$CURRENT_GID" != "1000" ]; then
|
|
echo "WARNING: Not running as UID:GID 1000:1000"
|
|
echo "This may cause permission issues with shared volumes"
|
|
fi
|
|
|
|
# Test write permissions
|
|
echo "Testing write permissions..."
|
|
if touch /files/.write_test 2>/dev/null; then
|
|
rm -f /files/.write_test
|
|
echo "✓ Write access to /files confirmed"
|
|
else
|
|
echo "⚠ WARNING: Cannot write to /files directory"
|
|
echo " This may cause file upload/download issues"
|
|
fi
|
|
|
|
if touch /app/public/filesAttachment/.write_test 2>/dev/null; then
|
|
rm -f /app/public/filesAttachment/.write_test
|
|
echo "✓ Write access to /app/public/filesAttachment confirmed"
|
|
else
|
|
echo "⚠ WARNING: Cannot write to /app/public/filesAttachment directory"
|
|
fi
|
|
|
|
echo "=========================================="
|
|
echo "Starting Next.js application..."
|
|
echo "=========================================="
|
|
|
|
# Execute the command passed to the entrypoint
|
|
exec "$@"
|