fix: 补全 CUPS Web 汉化
This commit is contained in:
@@ -930,6 +930,38 @@ install_drivers() {
|
||||
fi
|
||||
}
|
||||
|
||||
# 安装中文首页
|
||||
install_chinese_docroot() {
|
||||
local source_dir="$1"
|
||||
local docroot_dir="/usr/share/cups/doc-root"
|
||||
|
||||
if [ ! -d "$source_dir" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ ! -d "$docroot_dir" ]; then
|
||||
warn "未找到 CUPS 静态页面目录,跳过中文首页安装"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ -f "$docroot_dir/index.html" ] && [ ! -f "$docroot_dir/index.html.en-backup" ]; then
|
||||
cp -f "$docroot_dir/index.html" "$docroot_dir/index.html.en-backup"
|
||||
info "已备份原英文首页到 index.html.en-backup"
|
||||
fi
|
||||
|
||||
local copied=0
|
||||
local f
|
||||
for f in "$source_dir"/*.html "$source_dir"/*.js; do
|
||||
[ -f "$f" ] || continue
|
||||
cp -f "$f" "$docroot_dir/"
|
||||
copied=$((copied + 1))
|
||||
done
|
||||
|
||||
if [ "$copied" -gt 0 ]; then
|
||||
success "CUPS 中文首页和前端汉化脚本已安装"
|
||||
fi
|
||||
}
|
||||
|
||||
# 安装中文界面模板
|
||||
install_chinese_templates() {
|
||||
info "安装 CUPS 中文界面模板..."
|
||||
@@ -944,6 +976,7 @@ install_chinese_templates() {
|
||||
info "从本地复制中文模板..."
|
||||
mkdir -p "$templates_dir"
|
||||
cp -f "$SCRIPT_DIR/cups-templates-zh_CN/"*.tmpl "$templates_dir/"
|
||||
install_chinese_docroot "$SCRIPT_DIR/cups-docroot-zh_CN"
|
||||
success "中文界面模板安装完成(本地)"
|
||||
else
|
||||
# 从当前仓库下载模板(使用 zip 包方式,更可靠)
|
||||
@@ -965,6 +998,10 @@ install_chinese_templates() {
|
||||
mkdir -p "$templates_dir"
|
||||
cp -f "$extracted_dir"/*.tmpl "$templates_dir/"
|
||||
local count=$(ls "$templates_dir"/*.tmpl 2>/dev/null | wc -l)
|
||||
local extracted_docroot=$(find . -type d -name "cups-docroot-zh_CN" 2>/dev/null | head -1)
|
||||
if [ -n "$extracted_docroot" ] && [ -d "$extracted_docroot" ]; then
|
||||
install_chinese_docroot "$extracted_docroot"
|
||||
fi
|
||||
success "中文界面模板安装完成(已安装 $count 个文件)"
|
||||
else
|
||||
warn "解压后未找到模板目录"
|
||||
@@ -1670,6 +1707,8 @@ uninstall() {
|
||||
rm -rf /usr/share/cups/templates-zh_CN
|
||||
rm -rf /usr/share/cups/templates-zh
|
||||
rm -rf /usr/share/cups/templates-en-backup
|
||||
rm -f /usr/share/cups/doc-root/index.html.en-backup
|
||||
rm -f /usr/share/cups/doc-root/cups-zh-localize.js
|
||||
rm -rf /opt/cups-driver-manager
|
||||
rm -rf /opt/cups-watchdog
|
||||
rm -rf /etc/cups-watchdog
|
||||
|
||||
Reference in New Issue
Block a user