Guest User

Untitled

a guest
Dec 9th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. sudo apt-get install -y xfce4 xfce4-goodies tightvncserver expect
  4.  
  5. export LC_CTYPE=en_US.UTF-8
  6. export LC_ALL=en_US.UTF-8
  7.  
  8. mypass="secret" # not so
  9.  
  10. expect <<EOF
  11. spawn "vncserver"
  12. expect "Password:"
  13. send "$mypass\r"
  14. expect "Verify:"
  15. send "$mypass\r"
  16. expect "Would you like to enter a view-only password (y/n)?"
  17. send "n\r"
  18. expect eof
  19. exit
  20. EOF
  21.  
  22. vncserver -kill :1
  23.  
  24. > ~/.vnc/xstartup
  25. cat <<EOT >> ~/.vnc/xstartup
  26. #!/bin/bash
  27. xrdb $HOME/.Xresources
  28. startxfce4 &
  29. EOT
  30.  
  31. sudo chmod +x ~/.vnc/xstartup
  32.  
  33. sudo su
  34. cat << "EOF" > /etc/init.d/vncserver
  35. #!/bin/bash
  36. PATH="$PATH:/usr/bin/"
  37. export USER="vagrant"
  38. DISPLAY="1"
  39. DEPTH="16"
  40. GEOMETRY="1024x768"
  41. OPTIONS="-depth ${DEPTH} -geometry ${GEOMETRY} :${DISPLAY} -localhost"
  42. . /lib/lsb/init-functions
  43. case "$1" in
  44. start)
  45. log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:${DISPLAY}"
  46. su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
  47. ;;
  48. stop)
  49. log_action_begin_msg "Stopping vncserver for user '${USER}' on localhost:${DISPLAY}"
  50. su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
  51. ;;
  52. restart)
  53. $0 stop
  54. $0 start
  55. ;;
  56. esac
  57. exit 0
  58. EOF
  59. exit
  60.  
  61. sudo chmod +x /etc/init.d/vncserver
  62.  
  63. sudo service vncserver start
  64. sudo update-rc.d vncserver defaults
Add Comment
Please, Sign In to add comment