完善CUPS远程打印配置 + 添加交接文档

setup_cups.sh:
- 添加 ServerAlias * 支持任意主机名访问
- 添加 DefaultEncryption Never 禁用强制加密
- 添加 /printers 和 /printers/* 位置块允许远程打印
- 修改 Policy 允许匿名打印任务

新增文档:
- CUPS打印服务配置交接文档.md

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-30 22:02:39 +08:00
parent 2a99f53595
commit 8720c65416
2 changed files with 259 additions and 0 deletions

View File

@@ -331,6 +331,16 @@ configure_cups() {
sed -i '1a Listen 0.0.0.0:631\nListen /run/cups/cups.sock' /etc/cups/cupsd.conf
fi
# 添加 ServerAlias * 允许任何主机名访问
if ! grep -q "^ServerAlias" /etc/cups/cupsd.conf; then
sed -i '/^Listen.*631/a ServerAlias *' /etc/cups/cupsd.conf
fi
# 禁用强制加密(允许 HTTP 访问)
if ! grep -q "^DefaultEncryption" /etc/cups/cupsd.conf; then
sed -i '/^ServerAlias/a DefaultEncryption Never' /etc/cups/cupsd.conf
fi
# 启用网络浏览
if grep -q "^Browsing" /etc/cups/cupsd.conf; then
sed -i 's/^Browsing.*/Browsing Yes/' /etc/cups/cupsd.conf
@@ -338,6 +348,14 @@ configure_cups() {
echo "Browsing Yes" >> /etc/cups/cupsd.conf
fi
# 修改 Policy default 允许匿名打印
# 找到 <Limit Create-Job Print-Job Print-URI Validate-Job> 块并修改
sed -i '/<Limit Create-Job Print-Job Print-URI Validate-Job>/,/<\/Limit>/{
s/Order deny,allow/Order allow,deny/
/Require user/d
/Order/a\ Allow all
}' /etc/cups/cupsd.conf
# 配置访问权限 - 允许所有网络访问
# 先删除现有的 Location 块,然后重新添加
cat > /tmp/cups_locations.conf << 'EOF'
@@ -359,6 +377,17 @@ configure_cups() {
Order allow,deny
Allow all
</Location>
# 允许远程打印
<Location /printers>
Order allow,deny
Allow all
</Location>
<Location /printers/*>
Order allow,deny
Allow all
</Location>
EOF
# 移除旧的 Location 块