使用便宜的4g模块 配合docker来转发你的短信 libgammu smsforwarder golang

为什么会有这篇文章

刚开始一直在用SmsFordarder在安卓手机上进行短信转发,长期占用安卓手机,老化的电池也不放心,咸鱼发现有便宜可用的支持短信的4g模块,顺带研究一下相关的内容,就自己用golang写了相关服务。

我自己的硬件配置

主板 orange pi5 max 很不错的板子,我在上面跑frigate、jellyfin 能解码,能跑图像识别。
cpu rk3588 x86和arm64都可以
系统 ubuntu server22.04 因为还在跑redroid,需要5.10内核,所有没用24.04系统
4g模块 移远的EC200T-CN 咸鱼10块钱,cat4速率,但是我不需要用它上网,便宜,有短信,有通话接口就行。
usb转4g板子 咸鱼搜 mini pcie转4g模块 20块钱
天线 2根 IPEX一代接口
sim卡信息 中国联通 没其他卡,没测试移动和电信

软件配置

  • docker就行了。
  • 相关代码:
  • 我用golang写的一份读取短信和来电的服务gammu-web
  • 配合golang的通知服务ForwardSMS

准备转发配置文件forward.yaml

# 如果有all这个配置,就是默认所有短信都会转发给这个企业微信机器人,建议发送给管理员,或者直接删除关闭
all:
    rule: all
    type: all
    notify: wechat
    url: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxx

# 从上到下依次为 项目名称、规则(使用关键字匹配)
测试:
    rule: 测试DDD
    type: keyword
    notify: wechat
    url: https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxxxx

# 正则匹配规则
工单号:
    rule: "\\d{8}" # 匹配8位数字
    type: regex
    notify: gotify
    url: https://gotify.example.com
    token: your_app_token

# 转发给ios用它。
bark:
    notify: bark
    type: all
    rule: all
    url: "https://api.day.app/xxxx"

# 转发给安卓用它。
gtify:
    notify: gotify
    type: all
    rule: all
    url: "https://gotify.example.com"
    token: "your_app_token"

# emm邮箱转发
email:
    notify: email
    type: all
    rule: all
    smtp_host: "smtp.qq.com"
    smtp_port: "587"
    username: "[email protected]"
    password: "授权码"
    from: "[email protected]"
    to: "[email protected]"

配置docker-compose.yaml (支持x86和arm64)

version: "3"
services:
  # https://github.com/scjtqs2/ForwardSMS
  forwardsms:
    image:  ghcr.io/scjtqs2/forwardsms/forwardsms:latest
    environment:
      - FORWARD_SECRET=your_shared_secret_here
      - TZ=Asia/Shanghai
      - HTTP_PORT=8080
    volumes:
      # 挂载上面配置的推送文件
      - ./forward.yaml:/data/config/forward.yaml
    restart: always
    expose:
      - 8080

  # https://github.com/scjtqs2/gammu-web
  gammu-web:
    image: ghcr.io/scjtqs2/gammu-web:latest
    environment:
        - FORWARD_ENABLED=1
        # 写死
        - FORWARD_URL=http://forwardsms:8080/api/v1/sms/receive
        # 和forwardsms里面的要一致。
        - FORWARD_SECRET=your_shared_secret_here
        - TZ=Asia/Shanghai
        # 转发通知携带的标识。
        - PHONE_ID=SMS1_186xxxxxxxx
        - ATCONNECTION=at9600
        # ec200t-cn 默认的管理接口就是/dev/ttyUSB1(能同时收发短信,还能读取来电显示数据用来达到转发来电通知)。根据实际情况自行调整。
        - USB_PORT=/dev/ttyUSB1
        - API_PORT=21234
        # web网页访问用到。
        - API_TOKEN=your_shared_token_here
        - GAMMU_DEBUG=false
        - DEBUG=0
        - CALL_FORWARD_ENABLED=true
        - CALL_FORWARD_URL=http://forwardsms:8080/api/v1/call/receive
    volumes:
      - ./data:/data
    # 加了这个,就不用挨个去映射 /dev/ttyUSBx了
    privileged: true
    restart: always
    ports:
      - 21234:21234

浏览全部

macOS 版本下 Docker for Desktop 跨cpu架构运行容器的方法

如果你是x86架构(intel)的macOS:

# 运行x86的容器
docker run -it --rm alpine sh

# 运行arm架构的容器
docker run -it --rm --platform linux/arm64 alpine sh

如果你是arm架构(m1)的macOS:

# 运行arm架构的容器
docker run -it --rm alpine sh

# 运行x86架构的容器
docker run -it --rm --platform linux/amd64 alpine sh

ubuntu下 podman 转发端口 ufw 防火墙 不能放过( 不兼容) 的临时处理方案

podman的网络使用的是 iptables 的转发。不支持ufw开放/禁用 端口。 开了ufw防火墙后,podman 转发的端口基本上就只能本地访问了。这是个大坑

方法1

ifconfig

执行后,可以找到一些 cni-popdman0 这种的interface。 使用iptables对所有的相关cni都转发一下 例如:

