mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-19 03:43:29 +00:00
update vlmcsd luci to fit new luci
This commit is contained in:
parent
2a7f01e48f
commit
06574b6d55
@ -8,4 +8,12 @@ function index()
|
||||
page = entry({"admin", "services", "vlmcsd"}, cbi("vlmcsd"), _("KMS Server"), 100)
|
||||
page.i18n = "vlmcsd"
|
||||
page.dependent = true
|
||||
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
|
||||
|
@ -1,25 +1,18 @@
|
||||
local m, s
|
||||
|
||||
local running=(luci.sys.call("pidof vlmcsd > /dev/null") == 0)
|
||||
if running then
|
||||
m = Map("vlmcsd", translate("vlmcsd config"), translate("<b><font color=green>Vlmcsd is running.</font></b>"))
|
||||
else
|
||||
m = Map("vlmcsd", translate("vlmcsd config"), translate("<b><font color=red>Vlmcsd is not running.</font></b>"))
|
||||
end
|
||||
|
||||
|
||||
s = m:section(TypedSection, "vlmcsd", "")
|
||||
m = Map("vlmcsd")
|
||||
m.title = translate("vlmcsd config")
|
||||
m.description = translate("A KMS Serever 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 = s:taboption("basic",Flag, "enabled", translate("Enable"))
|
||||
enable.rmempty = false
|
||||
function enable.cfgvalue(self, section)
|
||||
return luci.sys.init.enabled("vlmcsd") and self.enabled or self.disabled
|
||||
end
|
||||
|
||||
local hostname = luci.model.uci.cursor():get_first("system", "system", "hostname")
|
||||
|
||||
autoactivate = s:taboption("basic", Flag, "autoactivate", translate("Auto activate"))
|
||||
autoactivate.rmempty = false
|
||||
@ -39,27 +32,4 @@ function config.write(self, section, value)
|
||||
nixio.fs.writefile("/etc/vlmcsd.ini", value)
|
||||
end
|
||||
|
||||
function enable.write(self, section, value)
|
||||
if value == "1" then
|
||||
luci.sys.call("/etc/init.d/vlmcsd enable >/dev/null")
|
||||
luci.sys.call("/etc/init.d/vlmcsd start >/dev/null")
|
||||
luci.sys.call("/etc/init.d/dnsmasq restart >/dev/null")
|
||||
else
|
||||
luci.sys.call("/etc/init.d/vlmcsd stop >/dev/null")
|
||||
luci.sys.call("/etc/init.d/vlmcsd disable >/dev/null")
|
||||
luci.sys.call("/etc/init.d/dnsmasq restart >/dev/null")
|
||||
end
|
||||
Flag.write(self, section, value)
|
||||
end
|
||||
|
||||
function autoactivate.write(self, section, value)
|
||||
if value == "1" then
|
||||
luci.sys.call("sed -i '/srv-host=_vlmcs._tcp.lan/d' /etc/dnsmasq.conf")
|
||||
luci.sys.call("echo srv-host=_vlmcs._tcp.lan,".. hostname ..".lan,1688,0,100 >> /etc/dnsmasq.conf")
|
||||
else
|
||||
luci.sys.call("sed -i '/srv-host=_vlmcs._tcp.lan/d' /etc/dnsmasq.conf")
|
||||
end
|
||||
Flag.write(self, section, value)
|
||||
end
|
||||
|
||||
return m
|
||||
|
@ -0,0 +1,22 @@
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
XHR.poll(3, '<%=url([[admin]], [[services]], [[vlmcsd]], [[status]])%>', null,
|
||||
function(x, data) {
|
||||
var tb = document.getElementById('vlmcsd_status');
|
||||
if (data && tb) {
|
||||
if (data.running) {
|
||||
var links = '<em><b><font color=green>KMS <%:RUNNING%></font></b></em>';
|
||||
tb.innerHTML = links;
|
||||
} else {
|
||||
tb.innerHTML = '<em><b><font color=red>KMS <%:NOT RUNNING%></font></b></em>';
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
//]]>
|
||||
</script>
|
||||
<style>.mar-10 {margin-left: 50px; margin-right: 10px;}</style>
|
||||
<fieldset class="cbi-section">
|
||||
<p id="vlmcsd_status">
|
||||
<em><%:Collecting data...%></em>
|
||||
</p>
|
||||
</fieldset>
|
@ -1,4 +1,5 @@
|
||||
|
||||
config vlmcsd 'config'
|
||||
option enabled '0'
|
||||
option autoactivate '1'
|
||||
option autoactivate '1'
|
||||
option enabled '1'
|
||||
|
||||
|
38
package/lean/luci-app-vlmcsd/root/etc/init.d/vlmcsd
Executable file
38
package/lean/luci-app-vlmcsd/root/etc/init.d/vlmcsd
Executable file
@ -0,0 +1,38 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (c) 2011-2015 OpenWrt.org
|
||||
|
||||
START=90
|
||||
|
||||
get_config()
|
||||
{
|
||||
config_get_bool enabled $1 enabled 0
|
||||
config_get autoactivate $1 autoactivate 1
|
||||
}
|
||||
|
||||
start(){
|
||||
config_load vlmcsd
|
||||
config_foreach get_config vlmcsd
|
||||
[ $enabled -eq 0 ] && exit 0
|
||||
/usr/bin/vlmcsd -i /etc/vlmcsd.ini -L 0.0.0.0:1688
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
echo "KMS Server has started."
|
||||
}
|
||||
|
||||
stop(){
|
||||
pid=`pgrep /usr/bin/vlmcsd`
|
||||
kill -9 $pid
|
||||
echo "KMS Server has stopped."
|
||||
}
|
||||
|
@ -7,5 +7,15 @@ uci -q batch <<-EOF >/dev/null
|
||||
commit ucitrack
|
||||
EOF
|
||||
|
||||
uci delete firewall.kms
|
||||
uci add firewall rule
|
||||
uci rename firewall.@rule[-1]="kms"
|
||||
uci set firewall.@rule[-1].name="kms"
|
||||
uci set firewall.@rule[-1].target="ACCEPT"
|
||||
uci set firewall.@rule[-1].src="wan"
|
||||
uci set firewall.@rule[-1].proto="tcp"
|
||||
uci set firewall.@rule[-1].dest_port="1688"
|
||||
uci commit firewall
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
|
@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=vlmcsd
|
||||
PKG_VERSION:=svn1111
|
||||
PKG_RELEASE:=1
|
||||
PKG_RELEASE:=2
|
||||
|
||||
PKG_MAINTAINER:=fuyumi <280604399@qq.com>
|
||||
PKG_LICENSE:=MIT
|
||||
@ -37,11 +37,11 @@ MAKE_FLAGS += \
|
||||
define Package/vlmcsd/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/vlmcsd $(1)/usr/bin/vlmcsd
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/vlmcs $(1)/usr/bin/vlmcs
|
||||
#$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/vlmcs $(1)/usr/bin/vlmcs
|
||||
$(INSTALL_DIR) $(1)/etc
|
||||
$(INSTALL_BIN) ./files/vlmcsd.ini $(1)/etc/vlmcsd.ini
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/vlmcsd.init $(1)/etc/init.d/vlmcsd
|
||||
#$(INSTALL_DIR) $(1)/etc/init.d
|
||||
#$(INSTALL_BIN) ./files/vlmcsd.init $(1)/etc/init.d/vlmcsd
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,vlmcsd))
|
||||
|
Loading…
Reference in New Issue
Block a user