container_post_create.sh 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/usr/bin/env bash
  2. TARGET_USER=batman
  3. source .devcontainer/.host/.env
  4. # override display flag for mac hosts
  5. if [[ $HOST_OS == darwin ]]; then
  6. echo "Setting up DISPLAY override for macOS..."
  7. cat <<EOF >> /home/$TARGET_USER/.bashrc
  8. source .devcontainer/.host/.env
  9. if [ -n "\$HOST_DISPLAY" ]; then
  10. DISPLAY_NUM=\$(echo "\$HOST_DISPLAY" | awk -F: '{print \$NF}')
  11. export DISPLAY=host.docker.internal:\$DISPLAY_NUM
  12. fi
  13. EOF
  14. fi
  15. # setup virtualgl for mac hosts
  16. if [[ $HOST_OS == darwin ]]; then
  17. echo "Setting up virtualgl for macOS..."
  18. cat <<EOF >> /home/$TARGET_USER/.bashrc
  19. if [ -n "\$HOST_DISPLAY" ]; then
  20. export VGL_PORT=10000
  21. export VGL_CLIENT=host.docker.internal
  22. export VGL_COMPRESS=rgb
  23. export VGL_DISPLAY=:99
  24. export VGL_FPS=60
  25. # prevent vglrun from running exec
  26. alias exec=:; source vglrun :; unalias exec
  27. fi
  28. EOF
  29. fi
  30. # These lines are temporary, to remain backwards compatible with old devcontainers
  31. # that were running as root and therefore had their caches written as root
  32. sudo chown -R $TARGET_USER: /tmp/scons_cache
  33. sudo chown -R $TARGET_USER: /tmp/comma_download_cache
  34. sudo chown -R $TARGET_USER: /home/batman/.comma