install-ubuntu-nicedcv.sh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/bash
  2. # Copyright (c) Contributors to the Open 3D Engine Project.
  3. # For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. #
  5. # SPDX-License-Identifier: Apache-2.0 OR MIT
  6. #
  7. # This script must be run as root
  8. if [[ $EUID -ne 0 ]]
  9. then
  10. echo "This script must be run as root (sudo)"
  11. exit 1
  12. fi
  13. # Download Nice DCV
  14. #
  15. echo Downloading Nice-DCV
  16. mkdir /tmp/nice-dcv
  17. cd /tmp/nice-dcv
  18. curl -sSL https://d1uj6qtbmh3dt5.cloudfront.net/NICE-GPG-KEY | gpg --import -
  19. if [ "`cat /etc/issue | grep 18.04`" != "" ] ; then
  20. dcv_server=`curl --silent --output - https://download.nice-dcv.com/ | \
  21. grep href | egrep "$dcv_version" | egrep "ubuntu1804" | grep Server | \
  22. sed -e 's/.*http/http/' -e 's/tgz.*/tgz/' | head -1`
  23. else
  24. dcv_server=`curl --silent --output - https://download.nice-dcv.com/ | \
  25. grep href | egrep "$dcv_version" | egrep "ubuntu2004" | grep Server | \
  26. sed -e 's/.*http/http/' -e 's/tgz.*/tgz/' | head -1`
  27. fi
  28. # Install Nice DCV
  29. #
  30. echo Installing DCV from $dcv_server
  31. wget $dcv_server \
  32. && tar zxvf nice-dcv-*ubun*.tgz
  33. cd nice-dcv-*64
  34. apt install -y ./nice-*amd64.ubuntu*.deb \
  35. && usermod -aG video dcv \
  36. && rm -rf /tmp/nice-dcv
  37. # Setup multiuser environment for DCV
  38. #
  39. systemctl isolate multi-user.target
  40. sleep 1
  41. dcvgladmin enable
  42. systemctl isolate graphical.target
  43. # Check if DCV localuser for X has been setup correctly
  44. #
  45. if [ $(DISPLAY=:0 XAUTHORITY=$(ps aux | grep "X.*\-auth" | grep -v grep | sed -n 's/.*-auth \([^ ]\+\).*/\1/p') xhost | grep "SI:localuser:dcv$") ]; then
  46. echo DCV localuser validated
  47. else
  48. echo [ERROR] DCV localuser not found. Output should be: SI:localuser:dcv. Exiting with 1
  49. exit 1
  50. fi
  51. # Configure DCV for auto start sessions and performance
  52. #
  53. sed -i "s/#create-session = true/create-session = true/g" /etc/dcv/dcv.conf
  54. sed -i "s/#owner=\"session-owner\"/owner=\"$LOGNAME\"/g" /etc/dcv/dcv.conf
  55. sed -i "s/#target-fps=30/target-fps=0/g" /etc/dcv/dcv.conf
  56. # Enable and start the DCV server
  57. #
  58. systemctl enable dcvserver
  59. systemctl start dcvserver
  60. # Output the DCV installation diagnostics
  61. #
  62. dcvgldiag
  63. # Start a DCV session to login
  64. #
  65. IP_ADDR=$(curl http://checkip.amazonaws.com)
  66. echo Starting DCV desktop session for $LOGNAME. Session can be accessed at https://$IP_ADDR:8443
  67. dcv create-session --type=console --owner $LOGNAME desktop