1
0

obfuscate.sh 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. # WaouW — PyArmor obfuscation script
  3. # Obfuscates all Python source files in app/ for source code protection.
  4. # Run inside Docker build stage.
  5. set -e
  6. echo "WaouW PyArmor Obfuscation"
  7. echo "========================="
  8. # Fix CRLF
  9. find /build -name "*.py" -exec sed -i 's/\r$//' {} +
  10. # Register license if key file exists
  11. if [ -f /build/pyarmor-regkey.txt ]; then
  12. echo "Registering PyArmor license..."
  13. pyarmor reg /build/pyarmor-regkey.txt 2>&1 || echo "License registration failed, continuing with trial"
  14. fi
  15. # Obfuscate all app/ files
  16. echo "Obfuscating app/..."
  17. cd /build
  18. pyarmor gen --recursive --output /tmp/pyarmor-out app/ 2>&1
  19. # Replace original files with obfuscated ones
  20. if [ -d /tmp/pyarmor-out/app ]; then
  21. echo "Replacing source with obfuscated files..."
  22. # Copy obfuscated files over originals
  23. cp -rf /tmp/pyarmor-out/app/* /build/app/
  24. # Copy runtime library
  25. if [ -d /tmp/pyarmor-out/pyarmor_runtime_* ]; then
  26. cp -rf /tmp/pyarmor-out/pyarmor_runtime_* /build/app/
  27. fi
  28. echo "Obfuscation complete."
  29. # Count
  30. TOTAL=$(find /build/app -name "*.py" ! -name "__init__.py" | wc -l)
  31. echo "Total Python files: $TOTAL"
  32. else
  33. echo "ERROR: Obfuscation output not found"
  34. exit 1
  35. fi
  36. # Cleanup
  37. rm -rf /tmp/pyarmor-out
  38. echo "Done."