想用上闲置的树莓派利用200M的上行带宽整点东西,记录一下。(draft)
树莓派配置
系统配置
- 刷 Ubuntu Server 22.04 镜像。
刷22版本主要是考虑到20的生命周期不剩太多了。注意可以通过imager配置ssh连入的authorized_key
- 在路由器内查设备ip,ssh上之后通过
sudo passwd root
修改root口令。
先整体更新一下,少点事
1 | sudo apt update |
webmin 配置
curl -o setup-repos.sh https://ghproxy.com/https://raw.githubusercontent.com/webmin/webmin/master/setup-repos.sh
sudo sh setup-repos.sh
sudo apt-get update
sudo apt-get install --install-recommends webmin
- 访问
https://xxxx:10000
webmin的主要目的是监视流量,对服务可用性有基本的了解。
navidrome配置
参考 https://www.navidrome.org/docs/installation/linux/
upgrade的时候可能要重启
sudo apt update
sudo apt upgrade
sudo apt install vim ffmpeg
配置组。我们使用专门的组来配置服务
sudo groupadd navidrome
sudo useradd -m -g navidrome navidrome
sudo install -d -o navidrome -g navidrome /opt/navidrome
sudo install -d -o navidrome -g navidrome /var/lib/navidrome
wget https://github.com/navidrome/navidrome/releases/download/v0.49.3/navidrome_0.49.3_Linux_arm64.tar.gz -O Navidrome.tar.gz
sudo tar -xvzf Navidrome.tar.gz -C /opt/navidrome/
sudo chown -R navidrome:navidrome /opt/navidrome
sudo -u navidrome -s
挂载移动硬盘
sudo fdisk -l
sudo mkdir /mnt/storage
sudo mount /dev/sdb1 /mnt/storage
Create Configuration File:
sudo vi /var/lib/navidrome/navidrome.toml
注意这个引号很重要
1 | MusicFolder="/mnt/storage/music" |
sudo vi /etc/systemd/system/navidrome.service
1 | [Unit] |
1 | sudo systemctl daemon-reload |
nginx 配置
安装
https://nginx.org/en/linux_packages.html#Ubuntu
vi /etc/nginx/nginx.conf
server {
listen 765 ssl;
server_name www.imas-music.top;
ssl_certificate /etc/letsencrypt/live/imas-music.top/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/imas-music.top/privkey.pem;
location / {
proxy_pass http://localhost:4533;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
一会儿reload
let’s encrypt 配置
- 安装snap。snap为默认安装项,不过可以通过以下命令确认
1 | sudo snap install hello-world |
- 配置certbot&aliyun插件
sudo snap install –classic certbot
git clone https://github.com/tengattack/certbot-dns-aliyun
cd certbot-dns-aliyun
sudo python3 setup.py install
cd ..
https://ram.console.aliyun.com/users
1 | dns_aliyun_access_key = 12345678 |
chmod 600 ./aliyun_credentials.ini
sudo certbot certonly –authenticator=dns-aliyun –dns-aliyun-credentials=’/home/darwin/aliyun_credentials.ini’ -d “*.imas-music.top,imas-music.top”
sudo crontab -e
1 | 0 0 * * * certbot renew --quiet |
树莓派配置内网静态ip
通过路由器配置
ddns
docker 安装 https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository
https://github.com/sanjusss/aliyun-ddns
1 | docker run -d --restart=always --net=host \ |
dns
docker run -d –restart=always –net=host
-e “AKID=LTAI5tBBzeLfS2HtXVgzcWj2”
-e “AKSCT=ktwlEWwcFgntTLu08kbH4rr6RhxYl6”
-e “DOMAIN=www.imas-music.top"
-e “REDO=30”
-e “TTL=600”
-e “TIMEZONE=8.0”
-e “TYPE=A,AAAA”
sanjusss/aliyun-ddns
增加CNAME记录
@ - CNAME - www.xxxx.top
navidrome 转码
手动预转码
选择256k的aac
#!/bin/bash
Source directory
SRC_DIR=”SHINY COLORS”
Destination directory
DEST_DIR=”aac”
Function to convert various audio formats to AAC
convert_to_aac() {
local src=”$1”
local dest=”${DEST_DIR}${src#$SRC_DIR}”
local extension=”${src##*.}”
dest=”${dest%.$extension}.m4a”
Create destination directory
mkdir -p “$(dirname “$dest”)”
Convert to AAC
ffmpeg -hwaccel cuvid -i “$src” -c:v copy -c:a aac -b:a 256k “$dest”
}
Export function and destination directory for parallel processing
export -f convert_to_aac
export DEST_DIR
Find all supported audio files in source directory and convert them in parallel
1 | find "$SRC_DIR" -type f \( -name "*.flac" -o -name "*.wav" -o -name "*.wv" -o -name "*.aiff" -o -name "*.m4a" \) -print0 | xargs -0 -n 1 -P 8 -I {} bash -c 'convert_to_aac "$@"' _ {} |
ftp 设置
sudo apt-get install vsftpd
sudo umount -l /mnt/storage
sudo mount -o iocharset=utf8 /dev/sda1 /mnt/storage