树莓派3B+raspbian+docker+hassio安装教程

说明:

1:此文转载,侵删]参考https://bbs.hassbian.com/thread-3501-1-1.html

2:修改echo "`date +%H:%M:%S`>>>>>>>>>>使用root用户安装 Hass.io<<<<<<<<<<"安装源地址

3:本人安装配置:树莓派3B+raspbian stretch Lite +docker+hassio

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

1:raspbian官网下载系统,本次安装为stretch lite版本.
2:用Etcher烧炉系统,烧炉结束在根目录新建ssh文件,开启ssh功能;新增wpa_supplicant.conf文件,写入内容:

country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
   ssid="wifi-name"    
   psk="wifi-key"
   key_mgmt=WPA-PSK    
   priority=1
}

3,用ipscaner找打树莓派的ip地址,用putty工具SSH到你的raspbian系统,用户名是pi,密码是raspberry。
首先要把系统读写区域扩大到整个内存卡

sudo raspi-config


然后选择第7项 advanced settings高级设置 的第1项  回车,确定。

重启树莓派系统sudo reboot


重新ssh连接.

 

cd /tmp
进入缓存目录
sudo nano docker_hassio.sh
创建一个临时shell文件
复制以下内容,粘贴到putty,

#!/bin/bash

#首先,运行以下命令,将SD卡扩大到整个空间,然后重启树莓派
#sudo raspi-config
#选7 ----> 选1

#设置中文语言   选4 ----> 选1  拉到最后选Zh-cn的GBK UTF-8等
#设置时区      选4 ----> 选2   选 Asia ----Shanghai
#设置wifi地区  选4 ----> 选4   选 CN china
#sudo reboot

#重启之后,依次运行以下命令
#cd /tmp
#sudo nano docker_hassio.sh
#复制本文件内容,到ssh命令行中,保存,关闭,然后依次运行下面的命令
#sudo chmod u+x docker_hassio.shnetwork
#sudo ./docker_hassio.sh 1>&2



echo
echo "`date +%H:%M:%S`<<<<<<<<<<<<一键安装脚本开始执行>>>>>>>>>>>>>"
echo

echo "<<<<<<<<<<<<修改源地址>>>>>>>>>>>>>"
sudo tee /etc/apt/sources.list <<-'EOF'
#deb http://mirrors.aliyun.com/raspbian/raspbian/ stretch main contrib non-free rpi
#deb-src http://mirrors.aliyun.com/raspbian/raspbian/ stretch main contrib non-free rpi
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
deb-src http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
#deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ stretch main contrib non-free rpi
#deb-src https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ stretch main contrib non-free rpi
EOF

sudo tee /etc/apt/sources.list.d/raspi.list <<-'EOF'
#deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ stretch ui
deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch ui
#deb http://mirrors.aliyun.com/debian/ stretch ui
EOF
echo

# echo "`date +%H:%M:%S`<<<<<<<<<<<<配置中文字符集>>>>>>>>>>>>>"
# sudo tee /etc/locale.gen <<-'EOF'
# zh_CN.GB2312
# zh_CN.GBK GBK
# zh_CN.UTF-8 UTF-8
# EOF
# sudo locale-gen
# echo


echo "`date +%H:%M:%S`>>>>>>>>>>添加HTTPS传输软件包以及CA证书<<<<<<<<<<"
sudo apt-get install -y \apt-transport-https \ca-certificates \curl \gnupg2 \software-properties-common
echo


echo "`date +%H:%M:%S`>>>>>>>>>>添加Docker 官方GPG密钥<<<<<<<<<<"
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
sleep 1
echo

echo "`date +%H:%M:%S`>>>>>>>>>>添加 Docker CE 软件源<<<<<<<<<<"
echo "deb [arch=armhf] https://download.docker.com/linux/debian \
      $(lsb_release -cs) stable" | \
     sudo tee /etc/apt/sources.list.d/docker.list
sleep 1
echo

echo "`date +%H:%M:%S`>>>>>>>>>>更新 apt 软件包缓存并安装Docker CE<<<<<<<<<<"
sudo apt-get update && apt-get upgrade -y 
sudo apt-get install docker-ce -y
echo

echo "`date +%H:%M:%S`>>>>>>>>>>将当前用户添加到 Docker 组<<<<<<<<<<"
#sudo groupadd docker
sudo usermod -aG docker $USER
echo

echo "`date +%H:%M:%S`>>>>>>>>>>修改Docker仓库到国内加速器<<<<<<<<<<"
#sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://registry.docker-cn.com"]
}
EOF
sleep 2
echo

echo "`date +%H:%M:%S`>>>>>>>>>>重新加载Docker配置并重启<<<<<<<<<<"
sudo systemctl daemon-reload
sudo systemctl restart docker
sleep 3

cd ~
mkdir .pip
sudo tee ~/.pip/pip.conf <<-'EOF'
[global]
trusted-host=mirrors.aliyun.com
index-url=http://mirrors.aliyun.com/pypi/simple
EOF
sleep 3