iptables -I FORWARD -p tcp ! -i cni-podman0 -o cni-podman0 -j ACCEPT

这样,即使开启着 ufw。你的podman的端口也能通过外部访问了。 不过不安全。这是全部转发的端口都允许了。所以只是临时方案。否则只能关闭ufw(不能接受)

方法2

  • 编辑 /etc/default/ufw 修改 DEFAULT_FORWARD_POLICY 的值为 ACCEPT
  • sudo ufw reload

Docker CE 镜像源站 linux 下国内源安装 阿里源

使用官方脚本:

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

 

Ubuntu 14.04 16.04 (使用apt-get进行安装)

# step 1: 安装必要的一些系统工具
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
# step 2: 安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
# Step 3: 写入软件源信息
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
# Step 4: 更新并安装 Docker-CE
sudo apt-get -y update
sudo apt-get -y install docker-ce

CentOS 7 (使用yum进行安装)

# step 1: 安装必要的一些系统工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
# Step 2: 添加软件源信息
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3: 更新并安装 Docker-CE
sudo yum makecache fast
sudo yum -y install docker-ce
# Step 4: 开启Docker服务
sudo service docker start

 

ubuntu下docker存储位置迁移

背景

树莓派上运行docker,自带tf卡性能太差,插了个usb的ssd上去,因此需要迁移docker的存储

步骤

停止docker

service docker stop

移动docker数据文件夹

此处有两种方法 方法一: rsync命令,同步文件,原文件夹保留

cd /opt
mkdir docker
rsync -aqxP /var/lib/docker/ /opt/docker/

方法二:mv命令

cd /var/lib/
mv docker /opt/

我使用的是mv命令。 浏览全部

docker版的 开源邮局系统 全套教程 mailu

前言:

1、我这里用的是mailu的邮局系统。有兴趣的朋友可以去它的github官方网址查看:https://github.com/Mailu/Mailu

2、用到的docker-compose配套的配置文件地址:https://github.com/scjtqs/docker-mail

3、这里用到了docker-compose工具,对于群晖之类的无法安装docker-compose的环境,我这里提供了docker版的docker-compose工具:https://hub.docker.com/r/scjtqs/docker-compose

安装环境情况,我这里介绍如下几种情况的安装:

1、具有固定ip的云服务器。

2、具备公网ip的家庭宽带

3、不具备公网ip的家庭宽带 浏览全部

mailu 一个 docker化的邮局系统 docker-compose配置

首先,去 https://setup.mailu.io/ 获取你对应的docker-compose和 mailu.env

详细设置 在 https://mailu.io/1.7/compose/setup.html#tls-certificates

Step 1 – 下载配置文件

Docker Compose expects a project file, named docker-compose.yml in a project directory. First create your project directory.
mkdir /mailu
Then download the project file. A side configuration file makes it easier to read and check the configuration variables generated by the wizard.
cd /mailu
wget http://setup.mailu.io/1.7/file/xxxxxxxxxxxxxxxxxxxxxxxxxxx/docker-compose.yml
wget http://setup.mailu.io/1.7/file/xxxxxxxxxxxxxxxxxxxxxxxxxxx/mailu.env 

Step 2 – Review the configuration

We did not insert any malicious code on purpose in the configurations we distribute, but your download could have been intercepted, or our wizard website could have been compromised, so make sure you check the configuration files before going any further. When you are done checking them, check them one last time.

Step 3 – Start the Compose project

To start your compose project, simply run the Docker Compose up command using -p mailu flag for project name.
cd /mailu
docker-compose -p mailu up -d
Before you can use Mailu, you must create the primary administrator user account. This should be [email protected]. Use the following command, changing PASSWORD to your liking:
docker-compose -p mailu exec admin flask mailu admin admin 你的根域名 PASSWORD
Login to the admin interface to change the password for a safe one, at one of the hostnames 你的域名/admin. Also, choose the “Update password” option in the left menu.

关于汉化和证书优化:

1、将docker-compose.yml中的admin的镜像替换成 scjtqs/mailu-admin:latest 可以完成后台管理的汉化。 2、将docker-compose.yml中的front服务的镜像 替换成 scjtqs/mailu-nginx:latest 即可替换成dnspod接口的dns方式验证获取和更新证书。 当然,想要使用dnspod的dns验证,需要提供dnspod的一些账号信息。并将其挂载到front的容器中去 挂载路径:”./cetbot-dns-dnspod-credentials.ini:/etc/cetbot-dns-dnspod-credentials.ini” 例如在docker-compose.yml中:
volumes:
  - "./mailu/certs:/certs"
  - "./mailu/overrides/nginx:/overrides"
  - "./cetbot-dns-dnspod-credentials.ini:/etc/cetbot-dns-dnspod-credentials.ini"
    cetbot-dns-dnspod-credentials.ini中的配置信息:
certbot_dns_dnspod:dns_dnspod_email = "DNSPod 账户的 Email"
certbot_dns_dnspod:dns_dnspod_api_token = "api_id,api_token"