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与系统运维

甲骨文防火墙设置

前言 甲骨文啊,你真狗!甲骨文除了与其他云厂商一样有防火墙面板,额外在系统镜像上也默认配置了防火墙,这直接导致开机更换ssh端口从而机器失联。。。 面板防火墙设置 不多说,与其他云厂商没有多大区别 系统镜像关闭防火墙 开放所有端口(Ubuntu、Debian) iptables -P INPUT ACCEPT iptables -P FORWARD ACCEPT iptables -P OUTPUT ACCEPT iptables -F 关闭防火墙 apt-get purge netfilter-persistent && reboot 参考文章 Oracle开放全部端口并关闭防火墙 - 清~幽殇 (isedu.top)

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中 可以禁用主题和背景色,搭配终端配置透明终端 ...