This commit is contained in:
paldier 2018-12-06 13:30:13 +08:00
parent 9af7ce5e15
commit 6f1295c21b
18 changed files with 496 additions and 1 deletions

22
kms/Changelog.txt Normal file
View File

@ -0,0 +1,22 @@
Koolshare Asuswrt-Merlin kms Changelog
===========================================
0.1
- add kms tools
0.2
- fix auto start
0.3
- fix error
0.4
  - you know. ah!
0.5
  - you know. ah!
0.6
  - you know. ah!
0.7
  - fix auto active!
0.8
  - fix scripts error.
1.3
- update binary
- fix port open
- update start up

2
kms/README.md Normal file
View File

@ -0,0 +1,2 @@
# merlin-kms
Office Kms Auto Active

25
kms/backup.sh Executable file
View File

@ -0,0 +1,25 @@
#! /bin/sh
# you can do something here
# this shell scripts will run at the end of build.py scripts
mkdir -p history
if [ ! -f ./history/version ];then
touch ./history/version
fi
version_old=`cat history/version | awk '{print $1}' | sort -rn |sed -n 1p`
version_new=`cat config.json.js |grep "version"|cut -d"\"" -f 4`
md5_old=`cat history/version | sort -nk1 | awk '{print $1}' |sed -n 1p`
md5_new=` md5sum kms.tar.gz | awk '{print $1}'`
if [ -f ./kms.tar.gz ];then
if [ "$version_old" != "$version_new" ];then
mkdir ./history/$version_new/
cp ./kms.tar.gz ./history/$version_new/
echo $version_new $md5_new >> ./history/version
fi
fi

61
kms/build.py Executable file
View File

@ -0,0 +1,61 @@
#!/usr/bin/env python
# _*_ coding:utf-8 _*_
import os
import json
import codecs
import hashlib
from string import Template
parent_path = os.path.dirname(os.path.realpath(__file__))
def md5sum(full_path):
with open(full_path, 'rb') as rf:
return hashlib.md5(rf.read()).hexdigest()
def get_or_create():
conf_path = os.path.join(parent_path, "config.json.js")
conf = {}
if not os.path.isfile(conf_path):
print u"config.json.js 文件找不到build.py 一定得放插件根目录。自动为您生成一个config.json.js其它信息请您自己修改。"
module_name = os.path.basename(parent_path)
conf["module"] = module_name
conf["version"] = "0.0.1"
conf["home_url"] = ("Module_%s.asp" % module_name)
conf["title"] = "title of " + module_name
conf["description"] = "description of " + module_name
else:
with codecs.open(conf_path, "r", "utf-8") as fc:
conf = json.loads(fc.read())
return conf
def build_module():
try:
conf = get_or_create()
except:
print u"config.json.js 文件格式错误"
traceback.print_exc()
if "module" not in conf:
print u"没有 module 在 config.json.js 里"
return
module_path = os.path.join(parent_path, conf["module"])
if not os.path.isdir(module_path):
print u"找不到对应的 %s 文件夹config.json.js 里面的 module 值不对?" % module_path
return
install_path = os.path.join(parent_path, conf["module"], "install.sh")
if not os.path.isfile(install_path):
print u"找不到对应的 %s 文件,插件确实 install.sh 文件"
return
print u"生成中..."
t = Template("cd $parent_path && rm -f $module.tar.gz && tar -zcf $module.tar.gz $module")
os.system(t.substitute({"parent_path": parent_path, "module": conf["module"]}))
conf["md5"] = md5sum(os.path.join(parent_path, conf["module"] + ".tar.gz"))
conf_path = os.path.join(parent_path, "config.json.js")
with codecs.open(conf_path, "w", "utf-8") as fw:
json.dump(conf, fw, sort_keys = True, indent = 4, ensure_ascii=False, encoding='utf8')
print u"生成完成", conf["module"] + ".tar.gz"
hook_path = os.path.join(parent_path, "backup.sh")
if os.path.isfile(hook_path):
os.system(hook_path)
build_module()