echo "`date +%H:%M:%S`>>>>>>>>>>获取最新源列表并更新软件<<<<<<<<<<"
sudo apt-get update && apt-get upgrade -y
sudo apt-get dist-upgrade -y
echo

echo "`date +%H:%M:%S`>>>>>>>>>>安装bash socat jq支持库软件<<<<<<<<<<"
sudo apt-get install -y bash jq curl avahi-daemon dbus apparmor-utils network-manager
echo


echo "`date +%H:%M:%S`>>>>>>>>>>安装Samba Git Screen Net-tools Nmap工具软件,配置Samba共享目录<<<<<<<<<<"
sudo apt-get install -y samba screen git net-tools nmap
echo "
[global]
netbios name = Raspberry Pi
server string = The Pi File Center
workgroup = WORKGROUP
hosts allow =
remote announce =
remote browse sync =
create mask = 0777
directory mask = 0777
force user = root
force create mode = 0777
force directory mode = 0777
hosts allow = 

[Home Assistant] 
path = /usr/share/hassio
comment = No comment
browsable = yes
read only = no
valid users =
writable = yes
guest ok = yes
public = yes


[Pi Home] 
path = /
comment = No comment
browsable = yes
read only = no
valid users = 
writable = yes
guest ok = yes
public = yes


[Pi Share] 
path = /home/pi
comment = No comment
browsable = yes
read only = no
valid users = 
writable = yes
guest ok = yes
public = yes
" >>/etc/samba/smb.conf
echo "`date +%H:%M:%S`>>>>>>>>>>等待重启Samba<<<<<<<<<<"
sleep 1
sudo service smbd restart
sleep 3

echo "`date +%H:%M:%S`>>>>>>>>>>拉取Docker可视化工具(portainer)<<<<<<<<<<"
sudo su -c "docker pull portainer/portainer:latest"
echo "`date +%H:%M:%S`>>>>>>>>>>配置Docker可视化工具到9010端口<<<<<<<<<<"
docker run -d -p 9010:9000 --name docker-portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer
echo

echo "`date +%H:%M:%S`>>>>>>>>>>拉取homeassistant镜像<<<<<<<<<<"
docker pull homeassistant/raspberrypi3-homeassistant:latest
echo

echo "`date +%H:%M:%S`>>>>>>>>>>拉取hassio-supervisor镜像<<<<<<<<<<"
docker pull homeassistant/armhf-hassio-supervisor:latest

echo "`date +%H:%M:%S`>>>>>>>>>>使用root用户安装 Hass.io<<<<<<<<<<"
# docker run -d --name="home-assistant" -v /path/to/your/config:/config -e "TZ= Asia/Chongqing" -p 8123:8123 homeassistant/raspberrypi3-homeassistant:0.84.3
sudo su -c "curl -sL -o install.sh https://raw.githubusercontent.com/neroxps/hassio_install/master/install.sh
chmod a+x install.sh
./install.sh"
echo

echo "`date +%H:%M:%S`>>>>>>>>>>安装完成,配置完Portainer后,输出Hassio日志<<<<<<<<<<"

echo "`date +%H:%M:%S`>>>>>>>>>>请用浏览器打开IP:9010,完成Portainer的配置"
read -p "等待中,按 回车键 进行下一步" 
echo "`date +%H:%M:%S`>>>>>>>>>>重启Hassio容器并输出日志<<<<<<<<<<"
# sudo systemctl restart hassio-supervisor 
sudo journalctl -fu hassio-supervisor





 

之后保存退出:Ctrl+O(保存),Ctrl+X(关闭)。
sudo chmod u+x docker_hassio.sh
授予sh文件读写权限
sudo ./docker_hassio.sh 1>&2
执行脚本。

手动打开浏览器,打开你的树莓派IP:9010 登录到portainer 客户端,创建管理账户,回车。
选择左边的Local  本地docker服务器 
Docker socket to manage a local Docker engine 
确定。

然后回到putty,按任意键系统自动安装,并开始输出hassio安装日志。
大约半小时后,基本就安装完成了,打开浏览器 ip:8123就可以了。

https://github.com/home-assistant/hassio-addons
https://git.coding.net/tomczhen/hassio-addons.git
https://github.com/neroxps/hassio-addons

https://github.com/bestlibre/hassio-addons
https://github.com/danielperna84/hassio-addons
https://github.com/vkorn/hassio-addons
https://github.com/gollo/hassio-addons
https://github.com/sunnythaper/sunnys-hassio
https://github.com/HerrHofrat/hassio-addons
https://github.com/balloob/hassio-addon-experiments
https://github.com/home-assistant/hassio-addons-example
https://github.com/ohmer1/hassio-addons
https://github.com/bramkragten/hassio-addons
https://github.com/adamrutt/hassio-addons
https://github.com/frenck/incubator
https://github.com/nalipaz/hassio-addons
https://github.com/odinuge/hassio-addons
https://github.com/pstreule/hassio-addons
https://github.com/charleyzhu/hassio-addons
https://github.com/notoriousbdg/hassio-addons
https://github.com/pantomax/haxio
https://github.com/Romkabouter/hassio-addons

你可能感兴趣的:(python)