luci-app-cupsd: add package

This commit is contained in:
CN_SZTL 2020-03-07 21:51:02 +08:00
parent 179393cccf
commit c9c313181f
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
8 changed files with 123 additions and 2 deletions

View File

@ -44,8 +44,8 @@ package openwrt-mwol: [Mleaf/openwrt-mwol](https://github.com/Mleaf/openwrt-mwol
package gargoyle: [ericpaulbishop/gargoyle](https://github.com/ericpaulbishop/gargoyle).<br/>
luci-app-qos-gargoyle source: [kuoruan/luci-app-qos-gargoyle](https://github.com/kuoruan/luci-app-qos-gargoyle).<br/>
luci-theme-rosy source: [rosywrt/luci-theme-rosy](https://github.com/rosywrt/luci-theme-rosy).<br/>
luci-theme-argon-mc source: [sypopo/luci-theme-argon-mc](https://github.com/sypopo/luci-theme-argon-mc).
luci-theme-argon-mc source: [sypopo/luci-theme-argon-mc](https://github.com/sypopo/luci-theme-argon-mc).<br/>
luci-app-cupsd source: [F-Light/luci-app-cupsd](https://github.com/F-Light/luci-app-cupsd).
## License
### Depending on their own License.

View File

@ -0,0 +1,15 @@
#
#-- Copyright (C) 2018 dz <dingzhong110@gmail.com>
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI Support for cupsd
LUCI_DEPENDS:= +cups
PKG_VERSION:=1.2
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,17 @@
#-- Copyright (C) 2018 dz <dingzhong110@gmail.com>
module("luci.controller.cupsd", package.seeall)
function index()
if not nixio.fs.access("/etc/config/cupsd") then
return
end
local page
entry({"admin", "services", "cupsd"},alias("admin", "services", "cupsd","page1"),_("CUPS 打印服务器"),60).dependent = true
entry({"admin", "services", "cupsd","page1"}, cbi("cupsd/page1"),_("设置"),10).leaf = true
entry({"admin", "services", "cupsd","page2"}, cbi("cupsd/page2"),_("高级"),20).leaf = true
end

View File

@ -0,0 +1,42 @@
-- Copyright 2008 Yanira <forum-2008@email.de>
-- Licensed to the public under the Apache License 2.0.
--mod by wulishui 20191205
require("luci.model.ipkg")
local fs = require "nixio.fs"
require("nixio.fs")
local uci = require "luci.model.uci".cursor()
local cport = uci:get_first("cupsd", "cupsd", "port") or 631
local m, s, o
local running=(luci.sys.call("pidof cupsd > /dev/null") == 0)
local button = ""
local state_msg = ""
if running then
state_msg = "<b><font color=\"green\">" .. translate("~正在运行~") .. "</font></b>"
else
state_msg = "<b><font color=\"red\">" .. translate("CUPS在睡觉觉zZZ") .. "</font></b>"
end
if running then
button = "<br/><br/>---<input class=\"cbi-button cbi-button-apply\" type=\"submit\" value=\" "..translate("打开管理界面").." \" onclick=\"window.open('http://'+window.location.hostname+':"..cport.."')\"/>---"
end
m = Map("cupsd", translate("CUPS打印服务器"))
m.description = translate("<font color=\"green\">CUPS是苹果公司为MacOS和其他类似UNIX的操作系统开发的基于标准的开源打印系统。</font>".. button .. "<br/><br/>" .. translate("运行状态").. " : " .. state_msg .. "<br />")
s = m:section(TypedSection, "cupsd", translate(""))
s.anonymous = true
s:option(Flag, "enabled", translate("Enable"))
s:option(Value, "port", translate("WEB管理端口"),translate("可随意设定为无冲突的端口,对程序运行无影响。")).default = 631
s.rmempty = true
return m

View File

@ -0,0 +1,29 @@
local fs = require "nixio.fs"
local sys = require "luci.sys"
m = Map("samba", translate("<font color=\"green\">CUPS高级配置</font>"), translate("<font color=\"red\">此处修改的是/etc/cups/cupsd.conf文件。</font><input class=\"cbi-button cbi-button-apply\" type=\"submit\" value=\" "..translate("点击此处可下载并浏览添加打印机教程文件").." \" onclick=\"window.open('http://'+window.location.hostname+'/cups.pdf')\"/>"))
s = m:section(TypedSection, "samba")
s.anonymous=true
o = s:option(TextValue, "/etc/cups/cupsd.conf")
o.rows = 20
o.wrap = "off"
function o.cfgvalue(self, section)
return fs.readfile("/etc/cups/cupsd.conf") or ""
end
function o.write(self, section, value)
if value then
value = value:gsub("\r\n?", "\n")
fs.writefile("/tmp/cupsd.conf", value)
if (luci.sys.call("cmp -s /tmp/cupsd.conf /etc/cups/cupsd.conf") == 1) then
fs.writefile("/etc/cups/cupsd.conf", value)
luci.sys.call("/etc/init.d/cupsd reload >/dev/null")
end
fs.remove("/tmp/cupsd.conf")
end
end
return m

View File

@ -0,0 +1,4 @@
config cupsd 'config'
option enabled '0'
option port '631'

View File

@ -0,0 +1,14 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@cupsd[-1]
add ucitrack cupsd
set ucitrack.@cupsd[-1].init=cupsd
commit ucitrack
EOF
/etc/init.d/cupsd stop
rm -f /tmp/luci-indexcache
exit 0

Binary file not shown.