在树莓派中安装和运行Domoticz:修订间差异

来自Domoticz
(创建页面,内容为“There are two ways of installing Domoticz on your Raspbery Pi. The easy way, and the hard way. Both are described on this page. =Preparation (for both methods)= I...”)
 
 
(未显示2个用户的8个中间版本)
第1行: 第1行:
There are two ways of installing Domoticz on your Raspbery Pi. The easy way, and the hard way. Both are described on this page.
有两种方法将Domoticz安装到你的树莓派,简单方法和复杂方法,两种方法本页均有介绍。




=Preparation (for both methods)=
=准备(两种方法都需要)=


If you have bought a 'fresh' Pi, you'll need to get your version of Linux to run smoothly.
如果你买了个'新鲜'的树莓派,你要确保你树莓派里的系统运行良好。


Log in to your Raspberry with the "pi" user, open the terminal window, and install the required packages by typing this command, followed by enter:
"pi"用户登录你的树莓派,打开终端命令行窗口,输入:


<code>sudo raspi-config</code>
<code>sudo raspi-config</code>


Using Raspi-config you should expand the root filesystem, set your timezone, finish (reboot) and login again. You can find various tutorials on how to do this elsewhere on the internet, or you can check out the tutorial on this wiki: [[Initial_Raspberry_Pi_Setup|Initial Raspberry Pi Setup]]
Using Raspi-config you should expand the root filesystem, set your timezone, finish (reboot) and login again. You can find various tutorials on how to do this elsewhere on the internet, or you can check out the tutorial on this wiki: [[全新树莓派的第一次设置]]




第17行: 第17行:
如果你的树莓派中运行的是基于Debian的Linux系统,比如Raspbian和Ubuntu,安装Domoticz非常简单,执行下面的命令即可:
如果你的树莓派中运行的是基于Debian的Linux系统,比如Raspbian和Ubuntu,安装Domoticz非常简单,执行下面的命令即可:


<code>sudo curl -L install.domoticz.com | sudo bash</code>
<code>sudo curl -L install.domoticz.cn | sudo bash</code>
 
''如果出现以下错误,请安装curl,安装命令:<code>sudo apt-get install curl</code>''
 
[[文件:curl_commandnotfound.jpg]]
 
''最近新装系统的树莓派无法正常运行Domoticz,解决方案:https://www.domoticz.cn/forum/viewtopic.php?f=6&t=121''
 


恭喜!安装已经完成了。
恭喜!安装已经完成了。
第23行: 第30行:
在浏览器中输入你的树莓派的IP与Domoticz默认端口号8080即可访问。在树莓派的浏览器中可以直接输入<code>http://127.0.0.1:8080</code>.
在浏览器中输入你的树莓派的IP与Domoticz默认端口号8080即可访问。在树莓派的浏览器中可以直接输入<code>http://127.0.0.1:8080</code>.


