Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Right now this configures a vnc instance running for user root.
- $USER=""
- apt-get install expect
- apt-get install tightvncserver
- /usr/bin/expect <<EOD
- set timeout -1
- spawn vncserver
- expect "Password:"
- send "123abc\r"
- expect "Verify:"
- send "123abc\r"
- expect "Would you like to enter a view-only password (y/n)?"
- send "n\r"
- expect eof
- EOD
- sudo killall Xtightvnc
- echo -e "Set the systemd unit file for VNC server"
- cat << EOF > /etc/systemd/system/vncserver@:1.service
- [Unit]
- Description=Remote desktop service (VNC)
- After=syslog.target network.target
- [Service]
- Type=forking
- ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
- ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i -geometry 1280x1024"
- PIDFile=/root/.vnc/%H%i.pid
- ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
- [Install]
- WantedBy=multi-user.target
- EOF
- systemctl daemon-reload
- systemctl enable vncserver@:1.service
- systemctl start vncserver@:1.service
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement