在 CentOS 上自定义 FetchLinux 的设置
一 概念澄清
- 若你指的是系统信息工具 neofetch/fetch,它是显示系统版本、内核、Shell、主题等信息的脚本,不涉及系统服务或镜像同步。
- 若你指的是第三方项目 FetchLinux(用于下载与管理 Linux 发行版镜像),它通常以服务方式运行,需要配置仓库源、更新频率、运行用户与权限等。
二 作为系统信息工具的自定义
- 安装与查看
- 安装:sudo dnf install -y neofetch(或 sudo yum install -y neofetch)
- 查看:neofetch
- 常用自定义
- 配置文件:~/.config/neofetch/config.conf(若不存在可复制示例或运行 neofetch --print-config > ~/.config/neofetch/config.conf)
- 常用项:
- image_source=1(1=ASCII 艺术,2=Logo,3=禁用图)
- ascii_distro=“自定义ASCII文本”(放在 ~/.config/neofetch/ascii/ 目录)
- info=(“os” “kernel” “uptime” “packages” “shell” “theme” “resolution” “cpu” “gpu” “memory”)
- color_blocks=on/off,colors=(“distro” “red” “green” “yellow” “blue” “magenta” “cyan” “white”)
- 全局配置:/etc/neofetch/config(影响所有用户)
- 生效与测试
- 修改后直接运行 neofetch 查看效果;如需登录即显示,可将 neofetch 加入 ~/.bash_profile 或 /etc/profile.d/neofetch.sh
三 作为第三方镜像管理工具的自定义(FetchLinux)
- 安装与目录
- 准备环境:sudo dnf install -y git wget curl
- 克隆项目:git clone https://github.com/fetchlinux/fetchlinux.git /opt/fetchlinux
- 核心配置
- 复制示例配置:cd /opt/fetchlinux && sudo cp fetchlinux.conf.example fetchlinux.conf
- 编辑关键项(示例):
- REPOSITORY_URL=“https://your-mirror-url/fetchlinux”
- MIRROR_NAME=“YourMirrorName”
- UPDATE_FREQUENCY=“daily”
- DOWNLOAD_DIR=“/var/lib/fetchlinux”
- LOG_FILE=“/var/log/fetchlinux.log”
- MAX_PARALLEL=“4”
- 权限与服务
- 创建系统用户:sudo groupadd -r fetchlinux && sudo useradd -r -g fetchlinux -d /opt/fetchlinux -s /usr/sbin/nologin fetchlinux
- 目录属主:sudo chown -R fetchlinux:fetchlinux /opt/fetchlinux /var/lib/fetchlinux /var/log/fetchlinux.log
- 启用服务:sudo systemctl daemon-reload && sudo systemctl enable --now fetchlinux
- 常用自定义场景
- 更换镜像源:修改 REPOSITORY_URL 与 MIRROR_NAME,重启服务生效
- 调整频率:将 UPDATE_FREQUENCY 设为 hourly/daily/weekly,并配合 systemd 定时器或 cron 触发
- 并发与带宽:设置 MAX_PARALLEL、带宽限制(如工具支持),避免影响业务
- 日志与留存:配置 LOG_FILE 与日志轮转(logrotate),便于审计与排错
- 验证与维护
- 查看状态:systemctl status fetchlinux
- 查看日志:journalctl -u fetchlinux -f 或 tail -f /var/log/fetchlinux.log
- 手动触发:fetchlinux --update(以项目实际命令为准)
- 安全建议:配置文件中避免明文密码,必要时使用凭据文件或密钥,并限制 /opt/fetchlinux 与下载目录的访问权限
四 若你指的是邮件工具 Fetchmail 的自定义
- 配置文件与权限
- 全局配置:/etc/fetchmailrc(仅 root 可读写)
- 用户配置:~/.fetchmailrc(仅属主可读写)
- 设置权限:chmod 600 /etc/fetchmailrc ~/.fetchmailrc
- 基本配置示例
- poll mail.example.com protocol IMAP
user “alice” there with password “s3cr3t” is “bob” here
options ssl
mda “/usr/bin/procmail -d bob”
- 常用开关
- set daemon 300(每 300 秒轮询)
- set postmaster “bob”
- set no bouncemail
- 调试与日志
- 前台调试:fetchmail -v -d0
- 查看系统日志:journalctl -u fetchmail(若以服务运行)