<repo_name>zhang-zhoujie-optim/install-vnc<file_sep>/vnc.sh
#!/bin/bash

echo "Installing vnc..."
sudo apt update
sudo apt install -y xfce4 xfce4-goodies
sudo apt install -y tightvncserver

vncserver

vncserver -kill :1
mv ~/.vnc/xstartup ~/.vnc/xstartup.bak

mkdir -p ~/.vnc/
touch ~/.vnc/xstartup

cat <<EOT >> ~/.vnc/xstartup
#!/bin/bash
xrdb \$HOME/.Xresources
startxfce4 &
EOT

chmod +x ~/.vnc/xstartup

touch vncserver@.service

cat <<EOT >> ./vncserver@.service
[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target

[Service]
Type=forking
User=$USER
Group=$USER
WorkingDirectory=$HOME

PIDFile=$HOME/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 -localhost :%i
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target
EOT

sudo mv ./vncserver@.service /etc/systemd/system/vncserver@.service

sudo systemctl daemon-reload
sudo systemctl enable vncserver@1.service
sudo systemctl start vncserver@1
<file_sep>/README.md
# install-vnc

This script installs VNC for a linux server.

For more information, see [this guide](https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-20-04).

## How to use

```bash
chmod +x vnc.sh
./vnc.sh
```

During installation, you may be prompted to choose a default display manager for Xfce. Select either one and press `ENTER`.

Then you’ll be prompted to enter and verify a password to access your machine remotely:

```bash
You will require a password to access your desktops.

Password:
Verify:

# The password must be between six and eight characters long. Passwords more than 8 characters will be truncated automatically.

Would you like to enter a view-only password (y/n)?

# n
```