[注意: 如果安装时遇到证书错误提示,你可以执行<code>sudo curl -L -k install.domoticz.com | sudo bash</code>,这条命令通过非加密通道下载Domoticz(http而不是https)。
[注意: 如果安装时遇到证书错误提示,你可以执行<code>sudo curl -L -k install.domoticz.cn | sudo bash</code>,这条命令通过非加密通道下载Domoticz(http而不是https)。
 


= Domoticz - 复杂方法(手动安装)=
= Domoticz - 复杂方法(手动安装)=
第126行: 第132行:
  make -j 3
  make -j 3


=Make Domoticz startup at boot time (Also needed for Web Update)=
=设置Domoticz开机自启动(网页升级后也需要)=


  sudo cp domoticz.sh /etc/init.d
  sudo cp domoticz.sh /etc/init.d
第132行: 第138行:
  sudo update-rc.d domoticz.sh defaults
  sudo update-rc.d domoticz.sh defaults


''Edit the startup script and change the USERNAME, DAEMON and DAEMON_ARGS parameters to reflect your current settings''
''编辑启动脚本,修改USERNAME, DAEMON 及 DAEMON_ARGS参数为你自己的设置''


  <code>sudo vi /etc/init.d/domoticz.sh</code>
  <code>sudo vi /etc/init.d/domoticz.sh</code>
第140行: 第146行:
  DAEMON_ARGS="-daemon -www 8080"
  DAEMON_ARGS="-daemon -www 8080"


If you want to use another web interface port change:
如果想用另一个端口访问domoticz,将8080修改为你需要的端口号即可:


  DAEMON_ARGS="-daemon -www 8080"
  DAEMON_ARGS="-daemon -www 8080"


'''Test Domoticz (Important to get the file ownerships right!)'''
'''测试Domoticz (确保获取文件所有权!)'''


  cd domoticz
  cd domoticz
第153行: 第159行:
  sudo service domoticz.sh start
  sudo service domoticz.sh start


Now connect with a browser to see if it is up and running.
然后到浏览器中查看Domoticz是否运行正常。
 


=Updating Domoticz=
=升级Domoticz=
升级前请一定备份数据库及自定义脚本等内容,升级会导致某些修改丢失。


===Binary install update===
===二进制安装更新===
Use the Web Interface to update Domoticz (Setup->Check for Updates)
使用web界面中的选项升级Domoticz(设置->软件更新)


If this fails for any reason (e.g. partial download giving segmentation fault) then you should manually update by:
如果升级失败(例如下载错误),你需要手动升级:


Stable:
稳定版:
  cd domoticz
  cd domoticz
  ./updaterelease
  sudo sh ./updaterelease


Beta:
Beta版:
  cd domoticz
  cd domoticz
  ./updatebeta
  sudo sh ./updatebeta


===Source Update===
如果以上命令出现连接失败的问题,可以编辑升级脚本,将domoticz.com改为domoticz.cn。
Login to your Raspberry Pi with the 'pi' user and issue:
===源码升级===


  cd domoticz
  cd domoticz
第180行: 第186行:


[[Category:Domoticz]]
[[Category:Domoticz]]
[[Category:Manual]]
[[Category:手册]]
[[Category:Install]]
[[Category:安装]]
[[Category:Raspberry Pi]]
[[Category:树莓派]]

2018年5月15日 (二) 15:15的最新版本

有两种方法将Domoticz安装到你的树莓派,简单方法和复杂方法,两种方法本页均有介绍。


准备(两种方法都需要)

如果你买了个'新鲜'的树莓派,你要确保你树莓派里的系统运行良好。

用"pi"用户登录你的树莓派,打开终端命令行窗口,输入:

sudo raspi-config

Using Raspi-config you should expand the root filesystem, set your timezone, finish (reboot) and login again. You can find various tutorials on how to do this elsewhere on the internet, or you can check out the tutorial on this wiki: 全新树莓派的第一次设置


Domoticz - 简单方法(推荐)

如果你的树莓派中运行的是基于Debian的Linux系统,比如Raspbian和Ubuntu,安装Domoticz非常简单,执行下面的命令即可:

sudo curl -L install.domoticz.cn | sudo bash

如果出现以下错误,请安装curl,安装命令:sudo apt-get install curl

最近新装系统的树莓派无法正常运行Domoticz,解决方案:https://www.domoticz.cn/forum/viewtopic.php?f=6&t=121


恭喜!安装已经完成了。

在浏览器中输入你的树莓派的IP与Domoticz默认端口号8080即可访问。在树莓派的浏览器中可以直接输入http://127.0.0.1:8080.

[注意: 如果安装时遇到证书错误提示,你可以执行sudo curl -L -k install.domoticz.cn | sudo bash,这条命令通过非加密通道下载Domoticz(http而不是https)。

Domoticz - 复杂方法(手动安装)

You can also install Domoticz by compiling the source code yourself. The advantage of this is that it should work on most versions of Linux (Debian/Ubuntu tested).

For a manual install see:

Build times reported are when using a Raspberry Pi 3, using "make -j 3"
(Older revisions of the raspberry pi could take up to 10x longer to compile)

You also might need to install GCC 4.6 and compile with this version as 4.9 takes to much memory
Creating a large swap file does not solve the problem, and build with 'make -j 3'

If you are using an old version of the Raspberry Pi, remove the "-j 4" from the make commands!

This will also work for Debian systems, but one these systems you do not need to install the wiringpi library

sudo apt-get install cmake make gcc g++ libssl-dev git curl libcurl4-openssl-dev libusb-dev wiringpi

Change to your source folder (could be your home folder)

Build & Install Boost Libraries

If this is a clean system, continue at Now build and install the Boost library.

[ This should most likely not be needed. The only thing you need to do is to add the flag -DCMAKE_EXE_LINKER_FLAGS=-lboost_atomic to the cmake command when building Domoticz below. I do not own an Raspberry PI so I have not tested it on an Raspberry PI but I have tested it on other ARM computer running debian (sterys) ]


Its recommended that you use the latest Boost libraries - as of 13th November 2016 that is version 1.62.0.
For this we need to compile/install them by issuing the following commands:
These instructions can also be used on a Linux system.

[This first step is necessary because you will get linking errors if you don't remove the old Boost library]

Instructions here are for removing boost 1.55, on your system this might be another version, so adopt these commands to your need. It could also be you never installed boost on your system, do not worry, just execute the commands

sudo apt-get remove libboost-dev libboost-thread-dev libboost-system-dev libboost-atomic-dev libboost-regex-dev
sudo apt-get remove libboost-date-time1.55-dev libboost-date-time1.55.0 libboost-atomic1.55.0 libboost-regex1.55.0 libboost-iostreams1.55.1
sudo apt-get remove libboost-iostreams1.55.0 libboost-iostreams1.55.0 libboost-iostreams1.55.0
sudo apt-get remove libboost-serialization1.55-dev libboost-serialization1.55.0 libboost-system1.55-dev
sudo apt-get remove libboost-system1.55.0 libboost-thread1.55-dev libboost-thread1.55.0 libboost1.55-dev
sudo apt-get autoremove

Now build and install the Boost library.

mkdir boost
cd boost
wget https://sourceforge.net/projects/boost/files/boost/1.62.0/boost_1_62_0.tar.gz/download
tar xvfz download
rm download
cd boost_1_62_0/
./bootstrap.sh
./b2 stage threading=multi link=static --with-thread --with-date_time --with-system --with-atomic --with-regex
sudo ./b2 install threading=multi link=static --with-thread --with-date_time --with-system --with-atomic --with-regex
cd ../../
rm -Rf boost/

Build Support for OpenZWave

If you need support for ZWave, you need to compile open-zwave before compiling domoticz
Make sure to follow the below steps, you will end up with a folder layout like:

- open-zwave-read-only
- dev-domoticz

sudo apt-get install libudev-dev

For the first time, you need to clone the code (copy) from GitHub into your system:

git clone https://github.com/OpenZWave/open-zwave open-zwave-read-only

Refresh the source and build OpenZWave(1m23.057s for initial build (rpi2 3 minutes))

cd open-zwave-read-only
git pull
make -j 3

go back to the top folder (your Home directory) with:

cd .. or cd ~

Domoticz Source

For the first time, you need to checkout the source from GitHub onto your system:

git clone https://github.com/domoticz/domoticz.git dev-domoticz

Note building on pi 3 with image september jessy with gcc 4.9, you need bigger swapspace 512 instead of 100 (see https://www.raspberrypi.org/forums/viewtopic.php?f=26&t=46472) or else it will take ages...

Build Domoticz (21m15.899s on a raspberry pi 3 , 35m0.646s on a raspberry pi 2 for initial build)

If you have updated dev-domoticz, the make step will only re-build those files that have been changed - although if a header-file common to a lot of source files has been changed, this will still take a long time

Change to the Domoticz directory, refresh the source and and start building

cd dev-domoticz
git pull
cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt
make -j 3

设置Domoticz开机自启动(网页升级后也需要)

sudo cp domoticz.sh /etc/init.d
sudo chmod +x /etc/init.d/domoticz.sh
sudo update-rc.d domoticz.sh defaults

编辑启动脚本,修改USERNAME, DAEMON 及 DAEMON_ARGS参数为你自己的设置

sudo vi /etc/init.d/domoticz.sh

USERNAME=pi
DAEMON=/home/$USERNAME/domoticz/$NAME
DAEMON_ARGS="-daemon -www 8080"

如果想用另一个端口访问domoticz,将8080修改为你需要的端口号即可:

DAEMON_ARGS="-daemon -www 8080"

测试Domoticz (确保获取文件所有权!)

cd domoticz
sudo ./domoticz

Start Domoticz

sudo service domoticz.sh start

然后到浏览器中查看Domoticz是否运行正常。

升级Domoticz

升级前请一定备份数据库及自定义脚本等内容,升级会导致某些修改丢失。

二进制安装更新

使用web界面中的选项升级Domoticz(设置->软件更新)

如果升级失败(例如下载错误),你需要手动升级:

稳定版:

cd domoticz
sudo sh ./updaterelease

Beta版:

cd domoticz
sudo sh ./updatebeta

如果以上命令出现连接失败的问题,可以编辑升级脚本,将domoticz.com改为domoticz.cn。

源码升级

cd domoticz
git pull
make -j 4