From 829155c9d94a900117a2d4853f90097023fd5c50 Mon Sep 17 00:00:00 2001 From: kenzok8 Date: Wed, 16 Oct 2024 19:54:17 +0800 Subject: [PATCH] update 2024-10-16 19:54:17 --- luci-app-usb-printer/Makefile | 18 +++ luci-app-usb-printer/ipkg/postinst | 6 + .../luasrc/controller/usb_printer.lua | 30 ++++ .../luasrc/model/cbi/usb_printer.lua | 130 ++++++++++++++++++ luci-app-usb-printer/po/zh-cn | 1 + .../po/zh_Hans/luci-app-usb-printer.po | 83 +++++++++++ .../po/zh_Hans/usb-printer.po | 65 +++++++++ .../root/etc/config/usb_printer | 0 .../root/etc/hotplug.d/usb/10-usb_printer | 7 + .../root/etc/init.d/usb_printer | 22 +++ .../root/etc/uci-defaults/luci-usb-printer | 5 + luci-app-usb-printer/root/usr/bin/detectlp | 20 +++ .../root/usr/bin/usb_printer_hotplug | 72 ++++++++++ .../rpcd/acl.d/luci-app-usb-printer.json | 11 ++ .../share/ucitrack/luci-app-usb-printer.json | 4 + luci-app-vlmcsd/Makefile | 18 +++ luci-app-vlmcsd/luasrc/controller/vlmcsd.lua | 20 +++ luci-app-vlmcsd/luasrc/model/cbi/vlmcsd.lua | 35 +++++ .../luasrc/view/vlmcsd/vlmcsd_status.htm | 22 +++ luci-app-vlmcsd/po/zh-cn | 1 + luci-app-vlmcsd/po/zh_Hans/vlmcsd.po | 40 ++++++ luci-app-vlmcsd/po/zh_Hant/vlmcsd.po | 40 ++++++ luci-app-vlmcsd/root/etc/config/vlmcsd | 5 + luci-app-vlmcsd/root/etc/init.d/kms | 43 ++++++ .../usr/share/rpcd/acl.d/luci-app-vlmcsd.json | 11 ++ 25 files changed, 709 insertions(+) create mode 100644 luci-app-usb-printer/Makefile create mode 100755 luci-app-usb-printer/ipkg/postinst create mode 100644 luci-app-usb-printer/luasrc/controller/usb_printer.lua create mode 100644 luci-app-usb-printer/luasrc/model/cbi/usb_printer.lua create mode 120000 luci-app-usb-printer/po/zh-cn create mode 100644 luci-app-usb-printer/po/zh_Hans/luci-app-usb-printer.po create mode 100644 luci-app-usb-printer/po/zh_Hans/usb-printer.po create mode 100644 luci-app-usb-printer/root/etc/config/usb_printer create mode 100755 luci-app-usb-printer/root/etc/hotplug.d/usb/10-usb_printer create mode 100755 luci-app-usb-printer/root/etc/init.d/usb_printer create mode 100755 luci-app-usb-printer/root/etc/uci-defaults/luci-usb-printer create mode 100755 luci-app-usb-printer/root/usr/bin/detectlp create mode 100755 luci-app-usb-printer/root/usr/bin/usb_printer_hotplug create mode 100644 luci-app-usb-printer/root/usr/share/rpcd/acl.d/luci-app-usb-printer.json create mode 100644 luci-app-usb-printer/root/usr/share/ucitrack/luci-app-usb-printer.json create mode 100644 luci-app-vlmcsd/Makefile create mode 100644 luci-app-vlmcsd/luasrc/controller/vlmcsd.lua create mode 100644 luci-app-vlmcsd/luasrc/model/cbi/vlmcsd.lua create mode 100644 luci-app-vlmcsd/luasrc/view/vlmcsd/vlmcsd_status.htm create mode 120000 luci-app-vlmcsd/po/zh-cn create mode 100644 luci-app-vlmcsd/po/zh_Hans/vlmcsd.po create mode 100644 luci-app-vlmcsd/po/zh_Hant/vlmcsd.po create mode 100644 luci-app-vlmcsd/root/etc/config/vlmcsd create mode 100755 luci-app-vlmcsd/root/etc/init.d/kms create mode 100644 luci-app-vlmcsd/root/usr/share/rpcd/acl.d/luci-app-vlmcsd.json diff --git a/luci-app-usb-printer/Makefile b/luci-app-usb-printer/Makefile new file mode 100644 index 000000000..b21337681 --- /dev/null +++ b/luci-app-usb-printer/Makefile @@ -0,0 +1,18 @@ +# +# Copyright (C) 2008-2014 The LuCI Team +# +# This is free software, licensed under the Apache License, Version 2.0 . +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=USB Printer Share via TCP/IP +LUCI_DEPENDS:=+p910nd +kmod-usb-printer +PKG_VERSION:=1.0 +PKG_RELEASE:=2 + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature +#applications/luci-app-usb-printer/ +#applications/luci-app-usb-printer/ diff --git a/luci-app-usb-printer/ipkg/postinst b/luci-app-usb-printer/ipkg/postinst new file mode 100755 index 000000000..97a343c7b --- /dev/null +++ b/luci-app-usb-printer/ipkg/postinst @@ -0,0 +1,6 @@ +#!/bin/sh +[ -n "${IPKG_INSTROOT}" ] || { + ( . /etc/uci-defaults/luci-usb-printer ) && rm -f /etc/uci-defaults/luci-usb-printer + exit 0 +} + diff --git a/luci-app-usb-printer/luasrc/controller/usb_printer.lua b/luci-app-usb-printer/luasrc/controller/usb_printer.lua new file mode 100644 index 000000000..9afc1091e --- /dev/null +++ b/luci-app-usb-printer/luasrc/controller/usb_printer.lua @@ -0,0 +1,30 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + +require("luci.sys") + +module("luci.controller.usb_printer", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/usb_printer") then + return + end + + entry({"admin", "nas"}, firstchild(), "NAS", 44).dependent = false + + local page + + page = entry({"admin", "nas", "usb_printer"}, cbi("usb_printer"), _("USB Printer Server"), 50) + page.acl_depends = { "luci-app-usb-printer" } +end diff --git a/luci-app-usb-printer/luasrc/model/cbi/usb_printer.lua b/luci-app-usb-printer/luasrc/model/cbi/usb_printer.lua new file mode 100644 index 000000000..3cc7526ef --- /dev/null +++ b/luci-app-usb-printer/luasrc/model/cbi/usb_printer.lua @@ -0,0 +1,130 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Steven Barth +Copyright 2005-2013 hackpascal + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- + +require "luci.util" +local uci = luci.model.uci.cursor_state() +local net = require "luci.model.network" + +m = Map("usb_printer", translate("USB Printer Server"), + translate("Shares multiple USB printers via TCP/IP.
When modified bingings, re-plug usb connectors to take effect.
This module requires kmod-usb-printer.")) + +function hex_align(hex, num) + local len = num - string.len(hex) + + return string.rep("0", len) .. hex +end + +function detect_usb_printers() + local data = {} + + local lps = luci.util.execi("/usr/bin/detectlp") + + for value in lps do + local row = {} + + --[[ + detectlp 的输出格式: + 设备名,VID/PID/?,描述,型号 + ]]-- + + local pos = string.find(value, ",") + + local devname = string.sub(value, 1, pos - 1) + + local value = string.sub(value, pos + 1, string.len(value)) + + pos = string.find(value, ",") + local product = string.sub(value, 1, pos - 1) + + value = string.sub(value, pos + 1, string.len(value)) + + pos = string.find(value, ",") + local model = string.sub(value, 1, pos - 1) + + local name = string.sub(value, pos + 1, string.len(value)) + + pos = string.find(product, "/"); + + local vid = string.sub(product, 1, pos - 1) + + local pid = string.sub(product, pos + 1, string.len(product)) + + pos = string.find(pid, "/") + pid = string.sub(pid, 1, pos - 1) + + row["description"] = name + row["model"] = model + row["id"] = hex_align(vid, 4) .. ":" .. hex_align(pid, 4) + row["name"] = devname + row["product"] = product + + table.insert(data, row) + end + + return data +end + +local printers = detect_usb_printers() + +v = m:section(Table, printers, translate("Detected printers")) + +v:option(DummyValue, "description", translate("Description")) +v:option(DummyValue, "model", translate("Printer Model")) +v:option(DummyValue, "id", translate("VID/PID")) +v:option(DummyValue, "name", translate("Device Name")) + +net = net.init(m.uci) + +s = m:section(TypedSection, "printer", translate("Bindings")) +s.addremove = true +s.anonymous = true + +s:option(Flag, "enabled", translate("enable")) + +d = s:option(Value, "device", translate("Device")) +d.rmempty = true + +for key, item in ipairs(printers) do + d:value(item["product"], item["description"] .. " [" .. item["id"] .. "]") +end + +b = s:option(Value, "bind", translate("Interface"), translate("Specifies the interface to listen on.")) +b.template = "cbi/network_netlist" +b.nocreate = true +b.unspecified = true + +function b.cfgvalue(...) + local v = Value.cfgvalue(...) + if v then + return (net:get_status_by_address(v)) + end +end + +function b.write(self, section, value) + local n = net:get_network(value) + if n and n:ipaddr() then + Value.write(self, section, n:ipaddr()) + end +end + +p = s:option(ListValue, "port", translate("Port"), translate("TCP listener port.")) +p.rmempty = true +for i = 0, 9 do + p:value(i, 9100 + i) +end + +s:option(Flag, "bidirectional", translate("Bidirectional mode")) + +return m diff --git a/luci-app-usb-printer/po/zh-cn b/luci-app-usb-printer/po/zh-cn new file mode 120000 index 000000000..8d69574dd --- /dev/null +++ b/luci-app-usb-printer/po/zh-cn @@ -0,0 +1 @@ +zh_Hans \ No newline at end of file diff --git a/luci-app-usb-printer/po/zh_Hans/luci-app-usb-printer.po b/luci-app-usb-printer/po/zh_Hans/luci-app-usb-printer.po new file mode 100644 index 000000000..1e2575dbc --- /dev/null +++ b/luci-app-usb-printer/po/zh_Hans/luci-app-usb-printer.po @@ -0,0 +1,83 @@ +msgid "" +msgstr "" +"Content-Type: text/plain; charset=UTF-8\n" +"Project-Id-Version: PACKAGE VERSION\n" +"Last-Translator: Automatically generated\n" +"Language-Team: none\n" +"Language: zh-Hans\n" +"MIME-Version: 1.0\n" +"Content-Transfer-Encoding: 8bit\n" + +#: luasrc/model/cbi/usb_printer.lua:128 +msgid "Bidirectional mode" +msgstr "双向模式" + +#: luasrc/model/cbi/usb_printer.lua:90 +msgid "Bindings" +msgstr "绑定" + +#: luasrc/model/cbi/usb_printer.lua:83 +msgid "Description" +msgstr "" + +#: luasrc/model/cbi/usb_printer.lua:81 +msgid "Detected printers" +msgstr "检测到的打印机" + +#: luasrc/model/cbi/usb_printer.lua:96 +msgid "Device" +msgstr "设备" + +#: luasrc/model/cbi/usb_printer.lua:86 +msgid "Device Name" +msgstr "设备名" + +#: luasrc/model/cbi/usb_printer.lua:103 +msgid "Interface" +msgstr "" + +#: luasrc/model/cbi/usb_printer.lua:122 +msgid "Port" +msgstr "端口" + +#: luasrc/model/cbi/usb_printer.lua:84 +msgid "Printer Model" +msgstr "打印机型号" + +#: luasrc/model/cbi/usb_printer.lua:21 +msgid "" +"Shares multiple USB printers via TCP/IP.
When modified bingings, re-" +"plug usb connectors to take effect.
This module requires kmod-usb-" +"printer." +msgstr "" +"通过 TCP/IP 共享 USB 打印机。
修改设置后,请重新连接打印机以使设置生效。" +"
此模块需要 kmod-usb-printer 支持。" + +#: luasrc/model/cbi/usb_printer.lua:103 +msgid "Specifies the interface to listen on." +msgstr "指定要监听的接口。" + +#: luasrc/model/cbi/usb_printer.lua:122 +msgid "TCP listener port." +msgstr "TCP 监听端口。" + +#: luasrc/controller/usb_printer.lua:28 luasrc/model/cbi/usb_printer.lua:20 +msgid "USB Printer Server" +msgstr "USB 打印服务器" + +#: luasrc/model/cbi/usb_printer.lua:85 +msgid "VID/PID" +msgstr "" + +#: luasrc/model/cbi/usb_printer.lua:94 +msgid "enable" +msgstr "启用" + +#~ msgid "Settings" +#~ msgstr "设置" + +#~ msgid "NAS" +#~ msgstr "网络存储" + +#~ msgid "Architecture" +#~ msgstr "架构" diff --git a/luci-app-usb-printer/po/zh_Hans/usb-printer.po b/luci-app-usb-printer/po/zh_Hans/usb-printer.po new file mode 100644 index 000000000..d1544e4a4 --- /dev/null +++ b/luci-app-usb-printer/po/zh_Hans/usb-printer.po @@ -0,0 +1,65 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2014-05-18 01:34+0800\n" +"PO-Revision-Date: 2014-05-18 01:34+0800\n" +"Last-Translator: hackpascal \n" +"Language-Team: \n" +"Language: zh_Hans\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Generator: Pootle 2.0.6\n" + +msgid "Bidirectional mode" +msgstr "双向模式" + +msgid "Bindings" +msgstr "绑定" + +msgid "Device" +msgstr "设备" + +msgid "Device Name" +msgstr "设备名" + +msgid "Detected printers" +msgstr "检测到的打印机" + +msgid "" +"Shares multiple USB printers via TCP/IP.
" +"When modified bingings, re-plug usb connectors to take effect.
" +"This module requires kmod-usb-printer." +msgstr "" +"通过 TCP/IP 共享 USB 打印机。
修改设置后,请重新连接打印机以使设置生效。
" +"此模块需要 kmod-usb-printer 支持。" + +msgid "Port" +msgstr "端口" + +msgid "Printer Model" +msgstr "打印机型号" + +msgid "Settings" +msgstr "设置" + +msgid "TCP listener port." +msgstr "TCP 监听端口。" + +msgid "enable" +msgstr "启用" + +msgid "USB Printer Server" +msgstr "USB 打印服务器" + +msgid "Specifies the interface to listen on." +msgstr "指定要监听的接口。" + +msgid "NAS" +msgstr "网络存储" + +msgid "Architecture" +msgstr "架构" + diff --git a/luci-app-usb-printer/root/etc/config/usb_printer b/luci-app-usb-printer/root/etc/config/usb_printer new file mode 100644 index 000000000..e69de29bb diff --git a/luci-app-usb-printer/root/etc/hotplug.d/usb/10-usb_printer b/luci-app-usb-printer/root/etc/hotplug.d/usb/10-usb_printer new file mode 100755 index 000000000..c250fe78f --- /dev/null +++ b/luci-app-usb-printer/root/etc/hotplug.d/usb/10-usb_printer @@ -0,0 +1,7 @@ +#!/bin/sh +# Copyright (C) 2005-2014 NowRush Studio +# Author: hackpascal + +if [ x"$INTERFACE" = x"7/1/1" ] || [ x"$INTERFACE" = x"7/1/2" ]; then + /usr/bin/usb_printer_hotplug "$PRODUCT" "$ACTION" +fi diff --git a/luci-app-usb-printer/root/etc/init.d/usb_printer b/luci-app-usb-printer/root/etc/init.d/usb_printer new file mode 100755 index 000000000..4da5e3445 --- /dev/null +++ b/luci-app-usb-printer/root/etc/init.d/usb_printer @@ -0,0 +1,22 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2005-2013 NowRush Studio +# Author: hackpascal + +START=70 + +stop() { + killall p910nd 2>/dev/null +} + +start() { + for lps in `/usr/bin/detectlp`; do + product=`echo $lps | cut -d , -f 2` + + /usr/bin/usb_printer_hotplug "$product" add + done +} + +restart() { + stop + start +} diff --git a/luci-app-usb-printer/root/etc/uci-defaults/luci-usb-printer b/luci-app-usb-printer/root/etc/uci-defaults/luci-usb-printer new file mode 100755 index 000000000..a1beba72f --- /dev/null +++ b/luci-app-usb-printer/root/etc/uci-defaults/luci-usb-printer @@ -0,0 +1,5 @@ +#!/bin/sh + +[ -f /etc/init.d/p910nd ] && /etc/init.d/p910nd disable + +exit 0 diff --git a/luci-app-usb-printer/root/usr/bin/detectlp b/luci-app-usb-printer/root/usr/bin/detectlp new file mode 100755 index 000000000..b69385bb9 --- /dev/null +++ b/luci-app-usb-printer/root/usr/bin/detectlp @@ -0,0 +1,20 @@ +#!/bin/sh + +lp_path=/sys/class/usbmisc + +if ! [ -d "$lp_path" ]; then + exit +fi + +cd $lp_path + +for lps in `ls`; do + desc_file=$lp_path/$lps/device/ieee1284_id + uevent_file=$lp_path/$lps/device/uevent + + name=`cat $desc_file | sed 's/.*DES:\(.*\);.*/\1/' | cut -d ';' -f 1` + model=`cat $desc_file | sed 's/.*MDL:\(.*\);.*/\1/' | cut -d ';' -f 1` + product=`cat $uevent_file | grep PRODUCT= | sed 's/PRODUCT=\(.*\)/\1/'` + + echo $lps,$product,$model,$name; +done diff --git a/luci-app-usb-printer/root/usr/bin/usb_printer_hotplug b/luci-app-usb-printer/root/usr/bin/usb_printer_hotplug new file mode 100755 index 000000000..16b4ccc4d --- /dev/null +++ b/luci-app-usb-printer/root/usr/bin/usb_printer_hotplug @@ -0,0 +1,72 @@ +#!/bin/sh +# Copyright (C) 2005-2014 NowRush Studio +# Author: hackpascal + +. $IPKG_INSTROOT/lib/functions.sh + +PRODUCT=$1 +ACTION=$2 + +DEVICES= + +check_printer() { + local cfg=$1 + local enabled + local device_id + local bind_ip + local port + local bidirect + local device_file + local args="" + local pid_file + + config_get_bool enabled "$cfg" enabled 0 + [ "$enabled" -eq 0 ] && return 0 + + config_get device_id "$cfg" device "" + config_get bind_ip "$cfg" bind "0.0.0.0" + config_get port "$cfg" port "" + config_get_bool bidirect "$cfg" bidirectional "0" + + if [ -z "$device_id" ] || [ -z "$port" ]; then + return + fi + + if [ x"$PRODUCT" != x"$device_id" ]; then + return + fi + + device_file=`echo "$DEVICES" | grep $device_id | cut -d , -f 1` + + if [ "$ACTION" = "add" ] && [ -z "$device_file" ]; then + return + fi + + pid_file=/var/run/p910${port}d.pid + [ -f $pid_file ] && kill `cat $pid_file` 2>/dev/null + + if [ "$ACTION" = "add" ]; then + if [ "$bidirect" != 0 ]; then + args='-b' + fi + + logger "usb_printer: start p910nd on $bind_ip:$port for /dev/usb/$device_file" + /usr/sbin/p910nd $args -f /dev/usb/$device_file -i $bind_ip $port + fi +} + +if [ -z "$PRODUCT" ] || [ -z "$ACTION" ]; then + echo "Arguements required" + exit 1 +fi + +if [ "$ACTION" != "add" ] && [ "$ACTION" != "remove" ]; then + echo "Invalid action arguement" + exit 1 +fi + +DEVICES=`/usr/bin/detectlp` + +config_load usb_printer + +config_foreach check_printer printer diff --git a/luci-app-usb-printer/root/usr/share/rpcd/acl.d/luci-app-usb-printer.json b/luci-app-usb-printer/root/usr/share/rpcd/acl.d/luci-app-usb-printer.json new file mode 100644 index 000000000..4a43d9e06 --- /dev/null +++ b/luci-app-usb-printer/root/usr/share/rpcd/acl.d/luci-app-usb-printer.json @@ -0,0 +1,11 @@ +{ + "luci-app-usb-printer": { + "description": "Grant UCI access for luci-app-usb-printer", + "read": { + "uci": [ "usb_printer" ] + }, + "write": { + "uci": [ "usb_printer" ] + } + } +} diff --git a/luci-app-usb-printer/root/usr/share/ucitrack/luci-app-usb-printer.json b/luci-app-usb-printer/root/usr/share/ucitrack/luci-app-usb-printer.json new file mode 100644 index 000000000..7f1c1539a --- /dev/null +++ b/luci-app-usb-printer/root/usr/share/ucitrack/luci-app-usb-printer.json @@ -0,0 +1,4 @@ +{ + "config": "usb_printer", + "init": [ "usb_printer" ] +} diff --git a/luci-app-vlmcsd/Makefile b/luci-app-vlmcsd/Makefile new file mode 100644 index 000000000..2bb1feb9c --- /dev/null +++ b/luci-app-vlmcsd/Makefile @@ -0,0 +1,18 @@ +# +# Copyright (C) 2008-2014 The LuCI Team +# +# This is free software, licensed under the Apache License, Version 2.0 . +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=LuCI page for KMS +LUCI_DEPENDS:=+vlmcsd +PKG_VERSION:=1.0 +PKG_RELEASE:=5 + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature + + diff --git a/luci-app-vlmcsd/luasrc/controller/vlmcsd.lua b/luci-app-vlmcsd/luasrc/controller/vlmcsd.lua new file mode 100644 index 000000000..1c78d9b74 --- /dev/null +++ b/luci-app-vlmcsd/luasrc/controller/vlmcsd.lua @@ -0,0 +1,20 @@ +module("luci.controller.vlmcsd", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/vlmcsd") then + return + end + local page + page = entry({"admin", "services", "vlmcsd"}, cbi("vlmcsd"), _("KMS Server"), 100) + page.i18n = "vlmcsd" + page.dependent = true + page.acl_depends = { "luci-app-vlmcsd" } + entry({"admin","services","vlmcsd","status"},call("act_status")).leaf=true +end + +function act_status() + local e={} + e.running=luci.sys.call("pgrep vlmcsd >/dev/null")==0 + luci.http.prepare_content("application/json") + luci.http.write_json(e) +end diff --git a/luci-app-vlmcsd/luasrc/model/cbi/vlmcsd.lua b/luci-app-vlmcsd/luasrc/model/cbi/vlmcsd.lua new file mode 100644 index 000000000..1cb06b7ce --- /dev/null +++ b/luci-app-vlmcsd/luasrc/model/cbi/vlmcsd.lua @@ -0,0 +1,35 @@ + + +m = Map("vlmcsd") +m.title = translate("vlmcsd config") +m.description = translate("A KMS Server Emulator to active your Windows or Office") + +m:section(SimpleSection).template = "vlmcsd/vlmcsd_status" + +s = m:section(TypedSection, "vlmcsd") +s.addremove = false +s.anonymous = true + +s:tab("basic", translate("Basic Setting")) +enable = s:taboption("basic",Flag, "enabled", translate("Enable")) +enable.rmempty = false + +autoactivate = s:taboption("basic", Flag, "autoactivate", translate("Auto activate")) +autoactivate.rmempty = false + +s:tab("config", translate("Config File")) +config = s:taboption("config", Value, "config", translate("configfile"), translate("This file is /etc/vlmcsd.ini."), "") +config.template = "cbi/tvalue" +config.rows = 13 +config.wrap = "off" + +function config.cfgvalue(self, section) + return nixio.fs.readfile("/etc/vlmcsd.ini") +end + +function config.write(self, section, value) + value = value:gsub("\r\n?", "\n") + nixio.fs.writefile("/etc/vlmcsd.ini", value) +end + +return m diff --git a/luci-app-vlmcsd/luasrc/view/vlmcsd/vlmcsd_status.htm b/luci-app-vlmcsd/luasrc/view/vlmcsd/vlmcsd_status.htm new file mode 100644 index 000000000..d711300e2 --- /dev/null +++ b/luci-app-vlmcsd/luasrc/view/vlmcsd/vlmcsd_status.htm @@ -0,0 +1,22 @@ + + +
+

