1.更换国内源
cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo nano /etc/apt/sources.list
# 默认注释了源码镜像以提高 apt update 速度
# 清华大学的软件源
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-backports main contrib non-free
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free
# 阿里云的软件源
# deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
# deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
# deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
# deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
# deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
# deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
# deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
# deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
# 中科大的软件源
# deb https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
# deb-src https://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
# deb https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
# deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
# deb https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
# deb-src https://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
# deb https://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib non-free
# deb-src https://mirrors.ustc.edu.cn/debian-security bullseye-security main contrib non-free
2.更新软件
sudo apt update && sudo apt upgrade -y
3.下载hosts
sed -i "/# GitHub520 Host Start/Q" /etc/hosts && curl https://raw.hellogithub.com/hosts >> /etc/hosts
docker pull dockerproxy.com/homeassistant/home-assistant:latest
4.安装casaos
wget -qO- https://get.casaos.io | sudo bash
5.安装HACS
进入容器
sudo docker exec -it HomeAssistant /bin/bash
wget -O - https://get.hacs.xyz | bash -
wget -O - https://raw.githubusercontent.com/hacs/get/main/get | bash -
6.安装Xiaomi Miot Auto
29312056
登录不上改host
tee -i /etc/hosts <<-'EOF'
#TMDB.ORG
18.66.15.21 www.themoviedb.org
18.66.15.36 api.themoviedb.org
13.32.110.58 api.tmdb.org
143.244.50.86 image.tmdb.org
183.84.6.64 sts.api.io.mi.com
123.125.103.173 api.io.mi.com
111.202.0.183 account.xiaomi.com
EOF
wget -qO - https://raw.hellogithub.com/hosts | cat - >> /etc/hosts
18.66.15.21 www.themoviedb.org
18.66.15.36 api.themoviedb.org
13.32.110.58 api.tmdb.org
143.244.50.86 image.tmdb.org
183.84.6.64 sts.api.io.mi.com
123.125.103.173 api.io.mi.com
111.202.0.183 account.xiaomi.com
5.固定ip地址
sudo nano /etc/network/interfaces
先修改iface eth0 inet dhcp 为 iface eth0 inet static,然后添加
# iface eth0 inet static
address 192.168.1.41
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 114.114.114.114 8.8.4.4
导入备份的json文件
删除docker中无用的镜像
docker system prune
opwrt
docker pull dockerproxy.com/w8ves/openwrt:onecloud
1.打开网卡混杂模式
sudo ip link set eth0 promisc on
2.创建网络
docker network create -d macvlan --subnet=192.168.1.0/24 --gateway=192.168.1.1 -o parent=eth0 macnet
删除docker网络: docker network rm macnet
docker run --restart always --name openwrt -d --network macnet --ip 192.168.1.252 --privileged dockerproxy.com/w8ves/openwrt:onecloud /sbin/init
docker exec -it openwrt /bin/bash
vi /etc/network/interfaces
将地址修成成192.168.1.252
重启网络
/etc/init.d/network restart
宿主机
nano /etc/network/interfaces
up ip link set eth0 promisc on # 添加这一行代码
用于永久开启混杂模式
src/gz openwrt_core https://mirrors.cloud.tencent.com/lede/snapshots/targets/at91/sama5/packages
src/gz openwrt_base https://mirrors.cloud.tencent.com/lede/snapshots/packages/arm_cortex-a5_vfpv4/base
#src/gz openwrt_freifunk https://mirrors.cloud.tencent.com/lede/snapshots/packages/arm_cortex-a5_vfpv4/freifunk
src/gz openwrt_freifunk https://mirrors4.tuna.tsinghua.edu.cn/lede/releases/19.07.6/packages/arm_cortex-a5_vfpv4/freifunk
#src/gz openwrt_helloworld https://mirrors.cloud.tencent.com/lede/snapshots/packages/arm_cortex-a5_vfpv4/helloworld
src/gz openwrt_luci https://mirrors.cloud.tencent.com/lede/releases/18.06.8/packages/arm_cortex-a5_vfpv4/luci
src/gz openwrt_packages https://mirrors.cloud.tencent.com/lede/snapshots/packages/arm_cortex-a5_vfpv4/packages
src/gz openwrt_routing https://mirrors.cloud.tencent.com/lede/snapshots/packages/arm_cortex-a5_vfpv4/routing
src/gz openwrt_telephony https://mirrors.cloud.tencent.com/lede/snapshots/packages/arm_cortex-a5_vfpv4/telephony
src/gz openwrt_core https://archive.openwrt.org/releases/21.02.1/targets/at91/sama5/packages
src/gz openwrt_base https://archive.openwrt.org/releases/21.02.1/packages/arm_cortex-a5_vfpv4/base
https://mirrors.ustc.edu.cn/openwrt/releases/packages-19.07/arm_cortex-a5_vfpv4/telephony/
/lede/releases/19.07.1/targets/at91/sama5/packages
https://archive.openwrt.org/releases/21.02.1/targets/at91/sama5/packages/
玩客云搭建MQTT服务器
下载安装#
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
cd /etc/apt/sources.list.d/
sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list
sudo wget http://repo.mosquitto.org/debian/mosquitto-stretch.list
sudo wget http://repo.mosquitto.org/debian/mosquitto-buster.list
apt-get update -y
apt-cache search mosquitto
apt-get install -y mosquitto mosquitto-clients
常用命令#
sudo service mosquitto status #查看运行状态
sudo service mosquitto start #启动服务
sudo service mosquitto stop #停止服务
修改配置文件#
MQTT服务器安装了之后,默认监听localhost的1883端口,外网不能够进行访问。如果有需要可以修改配置文件。用户的局部配置文件放在:
/etc/mosquitto/conf.d/目录下,并且这个目录下的所有以.conf后缀的文件都将被mosquitto作为配置文件,在启动时加载。
首先,我们将创建一个Mosquitto将用于验证连接的密码文件。使用mosquitto_passwd来创建这个文件,请确保使用你喜欢的用户名替换它:
sudo mosquitto_passwd -c /etc/mosquitto/passwd your-username #系统将提示您输入两次密码。
在/etc/mosquitto/conf.d 目录下,新建myconfig.conf配置文件:
allow_anonymous false #不允许匿名访问
password_file /etc/mosquitto/passwd #密码文件位置
listener 1883 0.0.0.0 #监听的端口和IP地址
重启Mosquitto以获取配置更改:
sudo systemctl restart mosquitto
检查以确保服务再次运行:
sudo systemctl status mosquitto
● mosquitto.service - LSB: mosquitto MQTT v3.1 message broker
Loaded: loaded (/etc/init.d/mosquitto; generated)
Active: active (running) since Mon 2018-07-16 15:03:42 UTC; 2min 39s ago
Docs: man:systemd-sysv-generator(8)
Process: 6683 ExecStop=/etc/init.d/mosquitto stop (code=exited, status=0/SUCCESS)
Process: 6699 ExecStart=/etc/init.d/mosquitto start (code=exited, status=0/SUCCESS)
Tasks: 1 (limit: 1152)
CGroup: /system.slice/mosquitto.service
└─6705 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
状态应该是active (running)。如果不是,请检查配置文件并重新启动。Mosquitto的日志文件中可能会提供更多信息:
sudo tail /var/log/mosquitto/mosquitto.log
测试MQTT#
测试Mosquitto#
我们在步骤1中安装了一些命令行MQTT客户端。我们可以在localhost监听器上订阅主题测试,如下所示:
mosquitto_sub -h localhost -t test -u "your-user" -P "your-password"
我们可以用mosquitto_pub发布:
mosquitto_pub -h localhost -t test -m "hello world" -u "your-user" -P "your-password"
作者:staluo
出处:https://www.cnblogs.com/stry/articles/17036664.html
版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。