selkies-gstreamer-entrypoint.sh 1.4 KB

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