Raspberry pi 開機自動開啟VNC(tightvncserver)

最近下載了
Raspbian(2016-05-27-jessie)
發現老方法已經不能用了(?
只好改一個方式自動啟動

環境:Raspberry pi2 b+
OS:Raspbian(2016-05-27-jessie)

先說老辦法好了

先執行

sudo nano /etc/init.d/tightvncserver

把這串coding上去


### BEGIN INIT INFO

# Provides: tightvnc

# Required-Start: $remote_fs $syslog

# Required-Stop: $remote_fs $syslog

# Default-Start: 2 3 4 5

# Default-Stop: 0 1 6

# Short-Description: Start VNC Server as a service

# Description: Start VNC Server as a service.

### END INIT INFO

#!/bin/sh

# /etc/init.d/tightvncserver

# Customised by Stewart Watkiss


# Set the VNCUSER variable to the name of the user to start tightvncserver under

VNCUSER='root'

eval cd ~$VNCUSER

case "$1" in

start)

   su $VNCUSER -c '/usr/bin/tightvncserver :1'

   echo "Starting TightVNC server for $VNCUSER "

   ;;

stop)

   pkill Xtightvnc

   echo "Tightvncserver stopped"

   ;;

*)

   echo "Usage: /etc/init.d/tightvncserver {start|stop}"

   exit 1

   ;;

esac

exit 0

#


之後更改權限

sudo chmod 755 /etc/init.d/tightvncserver

再塞到開機程序中即可

sudo update-rc.d tightvncserver defaults

============================================================

新方法則是編輯這份文件

sudo nano /etc/rc.local

把它改成這樣


#!/bin/sh -e

#

# rc.local

#

# This script is executed at the end of each multiuser runlevel.

# Make sure that the script will "exit 0" on success or any other

# value on error.

#

# In order to enable or disable this script just change the execution

# bits.

#

# By default this script does nothing.



# Print the IP address

_IP=$(hostname -I) || true

if [ "$_IP" ]; then

  printf "My IP address is %sn" "$_IP"

fi



# Start tightvncserver

su - pi -c '/usr/bin/tightvncserver :1`



exit 0


存好重開即可!!!