v4.5 Demo initial commit

This commit is contained in:
DaStra3003
2026-06-24 14:53:14 +02:00
commit 3de8ded7c2
110 changed files with 14363112 additions and 0 deletions
+90
View File
@@ -0,0 +1,90 @@
#!/bin/bash
set -e
echo "=========================================="
echo "IoT PreTester V3 - Backend Initialization"
echo "=========================================="
# 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
# Wait for database to be ready (if using external DB)
echo "Waiting for database..."
sleep 2
# Create required directories
echo "Creating required directories..."
mkdir -p /app/files/firmware 2>/dev/null || true
mkdir -p /app/files/pcap 2>/dev/null || true
mkdir -p /app/files/wireshark_capture 2>/dev/null || true
mkdir -p /app/data 2>/dev/null || true
mkdir -p /app/logs 2>/dev/null || true
echo "✓ Directories created"
# Test write permissions on shared volume
echo "Testing write permissions..."
if touch /app/files/.write_test 2>/dev/null; then
rm -f /app/files/.write_test
echo "✓ Write access to /app/files confirmed"
else
echo "⚠ WARNING: Cannot write to /app/files directory"
echo " This may cause firmware/pcap analysis issues"
fi
# Change to django_project directory
cd /app/django_project
# Run migrations
# The repo ships no migration files for IoTAnalyzer, so generate them first —
# otherwise migrate only covers Django's built-in apps and the iot_* tables
# are never created.
echo "Running database migrations..."
python manage.py makemigrations IoTAnalyzer --noinput
python manage.py migrate --noinput
echo "✓ Migrations completed"
# Collect static files
echo "Collecting static files..."
python manage.py collectstatic --noinput --clear || echo "⚠ Static files collection skipped"
# Create superuser if it doesn't exist
echo "Checking for superuser..."
python manage.py shell -c "
from django.contrib.auth import get_user_model;
User = get_user_model();
if not User.objects.filter(username='${DJANGO_SUPERUSER_USERNAME:-admin}').exists():
User.objects.create_superuser(
'${DJANGO_SUPERUSER_USERNAME:-admin}',
'${DJANGO_SUPERUSER_EMAIL:-admin@example.com}',
'${DJANGO_SUPERUSER_PASSWORD:-admin}'
);
print('✓ Superuser created');
else:
print('✓ Superuser already exists');
" || echo "⚠ Superuser check failed"
# Initialize database with default data
if [ "$INIT_DATABASE" = "true" ]; then
echo "Initializing database with default data..."
python create_models.py || echo "⚠ Database initialization skipped"
fi
echo "=========================================="
echo "Starting Django application..."
echo "=========================================="
# Start Gunicorn server
exec gunicorn IoTPreTester.wsgi:application \
--bind 0.0.0.0:8000 \
--workers ${GUNICORN_WORKERS:-4} \
--timeout ${GUNICORN_TIMEOUT:-120} \
--access-logfile /app/logs/access.log \
--error-logfile /app/logs/error.log \
--log-level ${LOG_LEVEL:-info}
+49
View File
@@ -0,0 +1,49 @@
#!/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 "$@"