为nanopi m1写一个自动配置脚本,简化自己的操作
配置:H3芯片,1G内存,64G卡
系统:friendlycore focal 4.14版本
烧录系统后,插入机器,但是使用df -ih
发现只有900K的nodes,不够。解决方法:重新插入windows电脑,删除该部分卷,重新插入机器后就有3.6M的nodes,才可以进行后面的docker安装操作。
管理员账号为pi,密码为fa。
使用sudo apt-get update && sudo apt-get upgrade -y
进行更新
保存如下配置脚本,nano setup_sys.sh
。随后使用chmod +x setup_sys.sh
进行配置,以及bash ./setup_sys.sh
进行运行。
#!/bin/bash
# 1. Update the system
sudo apt-get update && sudo apt-get upgrade -y
# 2. Install pip3
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py
rm get-pip.py
pip -V
# 3. Install Docker
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=armhf] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
sudo apt-get install docker-ce -y
# Set Docker to start on boot
sudo systemctl enable docker
sudo systemctl start docker
# docker-compose
sudo apt-get install libffi-dev libssl-dev -y
sudo apt-get install -y python3 python3-pip -y
sudo apt-get remove python-configparser -y
sudo apt-get install docker-compose -y
# 4. Install Portainer
docker volume create portainer_data
docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce
# 5. Install other common tools
sudo apt-get install -y git vim htop net-tools
echo "Setup complete!"
创建一个 docker-compose.yml 文件,如下。
version: '3'
services:
homeassistant:
image: homeassistant/home-assistant:latest
container_name: homeassistant
volumes:
- /root/appdata/hass:/config
ports:
- "8123:8123"
network_mode: "host"
restart: unless-stopped
nodered:
image: nodered/node-red:latest
container_name: nodered
ports:
- "1880:1880"
restart: unless-stopped
esphome:
image: esphome/esphome
container_name: esphome
ports:
- "6052:6052"
restart: unless-stopped
eclipse-mosquitto:
image: eclipse-mosquitto:latest
container_name: mosquitto
ports:
- "1883:1883"
- "9001:9001"
restart: unless-stopped
再创建一个setup_hass.sh文件,如下。
#!/bin/bash
# Create the directory for homeassistant config files
mkdir -p /root/appdata/hass
# Use docker-compose to start all services
docker-compose up -d
尝试安装opencv-python,运行在系统的默认python3上。
安装OpenCV的构建依赖项,运行以下命令:
sudo apt-get install libopencv-dev python3-opencv
然后,使用Python 3的pip来安装opencv-python包:
pip install opencv-python
pip3 install opencv-python
这将使用Python 3的pip来安装OpenCV的Python包。
安装完成后,您可以验证安装是否成功:
python3 -c "import cv2; print(cv2.__version__)"
这将打印出安装的OpenCV版本号,以确认opencv-python已成功安装。