Browse Source

提交安装脚本

corvin 4 years ago
parent
commit
5a33149e0a
1 changed files with 43 additions and 0 deletions
  1. 43 0
      configRemoteDesktop.sh

+ 43 - 0
configRemoteDesktop.sh

@@ -0,0 +1,43 @@
+#!/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
+