Advertisement
Guest User

Untitled

a guest
Jan 7th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.04 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3.  
  4. # Right now this configures a vnc instance running for user root.
  5. $USER=""
  6.  
  7. apt-get install expect
  8. apt-get install tightvncserver
  9.  
  10.  
  11.  
  12. /usr/bin/expect  <<EOD
  13. set timeout -1
  14.  
  15. spawn vncserver
  16.  
  17. expect "Password:"
  18.  
  19. send  "123abc\r"
  20.  
  21. expect "Verify:"
  22.  
  23. send "123abc\r"
  24.  
  25. expect "Would you like to enter a view-only password (y/n)?"
  26.  
  27. send "n\r"
  28.  
  29. expect eof
  30.  
  31. EOD
  32.  
  33.  
  34. sudo  killall Xtightvnc
  35.  
  36. echo -e "Set the systemd unit file for VNC server"
  37.  
  38. cat << EOF  > /etc/systemd/system/vncserver@:1.service
  39.  
  40. [Unit]
  41. Description=Remote desktop service (VNC)
  42. After=syslog.target network.target
  43.  
  44. [Service]
  45. Type=forking
  46. ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
  47. ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i -geometry 1280x1024"
  48. PIDFile=/root/.vnc/%H%i.pid
  49. ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
  50.  
  51. [Install]
  52. WantedBy=multi-user.target
  53.  
  54. EOF
  55.  
  56. systemctl daemon-reload
  57. systemctl enable vncserver@:1.service
  58. systemctl start vncserver@:1.service
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement