Tag Archives: raspberrypi

Raspberry Pi Guide – VNC-another way to auto start

网上看了自动启动 VNC Server 的方法,但是由于懒,脚本都不写 Init Info,导致更新启动项时出现 LSB Tags 等缺失的警告。现将必要的信息补充完整如下。
首先把以下内容写入 /etc/init.d/tightvncserver
#!/bin/sh
### BEGIN INIT INFO
# Provides: tightvncserver
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starts VNC Server on system start.
# Description: Starts tight VNC Server. Script written by James Swineson.
### END INIT INFO
# /etc/init.d/tightvncserver
VNCUSER=’pi’
case “” in
start)
su  -c ‘/usr/bin/tightvncserver :1’
echo “Starting TightVNC Server for ”
;;
stop)
pkill Xtightvnc
echo “TightVNC Server 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 update-rc.d -f tightvncserver remove

Raspberry Pi Guide

### CPU Temprature

cat /sys/class/thermal/thermal_zone0/temp

### list disk partitions

sudo fdisk -l

### mount disk

mount -t vfat -o rw /dev/xxx/xxx /boot
# see /etc/fstab

### iwconfig list the wireless devices

ifconfig
look for wlan0 wlan1 or more

### change config.txt

cd /boot
ls -al
sudo nano /boot/config.txt

### shutdown

shutdown -t +10
例1,系统在十分钟后关机并且马上重新启动
# shutdown –r +10
例2,系统马上关机并且不重新启动
# shutdown –h now

### Date/Time

sudo apt-get install ntpdate
sudo service ntp stop
sudo ntpdate -s time.nist.gov
sudo service ntp start
cat /etc/init.d/ntp
#### Restart the ntp deamon.
sudo /etc/init.d/ntp restart

#### VNC

sudo apt-get install tightvncserver
If VNC Server is not listening on port 5900, enter :<1-99> for ports in the range 5901-5999,
for example 192.168.5.127:80 for port 5980, and ::<full-number> for all other ports, for
example 192.168.5.127::80 for port 80.

### netstat show network connections

netstat –apn

### Display Monitor Config

/opt/vc/bin/tvservice -s
/opt/vc/bin/tvservice -m DMT
/opt/vc/bin/tvservice -d edid.dat
/opt/vc/bin/edidparser edid.dat
当你发现你设置了很多显示器分辨率的设置,但是并不生效的时候,
你一定要看看你有没有打开hdmi_safe=1这个开关,我被它坑惨了。
还有
/opt/vc/bin/tvservice -m DMT
这个显示出来的分辨率,你的显示器并不一定真的支持,需要自己试。
我的显示器acer的win10上最佳分辨率是1600*900,上面的命令也检测
出来了,但是我设置了始终不生效。
然后我就用了下面的两个命令,生成edid数据,然后找到1440*900,幸
运的是,它居然支持。

Raspberry Pi Guide – VNC

 

update your apt package info

 

sudo apt-get update

 

  • Install TightVNCServer
sudo apt-get install tightvncserver
  • start the server:

type the following command in your favorite terminal

vncserver :1

and you will be required to input the password.

the console output should be like this:


You will require a password to access your desktops.

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

New 'X' desktop is raspberrypi:1

Creating default startup script /home/pi/.vnc/xstartup
Starting applications specified in /home/pi/.vnc/xstartup
Log file is /home/pi/.vnc/raspberrypi:1.log

  • start at boot:

if you are running raspbian jessie, you can use the systemd to auto start vnc server

 

 

Create a new file /etc/systemd/system/vncserver@.service with the following contents:

[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=forking
User=pi
PAMName=login
PIDFile=/home/pi/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i

[Install]
WantedBy=multi-user.target

you can modify the params in the file according to your device(Display Monitor)

-depth and -geometry

then run:

sudo systemctl daemon-reload && sudo systemctl enable vncserver@1.service

more detail, see

https://www.raspberrypi.org/forums/viewtopic.php?t=123457&p=830506