selkies-gstreamer-entrypoint.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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. # Default display is :0 across this setup
  10. export DISPLAY=":0"
  11. # Show debug logs for GStreamer
  12. export GST_DEBUG="${GST_DEBUG:-*:2}"
  13. # Set password for basic authentication
  14. if [ "${ENABLE_BASIC_AUTH,,}" = "true" ] && [ -z "$BASIC_AUTH_PASSWORD" ]; then export BASIC_AUTH_PASSWORD="$PASSWD"; fi
  15. # Wait for X11 to start
  16. echo "Waiting for X socket"
  17. until [ -S "/tmp/.X11-unix/X${DISPLAY/:/}" ]; do sleep 1; done
  18. echo "X socket is ready"
  19. # Write Progressive Web App (PWA) configuration
  20. export PWA_APP_NAME="Selkies WebRTC"
  21. export PWA_APP_SHORT_NAME="selkies"
  22. export PWA_START_URL="/index.html"
  23. sudo sed -i \
  24. -e "s|PWA_APP_NAME|${PWA_APP_NAME}|g" \
  25. -e "s|PWA_APP_SHORT_NAME|${PWA_APP_SHORT_NAME}|g" \
  26. -e "s|PWA_START_URL|${PWA_START_URL}|g" \
  27. /opt/gst-web/manifest.json && \
  28. sudo sed -i \
  29. -e "s|PWA_CACHE|${PWA_APP_SHORT_NAME}-webrtc-pwa|g" \
  30. /opt/gst-web/sw.js
  31. # Clear the cache registry to force the CUDA elements to refresh
  32. rm -f "${HOME}/.cache/gstreamer-1.0/registry.x86_64.bin"
  33. # Start the selkies-gstreamer WebRTC HTML5 remote desktop application
  34. selkies-gstreamer \
  35. --addr="0.0.0.0" \
  36. --port="8080" \
  37. $@