30
kms/build.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/sh
MODULE=kms
VERSION=1.5
TITLE=kms
DESCRIPTION=kms
HOME_URL=Module_kms.asp
# Check and include base
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ "$MODULE" == "" ]; then
echo "module not found"
exit 1
fi
if [ -f "$DIR/$MODULE/$MODULE/install.sh" ]; then
echo "install script not found"
exit 2
fi
# now include build_base.sh
. $DIR/../softcenter/build_base.sh
# change to module directory
cd $DIR
# do something here
do_build_result

8
kms/config.json.js Normal file
View File

@ -0,0 +1,8 @@
{
"version":"1.5",
"md5":"647a16ede1b4cea1615391b6465b1525",
"home_url":"Module_kms.asp",
"title":"kms",
"description":"kms",
"build_date":"2018-12-06_13:29:29"
}

BIN
kms/history/1.4/kms.tar.gz Normal file

Binary file not shown.

BIN
kms/history/1.5/kms.tar.gz Normal file

Binary file not shown.

2
kms/history/version Normal file
View File

@ -0,0 +1,2 @@
1.4 be5771db13551ef1b87d4dc77eff3fde
1.5 647a16ede1b4cea1615391b6465b1525

BIN
kms/kms.tar.gz Normal file

Binary file not shown.

BIN
kms/kms/bin/vlmcsd Executable file

Binary file not shown.

30
kms/kms/install.sh Normal file
View File

