网络与远程访问

TG机器人通知IP地址

背景 公网IPv4政策的收紧,包括不限于不能使用DDNS服务解析到未备案域名,因此使用TG机器人API服务,定时检测IP地址,若IP变化则自动更新 项目地址 Raspberry-Pi/shell/telegram-ip-bot.sh at master · laningya/Raspberry-Pi · GitHub 部署过程 获取ChatID API_TOKEN="YOUR_BOT_TOKEN" curl -s "https://api.telegram.org/bot$API_TOKEN/getUpdates" | jq '.result[0].message.chat.id' 脚本填入Bot的API Token,以及自行判断需要设置代理 添加crontab定时任务 ...

网络与远程访问

Cloudflare和阿里云DDNS的Shell实现

下一步开发计划 接入Telegram机器人,IP变化时自动通知 脚本地址 raw.githubusercontent.com/laningya/Raspberry-Pi/refs/heads/master/shell/cfddns.sh raw.githubusercontent.com/laningya/Raspberry-Pi/refs/heads/master/shell/aliddns.sh 使用说明 Cloudflare proxy=false/true,是否开始Cloudflare小黄云选项 ZONE_ID,API_TOKEN,Cloudflare 域ID和API令牌,API需对应域名的DNS编辑和读取权限 IPv4Domain,需要填写全写,如"test.yourdomain.com" 阿里云 accessKeyId,accessSecret,需要在阿里云控制台获取,并赋予DNS编辑和读取权限 与Cloudflare不同,子域名和主域名分开

Linux与系统运维

服务备份与同步脚本实现

脚本地址 raw.githubusercontent.com/laningya/Raspberry-Pi/refs/heads/master/shell/back.sh raw.githubusercontent.com/laningya/Raspberry-Pi/refs/heads/master/shell/rsync.sh 使用说明 为防止服务器宕机开发,需要配合crontab等服务实现定时备份 针对采用docker-compose部署的服务编写,如为其他方式部署的服务,此脚本并不使用

Linux与系统运维

Armbian/build脚本分析

1. 脚本目录检测和代码健壮性保证 1.1 程序报错退出脚本 #set -o pipefail # trace ERR through pipes - will be enabled "soon" #set -o nounset ## set -u : exit the script if you try to use an uninitialised variable - one day will be enabled set -e set -o errtrace # trace ERR through - enabled set -o errexit ## set -e : exit the script if any statement returns a non-true return value - enabled # Important, go read http://mywiki.wooledge.org/BashFAQ/105 NOW! 1.2. ./compile.sh脚本目录检测 SRC="$(dirname "$(realpath "${BASH_SOURCE[0]}")")" cd "${SRC}" || exit # check for whitespace in ${SRC} and exit for safety reasons grep -q "[[:space:]]" <<< "${SRC}" && { echo "\"${SRC}\" contains whitespace. Not supported. Aborting." >&2 exit 1 } 2. single.sh 文件加载(位于./lib) 2.1 检查bash版本是否高于5.x # The Armbian functions require Bash 5.x. if [[ "${BASH_VERSINFO:-0}" -lt 5 ]]; then echo "Armbian build scripts require Bash 5.x. Go get it..." >&2 if [[ "${OSTYPE}" == "darwin"* ]]; then echo "Armbian build scripts require brew to be installed and working on macOS. (old Bash version)" >&2 echo "Please install brew, *restart your terminal*." >&2 echo "Then run 'brew install bash coreutils git', *restart your terminal* and then try again." >&2 exit 51 fi exit 50 fi 2.2 macOS系统检查 是否以root运行脚本 Homebrew 包管理器已安装并正常工作 通过 Homebrew 的 coreutils 安装的 realpath 命令是否可用 更新 PATH 环境变量以包含由 Homebrew 安装的 GNU coreutils 二进制文件。 确保 ${SRC} 变量(应指向构建脚本的源目录)位于用户的主目录中。这对于 macOS 上的 Docker 兼容性很重要。 ...

Linux与系统运维

VPS测试脚本

三网回程测试脚本 脚本地址 zhanghanyun/backtrace: 三网回程路由测试 (github.com) 命令行 curl https://raw.githubusercontent.com/zhanghanyun/backtrace/main/install.sh -sSf | sh 流媒体/GPT解锁测试脚本 脚本地址 lmc999/RegionRestrictionCheck: A bash script to check the status of your IP on various geo-restricted services. (github.com) 命令行 bash <(curl -L -s check.unlock.media) BBR加速 脚本地址 Chikage0o0/Linux-NetSpeed: 将Linux现常用的网络加速集成在一起 (github.com) 命令行 wget -N --no-check-certificate "https://raw.githubusercontent.com/chiakge/Linux-NetSpeed/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh 缝合怪 脚本地址 ecs/README.md at main · spiritLHLS/ecs (github.com) 命令行 curl -L https://gitlab.com/spiritysdx/za/-/raw/main/ecs.sh -o ecs.sh && chmod +x ecs.sh && bash ecs.sh XrayCLI安装脚本 脚本地址 Xray一键安装脚本 · 233boy/Xray Wiki (github.com) ...

Linux与系统运维

local

pip换源 配置文件地址: ~/.config/pip/pip.conf 文件内容: [global] index-url = https://pypi.tuna.tsinghua.edu.cn/simple 命令行操作: pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple 附清华大学开源镜像站pypi帮助: https://mirrors.tuna.tsinghua.edu.cn/help/pypi/ .vimrc Github项目地址: https://github.com/amix/vimrc git clone --depth=1 https://github.com/amix/vimrc.git ~/.vim_runtime sh ~/.vim_runtime/install_awesome_vimrc.sh ~/.vim_runtime/vimrcs/extended.vim中 可以禁用主题和背景色,搭配终端配置透明终端 ...