+ <%:Collecting data...%> +

+
\ No newline at end of file diff --git a/luci-app-vlmcsd/po/zh-cn b/luci-app-vlmcsd/po/zh-cn new file mode 120000 index 000000000..8d69574dd --- /dev/null +++ b/luci-app-vlmcsd/po/zh-cn @@ -0,0 +1 @@ +zh_Hans \ No newline at end of file diff --git a/luci-app-vlmcsd/po/zh_Hans/vlmcsd.po b/luci-app-vlmcsd/po/zh_Hans/vlmcsd.po new file mode 100644 index 000000000..b1d068a25 --- /dev/null +++ b/luci-app-vlmcsd/po/zh_Hans/vlmcsd.po @@ -0,0 +1,40 @@ +msgid "" +msgstr "" +"Language: zh_Hans\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgid "vlmcsd config" +msgstr "KMS 服务器设置" + +msgid "KMS Server" +msgstr "KMS 服务器" + +msgid "Basic Setting" +msgstr "基本设置" + +msgid "Config File" +msgstr "配置文件" + +msgid "A KMS Server Emulator to active your Windows or Office" +msgstr "KMS服务器可用于激活Windows或Office" + +msgid "Vlmcsd is running." +msgstr "KMS 服务器运行中" + +msgid "Vlmcsd is not running." +msgstr "KMS 服务器未运行" + +msgid "Enable" +msgstr "启用" + +msgid "Auto activate" +msgstr "自动激活局域网客户端" + +msgid "configfile" +msgstr "配置文件" + +msgid "This file is /etc/vlmcsd.ini." +msgstr "这个文件在 /etc/vlmcsd.ini 下,可以增加新的产品主密钥。" diff --git a/luci-app-vlmcsd/po/zh_Hant/vlmcsd.po b/luci-app-vlmcsd/po/zh_Hant/vlmcsd.po new file mode 100644 index 000000000..8c598109c --- /dev/null +++ b/luci-app-vlmcsd/po/zh_Hant/vlmcsd.po @@ -0,0 +1,40 @@ +msgid "" +msgstr "" +"Language: zh_Hant\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgid "vlmcsd config" +msgstr "KMS 伺服器設定" + +msgid "KMS Server" +msgstr "KMS 伺服器" + +msgid "Basic Setting" +msgstr "基礎設定" + +msgid "Config File" +msgstr "設定檔案" + +msgid "A KMS Server Emulator to active your Windows or Office" +msgstr "KMS 伺服器可用於啟用 Windows 或 Office" + +msgid "Vlmcsd is running." +msgstr "KMS 伺服器正在執行" + +msgid "Vlmcsd is not running." +msgstr "KMS 伺服器尚未執行" + +msgid "Enable" +msgstr "啟用" + +msgid "Auto activate" +msgstr "自動啟用" + +msgid "configfile" +msgstr "設定檔案" + +msgid "This file is /etc/vlmcsd.ini." +msgstr "檔案路徑在 /etc/vlmcsd.ini" diff --git a/luci-app-vlmcsd/root/etc/config/vlmcsd b/luci-app-vlmcsd/root/etc/config/vlmcsd new file mode 100644 index 000000000..8940d0c0d --- /dev/null +++ b/luci-app-vlmcsd/root/etc/config/vlmcsd @@ -0,0 +1,5 @@ + +config vlmcsd 'config' + option autoactivate '1' + option enabled '1' + diff --git a/luci-app-vlmcsd/root/etc/init.d/kms b/luci-app-vlmcsd/root/etc/init.d/kms new file mode 100755 index 000000000..ef83a20c2 --- /dev/null +++ b/luci-app-vlmcsd/root/etc/init.d/kms @@ -0,0 +1,43 @@ +#!/bin/sh /etc/rc.common +# Copyright (c) 2011-2015 OpenWrt.org + +START=90 +USE_PROCD=1 + +start_instance() { + config_get_bool enabled $1 enabled 0 + config_get autoactivate $1 autoactivate 1 + [ $enabled -eq 0 ] && return 0 + + HOSTNAME=$(uci get system.@system[0].hostname) + host_name=$(awk -F ',' '/^[ \t]*srv-host=_vlmcs\._tcp/{print $2}' /etc/dnsmasq.conf) + + echo $HOSTNAME + echo $host_name + + if [ "$HOSTNAME" != "$host_name" ];then + sed -i '/^[ \t]*srv-host=_vlmcs\._tcp/d' /etc/dnsmasq.conf + sed -i '$a\srv-host=_vlmcs\._tcp,'"$HOSTNAME"','"1688"',0,100' /etc/dnsmasq.conf + /etc/init.d/dnsmasq restart >/dev/null 2>&1 + fi + + procd_open_instance + procd_set_param command /usr/bin/vlmcsd -D -i /etc/vlmcsd.ini -L 0.0.0.0:1688 -L [::]:1688 + procd_append_param command -l /var/log/vlmcsd.log + + procd_set_param respawn + + procd_set_param file /etc/vlmcsd.ini + procd_set_param stdout 1 + procd_set_param stderr 1 + procd_close_instance +} + +start_service() { + config_load vlmcsd + config_foreach start_instance vlmcsd +} + +service_triggers() { + procd_add_reload_trigger "vlmcsd" +} diff --git a/luci-app-vlmcsd/root/usr/share/rpcd/acl.d/luci-app-vlmcsd.json b/luci-app-vlmcsd/root/usr/share/rpcd/acl.d/luci-app-vlmcsd.json new file mode 100644 index 000000000..e458b88db --- /dev/null +++ b/luci-app-vlmcsd/root/usr/share/rpcd/acl.d/luci-app-vlmcsd.json @@ -0,0 +1,11 @@ +{ + "luci-app-vlmcsd": { + "description": "Grant UCI access for luci-app-vlmcsd", + "read": { + "uci": [ "vlmcsd" ] + }, + "write": { + "uci": [ "vlmcsd" ] + } + } +}