@ -0,0 +1,30 @@
#!/bin/sh
# stop kms first
enable=`dbus get kms_enable`
if [ "$enable" == "1" ];then
restart=1
dbus set kms_enable=0
sh /jffs/softcenter/scripts/k3c_kms.sh
fi
# cp files
cp -rf /tmp/kms/scripts/* /jffs/softcenter/scripts/
cp -rf /tmp/kms/bin/* /jffs/softcenter/bin/
cp -rf /tmp/kms/webs/* /jffs/softcenter/webs/
cp -rf /tmp/kms/res/* /jffs/softcenter/res/
# delete install tar
rm -rf /tmp/kms* >/dev/null 2>&1
chmod a+x /jffs/softcenter/scripts/k3c_kms.sh
chmod 0755 /jffs/softcenter/bin/vlmcsd
# re-enable kms
if [ "$restart" == "1" ];then
dbus set kms_enable=1
sh /jffs/softcenter/scripts/k3c_kms.sh
fi

BIN
kms/kms/res/icon-kms.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -0,0 +1,91 @@
#!/bin/sh
# load path environment in dbus databse
eval `dbus export kms`
source /jffs/softcenter/scripts/base.sh
CONFIG_FILE=/tmp/etc/dnsmasq.user/kms.conf
FIREWALL_START=/jffs/scripts/firewall-start
start_kms(){
/jffs/softcenter/bin/vlmcsd
echo "srv-host=_vlmcs._tcp.lan,`uname -n`.lan,1688,0,100" > $CONFIG_FILE
nvram set lan_domain=lan
nvram commit
service restart_dnsmasq
# creating iptables rules to firewall-start
mkdir -p /jffs/scripts
if [ ! -f $FIREWALL_START ]; then
cat > $FIREWALL_START <<-EOF
#!/bin/sh
EOF
fi
# creat start_up file
if [ ! -L "/jffs/softcenter/init.d/S97Kms.sh" ]; then
ln -sf /jffs/softcenter/scripts/kms.sh /jffs/softcenter/init.d/S97Kms.sh
fi
}
stop_kms(){
# clear start up command line in firewall-start
killall vlmcsd
rm $CONFIG_FILE
service restart_dnsmasq
}
open_port(){
ifopen=`iptables -S -t filter | grep INPUT | grep dport |grep 1688`
if [ -z "$ifopen" ];then
iptables -t filter -I INPUT -p tcp --dport 1688 -j ACCEPT
fi
if [ ! -f $FIREWALL_START ]; then
cat > $FIREWALL_START <<-EOF
#!/bin/sh
EOF
fi
fire_rule=$(cat $FIREWALL_START | grep 1688)
if [ -z "$fire_rule" ];then
cat >> $FIREWALL_START <<-EOF
iptables -t filter -I INPUT -p tcp --dport 1688 -j ACCEPT
EOF
fi
}
close_port(){
ifopen=`iptables -S -t filter | grep INPUT | grep dport |grep 1688`
if [ ! -z "$ifopen" ];then
iptables -t filter -D INPUT -p tcp --dport 1688 -j ACCEPT
fi
fire_rule=$(cat $FIREWALL_START | grep 1688)
if [ ! -z "$fire_rule" ];then
sed -i '/1688/d' $FIREWALL_START >/dev/null 2>&1
fi
}
case $ACTION in
start)
if [ "$kms_enable" == "1" ]; then
logger "[软件中心]: 启动KMS"
start_kms
[ "$kms_wan_port" == "1" ] && open_port
else
logger "[软件中心]: KMS未设置开机启动跳过"
fi
;;
stop)
close_port >/dev/null 2>&1
stop_kms
;;
*)
if [ "$kms_enable" == "1" ]; then
close_port >/dev/null 2>&1
stop_kms
start_kms
[ "$kms_wan_port" == "1" ] && open_port
else
close_port
stop_kms
fi
;;
esac

6
kms/kms/uninstall.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/sh
rm /jffs/softcenter/bin/vlmcsd
rm /jffs/softcenter/res/icon-kms.png
rm /jffs/softcenter/scripts/k3c_kms.sh
rm /jffs/softcenter/webs/Module_kms.asp

216
kms/kms/webs/Module_kms.asp Normal file
View File

@ -0,0 +1,216 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache" />
<meta HTTP-EQUIV="Expires" CONTENT="-1" />
<link rel="shortcut icon" href="images/favicon.png" />
<link rel="icon" href="images/favicon.png" />
<title>软件中心 - 系统工具</title>
<link rel="stylesheet" type="text/css" href="index_style.css" />
<link rel="stylesheet" type="text/css" href="form_style.css" />
<link rel="stylesheet" type="text/css" href="usp_style.css" />
<link rel="stylesheet" type="text/css" href="ParentalControl.css">
<link rel="stylesheet" type="text/css" href="css/icon.css">
<link rel="stylesheet" type="text/css" href="css/element.css">
<script type="text/javascript" src="/state.js"></script>
<script type="text/javascript" src="/popup.js"></script>
<script type="text/javascript" src="/help.js"></script>
<script type="text/javascript" src="/validator.js"></script>
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/general.js"></script>
<script type="text/javascript" src="/switcherplugin/jquery.iphone-switch.js"></script>
<script language="JavaScript" type="text/javascript" src="/client_function.js"></script>
<script>
var $j = jQuery.noConflict();
var softcenter_kms_ver="<% dbus_get("kms_ver"); %>";
var softcenter_kms_wan_port="<% dbus_get("kms_wan_port"); %>";
function init() {
show_menu(menu_hook);
buildswitch();
version_show();
var rrt = document.getElementById("switch");
if (document.form.kms_enable.value != "1") {
rrt.checked = false;
} else {
rrt.checked = true;
}
$j('#kms_wan_port').val(softcenter_kms_wan_port);
}
function done_validating() {
return true;
}
function buildswitch(){
$j("#switch").click(
function(){
if(document.getElementById('switch').checked){
document.form.kms_enable.value = 1;
}else{
document.form.kms_enable.value = 0;
}
});
}
function onSubmitCtrl(o, s) {
document.form.action_mode.value = s;
showLoading(3);
document.form.submit();
}
function reload_Soft_Center(){
location.href = "/Main_Soft_center.asp";
}
function version_show(){
$j.ajax({
url: 'https://raw.githubusercontent.com/paldier/softcenter_ks/mips_softerware_center/kms/config.json.js',
type: 'GET',
dataType: 'json',
success: function(res) {
$j("#kms_install_show").html("<i>有新版本:" + res.version);
}
});
}
var enable_ss = "<% nvram_get("enable_ss"); %>";
var enable_soft = "<% nvram_get("enable_soft"); %>";
function menu_hook(title, tab) {
tabtitle[tabtitle.length -1] = new Array("", "KMS");
tablink[tablink.length -1] = new Array("", "Module_kms.asp");
}
</script>
</head>
<body onload="init();">
<div id="TopBanner"></div>
<div id="Loading" class="popup_bg"></div>
<iframe name="hidden_frame" id="hidden_frame" src="" width="0" height="0" frameborder="0"></iframe>
<form method="POST" name="form" action="/applydb.cgi?p=kms_" target="hidden_frame">
<input type="hidden" name="current_page" value="Module_kms.asp" />
<input type="hidden" name="next_page" value="Module_kms.asp" />
<input type="hidden" name="group_id" value="" />
<input type="hidden" name="modified" value="0" />
<input type="hidden" name="action_mode" value="" />
<input type="hidden" name="action_script" value="" />
<input type="hidden" name="action_wait" value="5" />
<input type="hidden" name="first_time" value="" />
<input type="hidden" name="preferred_lang" id="preferred_lang" value="<% nvram_get(" preferred_lang "); %>"/>
<input type="hidden" name="SystemCmd" onkeydown="onSubmitCtrl(this, ' Refresh ')" value="k3c_kms.sh" />
<input type="hidden" name="firmver" value="<% nvram_get(" firmver "); %>"/>
<input type="hidden" id="kms_enable" name="kms_enable" value='<% dbus_get_def("kms_enable", "0"); %>' />
<table class="content" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="17">&nbsp;</td>
<td valign="top" width="202">
<div id="mainMenu"></div>
<div id="subMenu"></div>
</td>
<td valign="top">
<div id="tabMenu" class="submenuBlock"></div>
<table width="98%" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top">
<table width="760px" border="0" cellpadding="5" cellspacing="0" bordercolor="#6b8fa3" class="FormTitle" id="FormTitle">
<tr>
<td bgcolor="#4D595D" colspan="3" valign="top">
<div>&nbsp;</div>
<div style="float:left;" class="formfonttitle">系统工具 - 来自网络的胃軟系统工具</div>
<div style="float:right; width:15px; height:25px;margin-top:10px">
<img id="return_btn" onclick="reload_Soft_Center();" align="right" style="cursor:pointer;position:absolute;margin-left:-30px;margin-top:-25px;" title="返回软件中心" src="/images/backprev.png" onMouseOver="this.src='/images/backprevclick.png'" onMouseOut="this.src='/images/backprev.png'"></img>
</div>
<div style="margin-left:5px;margin-top:10px;margin-bottom:10px">
<img src="/images/New_ui/export/line_export.png">
</div>
<div class="formfontdesc" id="cmdDesc">该工具用于“鸡或”“胃軟奥菲斯”和“胃軟操作系统”。</div>
<div class="formfontdesc" id="cmdDesc"></div>
<table style="margin:10px 0px 0px 0px;" width="100%" border="1" align="center" cellpadding="4" cellspacing="0" bordercolor="#6b8fa3" class="FormTable" id="kms_table">
<thead>
<tr>
<td colspan="2">系统工具选项</td>
</tr>
</thead>
<tr>
<th>开启系统工具</th>
<td colspan="2">
<div class="switch_field" style="display:table-cell;float: left;">
<label for="switch">
<input id="switch" class="switch" type="checkbox" style="display: none;">
<div class="switch_container">
<div class="switch_bar"></div>
<div class="switch_circle transition_style">
<div></div>
</div>
</div>
</label>
</div>
<div id="kms_version_show" style="padding-top:5px;margin-left:230px;margin-top:0px;"><i>当前版本:<% dbus_get_def("kms_ver", "未知"); %></i>
</div>
<div id="kms_install_show" style="padding-top:5px;margin-left:330px;margin-top:-25px;"></div>
<a style="margin-left: 318px;" href="https://raw.githubusercontent.com/paldier/softcenter_ks/mips_softerware_center/kms/Changelog.txt" target="_blank"><em>[<u> 更新日志 </u>]</em></a>
</td>
</tr>
<tr id="port_tr">
<th width="35%">外网开关</th>
<td>
<div style="float:left; width:165px; height:25px">
<select id="kms_wan_port" name="kms_wan_port" style="width:164px;margin:0px 0px 0px 2px;" class="input_option">
<option value="0">关闭</option>
<option value="1">开启</option>
</select>
</div>
</td>
</tr>
</table>
<div class="apply_gen">
<button id="cmdBtn" class="button_gen" onclick="onSubmitCtrl(this, ' Refresh ')">提交</button>
</div>
<div style="margin-left:5px;margin-top:10px;margin-bottom:10px">
<img src="/images/New_ui/export/line_export.png">
</div>
<div id="NoteBox">
<h2>使用说明:</h2>
<h3>以管理员身份运行CMD输入以下命令红色字体代表变量不是固定的请参照自己的计算机修改。</h3>
<h3>【1】 奥菲斯鸡或</h3>
<p>CD <font color="red">X</font>:\Program Files<font color="red">(X86)</font>\Microsoft Office\Office<font color="red">14</font>
</p>
<p>cscript ospp.vbs /sethst:<font color="red">192.168.50.1</font>
</p>
<p>cscript ospp.vbs /act</p>
<p>cscript ospp.vbs /dstatus</p>
<h3>【2】 操作系统鸡或</h3>
<p>slmgr /ipk <font color="red">MHF9N-XY6XB-WVXMC-BTDCT-MKKG7</font>
</p>
<p>slmgr /skms <font color="red">192.168.50.1</font>
</p>
<p>slmgr /ato</p>
<h2>申明:本工具来自国外互联网 <a href="https://forums.mydigitallife.info/threads/50234-Emulated-KMS-Servers-on-non-Windows-platforms" target="_blank">点我跳转</a></h2>
</div>
<div style="margin-left:5px;margin-top:10px;margin-bottom:10px">
<img src="/images/New_ui/export/line_export.png">
</div>
<div class="KoolshareBottom">
<br/>论坛技术支持:
<a href="http://www.koolshare.cn" target="_blank"> <i><u>www.koolshare.cn</u></i>
</a>
<br/>后台技术支持: <i>Xiaobao</i>
<br/>Shell, Web by <i>fw867</i>
<br/>修改版 by <i>paldier</i>
<br/>
</div>
</td>
</tr>
</table>
</td>
<td width="10" align="center" valign="top"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</td>
<div id="footer"></div>
</body>
</html>

2
kms/version Normal file
View File

@ -0,0 +1,2 @@
1.5
647a16ede1b4cea1615391b6465b1525

View File

@ -150,7 +150,7 @@ document.form.v2ray_user.value = "0";
<input type="hidden" name="modified" value="0">
<input type="hidden" name="action_wait" value="2">
<input type="hidden" name="action_mode" value="toolscript">
<input type="hidden" name="action_script" value="softcenter_v2ray.sh">
<input type="hidden" name="action_script" value="/jffs/softcenter/scripts/softcenter_v2ray.sh">
<input type="hidden" name="preferred_lang" id="preferred_lang" value="<% nvram_get("preferred_lang"); %>" disabled>
<input type="hidden" name="firmver" value="<% nvram_get("firmver"); %>">
<input type="hidden" name="v2ray_enable" value="<% nvram_get("v2ray_enable"); %>">