树莓派设置
使用清华镜像源
先编辑 raspi.list 文件
sudo vi /etc/apt/sources.list.d/raspi.list
替换为
deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main
再编辑
sudo vi /etc/apt/sources.list
替换为
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware更新系统
sudo apt update && sudo apt upgrade -y设置语言
sudo apt update
sudo apt install locales -y
sudo dpkg-reconfigure locales
选择 en_GB.UTF-8 UTF-8
输入命令 locale 验证
VIM
安装 VIM
sudo apt install vim
基本配置
inoremap <silent> jk <Esc>
vnoremap > >gv
vnoremap < <gv
vnoremap = =gv
set mouse=a
syntax on
filetype plugin indent on
set autoread
set encoding=utf-8
set fileencodings=utf-8
set number
set relativenumber
set cursorline
set tabstop=4
set shiftwidth=4
set expandtab
set backspace=indent,eol,start
set incsearch
set hlsearch
set ignorecase
set smartcase
set laststatus=2
set showcmd
set showmode
set list
set listchars=tab:>-,trail:.
set wildmenu
set wildmode=list:longest,full
set nobackup
set nowritebackup
set noswapfiledocker
安装 docker
curl -fsSL https://get.docker.com -o install-docker.sh
sudo sh install-docker.sh --mirror Aliyun
开机启动
sudo systemctl enable docker设置 rootless 树莓派不推荐做
当前用户添加到 docker 用户组
sudo usermod -aG docker $USER
newgrp docker
设置 rootless
sudo apt update
sudo apt install -y uidmap
dockerd-rootless-setuptool.sh install
echo 'export DOCKER_HOST=unix:///run/user/1000/docker.sock' >> ~/.bashrc
source ~/.bashrc
sudo loginctl enable-linger [username]
# verify
docker info | grep rootless设置 docker 镜像
设置 docker 镜像,可以在这里找找。root 模式是 /etc/docker/daemon.json,rootless 模式是 ~/.config/docker/daemon.json
sudo vim /etc/docker/daemon.json
# mkdir -p .config/docker
# vim .config/docker/daemon.json
{
"registry-mirrors": [
"https://docker.1ms.run"
]
}
# restart docker, root
sudo systemctl restart docker
# restart docker, rootless
# systemctl --user restart docker.service设置代理
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo nano /etc/systemd/system/docker.service.d/proxy.conf
写入下面的内容
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890"
Environment="HTTPS_PROXY=http://127.0.0.1:7890"
Environment="NO_PROXY=localhost,127.0.0.1"
保存退出后执行
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl restart docker测试一下
docker run --rm hello-world网络问题
下载 mihomo
mihomo 这里就直接使用命令行版本,可以从 GitHub 下载,下载的版本是 xxx-linux-arm64-xxx.deb 将文件通过 scp 复制到树莓派
scp .\mihomo-linux-arm64-alpha-xx.deb kilos@192.168.101.xx:~/安装文件
sudo apt install mihomo-linux-arm64-alpha-xx.deb配置文件
编辑 /etc/mihomo/config.yaml 文件,如果不存在就创建。
具体内容查看这两个链接。
也可以从其他软件直接把配置复制出来,比如 clash-party(mihomo-party)。
创建完成配置文件可以测试一下
mihomo -t
创建服务启动可以参考创建运行服务 - 虚空终端 Docs
# 开启 mihomo 服务
sudo systemctl start mihomo
# 开启自启动服务
sudo systemctl enable mihomo
# 查看运行日志
sudo journalctl -u mihomo -o cat -e
检查是否可以正常运行
curl -x http://127.0.0.1:7890 https://ipinfo.io
有可能缺少一些文件导致不能正常启动,可以先在本地下载好这两个文件
wget -O geoip.metadb https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geoip.metadb
wget -O geosite.dat https://github.com/MetaCubeX/meta-rules-dat/releases/latest/download/geosite.dat
然后传到树莓派
scp geoip.metadb geosite.dat user@xxx.xxx.xxx.xx:~/
然后再树莓派移动一下文件位置
sudo mv geoip.metadb geosite.dat /etc/mihomo
然后重新启动一下树莓派就可以了
sudo systemctl restart mihomo
创建个函数方便开启关闭代理,在 .bashrc 中写入
proxy() {
if [ "$1" = "on" ]; then
export https_proxy=http://127.0.0.1:7890
export http_proxy=http://127.0.0.1:7890
export all_proxy=http://127.0.0.1:7890
echo "Proxy is ON"
elif [ "$1" = "off" ]; then
unset https_proxy http_proxy all_proxy
echo "Proxy is OFF"
else
echo "Usage: proxy [on|off]"
echo "Current proxy settings:"
echo " http_proxy=$http_proxy"
echo " https_proxy=$https_proxy"
echo " all_proxy=$all_proxy"
fi
}