12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- #!/bin/bash
- sudo apt update
- sudo apt install lightdm
- sudo apt install x11vnc
- # 配置访问密码
- sudo x11vnc -storepasswd /etc/x11vnc.pass
- # 配置文件权限,默认的权限导致其他用户可能无法正常使用
- sudo chmod 755 /etc/x11vnc.pass
- echo "Create service"
- cat > /lib/systemd/system/x11vnc.service << EOF
- [Unit]
- Description=Start x11vnc at startup.
- After=network-online.target
- [Service]
- Type=simple
- ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /etc/x11vnc.pass -rfbport 5900 -shared -display :0
- ExecStop=/bin/kill -TERM $MAINPID
- ExecReload=/bin/kill -HUP $MAINPID
- KillMode=control-group
- Restart=on-failure
- [Install]
- WantedBy=graphical.target
- EOF
- echo "Configure firewall"
- sudo ufw allow 5900
- echo "Configure Services"
- sudo systemctl daemon-reload
- sudo systemctl enable x11vnc.service
- echo "Ready to reboot system..."
- sleep 5s
- sudo shutdown -r now
|