selkies-gstreamer-entrypoint.sh 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/bash -e
  2. # This Source Code Form is subject to the terms of the Mozilla Public
  3. # License, v. 2.0. If a copy of the MPL was not distributed with this
  4. # file, You can obtain one at https://mozilla.org/MPL/2.0/.
  5. # Source environment for GStreamer
  6. source /opt/gstreamer/gst-env
  7. # Add CUDA library path
  8. export LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}"
  9. # Set default display
  10. export DISPLAY="${DISPLAY:-:0}"
  11. # Configure joystick interposer
  12. sudo mkdir -pm755 /dev/input
  13. sudo touch /dev/input/{js0,js1,js2,js3}
  14. # Show debug logs for GStreamer
  15. export GST_DEBUG="${GST_DEBUG:-*:2}"
  16. # Set password for basic authentication
  17. if [ "${ENABLE_BASIC_AUTH,,}" = "true" ] && [ -z "$BASIC_AUTH_PASSWORD" ]; then export BASIC_AUTH_PASSWORD="$PASSWD"; fi
  18. # Wait for X11 to start
  19. echo "Waiting for X socket"
  20. until [ -S "/tmp/.X11-unix/X${DISPLAY/:/}" ]; do sleep 1; done
  21. echo "X socket is ready"
  22. # Write Progressive Web App (PWA) configuration
  23. export PWA_APP_NAME="Selkies WebRTC"
  24. export PWA_APP_SHORT_NAME="selkies"
  25. export PWA_START_URL="/index.html"
  26. sudo sed -i \
  27. -e "s|PWA_APP_NAME|${PWA_APP_NAME}|g" \
  28. -e "s|PWA_APP_SHORT_NAME|${PWA_APP_SHORT_NAME}|g" \
  29. -e "s|PWA_START_URL|${PWA_START_URL}|g" \
  30. /opt/gst-web/manifest.json && \
  31. sudo sed -i \
  32. -e "s|PWA_CACHE|${PWA_APP_SHORT_NAME}-webrtc-pwa|g" \
  33. /opt/gst-web/sw.js
  34. # Clear the cache registry to force the CUDA elements to refresh
  35. rm -f "${HOME}/.cache/gstreamer-1.0/registry.x86_64.bin"
  36. # Start the selkies-gstreamer WebRTC HTML5 remote desktop application
  37. selkies-gstreamer \
  38. --addr="0.0.0.0" \
  39. --port="8080" \
  40. $@