bootstrap.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. set -e
  3. trap "echo TRAPed signal" HUP INT QUIT KILL TERM
  4. # NVIDIA driver inside the container must be same version as host.
  5. HEX_ID=$(sudo nvidia-smi --query-gpu=pci.bus_id --id=${NVIDIA_VISIBLE_DEVICES} --format=csv | tail -n1)
  6. IFS=":." ARR_ID=($HEX_ID); unset IFS
  7. BUS_ID=PCI:$((16#${ARR_ID[1]})):$((16#${ARR_ID[2]})):$((16#${ARR_ID[3]}))
  8. # Leave out --use-display-device=None if GPU is headless such as Tesla and download links of such GPU drivers in Dockerfile should also be different
  9. sudo nvidia-xconfig -a --virtual=${SIZEW}x${SIZEH} --allow-empty-initial-configuration --enable-all-gpus --busid=$BUS_ID --use-display-device=None
  10. shopt -s extglob
  11. for tty in /dev/tty+([0-9])
  12. do
  13. if [ -w ${tty} ] ; then
  14. /usr/bin/X tty$(echo ${tty} | grep -Eo '[0-9]+$') :0 &
  15. break
  16. fi
  17. done
  18. sleep 1
  19. x11vnc -display :0 -passwd $VNCPASS -forever -rfbport 5900 &
  20. sleep 2
  21. pulseaudio --start
  22. sleep 2
  23. /opt/noVNC/utils/launch.sh --vnc localhost:5900 --listen 5901 &
  24. sleep 2
  25. export DISPLAY=:0
  26. mate-session &
  27. sleep 2
  28. gsettings set org.gnome.desktop.lockdown disable-lock-screen true
  29. gsettings set org.gnome.desktop.screensaver lock-enabled false
  30. gsettings set org.gnome.desktop.screensaver idle-activation-enabled false
  31. echo "Session Running. Press [Return] to exit."
  32. read