樹莓派 讓 VNC Server 每次開機都能自動啟動~~
開啟與樹莓派的 SSH 連線 終端機, 輸入:
sudo nano /etc/init.d/vncserver
然後輸入底下文字:
#!/bin/sh
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: $local_fs
# Required-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop vncserver
### END INIT INFO
# More details see:
# http://www.penguintutor.com/linux/vnc
### Customize this entry
# Set the USER variable to the name of the user to start vncserver under
export USER='pi'
### End customization required
eval cd ~$USER
case "$1" in
start)
# Start the command line. Customize the resolution, console number, or other parameters here.
su $USER -c '/usr/bin/vncserver -depth 16 -geometry 1024x768 :1'
echo "Starting VNC server for $USER "
;;
stop)
# Terminate the command line. The console number here is the same as the startup.
su $USER -c '/usr/bin/vncserver -kill :1'
echo "vncserver stopped"
;;
*)
echo "Usage: /etc/init.d/vncserver {start|stop}"
exit 1
;;
esac
exit 0
輸入完畢後儲存檔案,,按,
CTL-X
Y
Enter
修改使用權限:
sudo chmod 755 /etc/init.d/vncserver
添加至開機啟動程序
sudo update-rc.d vncserver defaults
留言
張貼留言