add softcenter

This commit is contained in:
paldier 2018-12-06 23:59:57 +08:00
parent 6f1295c21b
commit e789740b34
73 changed files with 2220 additions and 2 deletions

View File

@ -65,7 +65,7 @@
function version_show(){
$j.ajax({
url: 'https://raw.githubusercontent.com/paldier/softcenter_ks/mips_softerware_center/kms/config.json.js',
url: 'https://raw.githubusercontent.com/paldier/softcenter/master/kms/config.json.js',
type: 'GET',
dataType: 'json',
success: function(res) {
@ -147,7 +147,7 @@
<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>
<a style="margin-left: 318px;" href="https://raw.githubusercontent.com/paldier/softcenter/master/kms/Changelog.txt" target="_blank"><em>[<u> 更新日志 </u>]</em></a>
</td>
</tr>
<tr id="port_tr">

14
softcenter/Changelog.txt Normal file
View File

@ -0,0 +1,14 @@
Koolshare Asuswrt-Merlin softeware center Changelog
===========================================
1.1.0
- fix make shadowsocks the first icon in softerware center when using local data
1.0.9
- fix fix shadowsocks turn to koolsocks when software center server is down
- add make shadowsocks default installed in softerware center(prepare for the next fw)
1.0.8
- fix icon position adjustmet
1.0.5
- fix 插件隐藏按钮移动到右侧

34
softcenter/README.md Normal file
View File

@ -0,0 +1,34 @@
软件中心原理
=====
负责维护与独立更新新增模块的安装脚本以及安装界面。也就是说路由器初步只需要安装软件中心,再由软件中心去更新各个模块的安装脚本与安装界面,用户就可以独立安装相应的模块了。恩,这个是一个好想法。
目前软件中心没有像 openwrt 一样使用 opkg 来解决软件安装的依赖问题。目前原因是为了简单。所以现在只是一个安装的压缩包,并没有解决软件中心的各大依赖问题。如果有依赖问题请在安装脚本里去实现与提示。
模块实现规定
======
比如 adm 模块。本项目文件夹形式:
* adm
* adm adm程序本身的一些配置以及可执行程序
* bin 相关用到的可执行文件
* init.d 启动脚本。其实是一个软链接
* install.sh 模块本身解压之后要运行的安装脚本
* scripts http 界面配置需要用到的网页配置相关脚本
* adm_install.sh 软件中心安装包要带上它,以实现模块的安装
* adm_udpate.sh 软件中心要带上它,以实现模块的更新
* adm_config.sh 路由器 http server 服务的配置脚本
* adm_uninstall.sh 卸载
* webs
* Module_adm.asp 路由器配置界面,软件中心要带上它,以实现模块界面的安装。用户才可以点开配置界面安装模块本身。
* build.sh 模块生成脚本
* config.json.js 当前项目在线版本号,通过跨域调用来获得此版本
* version 版本信息文件,模块安装依赖此版本信息
软件中心设计初步想法
======
* 所有的图标存于./softcenter/res/software_center.png
* 所有的 APP 信息存于 app.json.js
* 已安装的数据,存于路由器内部
* 未安装部分,实时从 github 拿到数据
* 问题
* 未安装部分的图片,如何实时从github当中拿?
* 未安装部分的 css 如何实时从 github 动态拉取拿?

120
softcenter/app.json.js Normal file
View File

@ -0,0 +1,120 @@
{
"apps": [
{
"build_date": "2016-09-01_17:20:58",
"description": "让测速更简单",
"home_url": "Module_speedtest.asp",
"md5": "7adab161925485c41ff8b54a7ffc75f2",
"name": "speedtest",
"tar_url": "speedtest/speedtest.tar.gz",
"title": "网络测速",
"version": "0.2.2"
},
{
"name": "shadowsocks",
"tar_url": "shadowsocks/shadowsocks.tar.gz",
"title": "shadowsocks"
},
{
"build_date": "2017-05-03_19:15:58",
"description": "godaddy ddns",
"home_url": "Module_gdddns.asp",
"md5": "6d1fce64a66aa830df21abf764456def",
"module": "gdddns",
"name": "gdddns",
"tar_url": "gdddns/gdddns.tar.gz",
"title": "gdddns",
"version": "1.0.0"
},
{
"build_date": "2016-09-01_17:21:04",
"description": "老板,来一斤虚拟内存~",
"home_url": "Module_swap.asp",
"md5": "852a398f732af3508c83a6d3ca91f25d",
"name": "swap",
"tar_url": "swap/swap.tar.gz",
"title": "虚拟内存",
"version": "1.8"
},
{
"build_date": "2017-06-06_01:02:58",
"description": "koolproxy",
"home_url": "Module_koolproxy.asp",
"md5": "11d29bfc9f80fa76ffe23d834cd7799b",
"name": "koolproxy",
"tar_url": "koolproxy/koolproxy.tar.gz",
"title": "koolproxy",
"version": "3.2.9"
},
{
"build_date": "2016-09-01_17:20:52",
"description": "迅雷快鸟,为上网加速而生~",
"home_url": "Module_kuainiao.asp",
"md5": "e767c621332ec5cb4227d4358c9a283b",
"name": "kuainiao",
"tar_url": "kuainiao/kuainiao.tar.gz",
"title": "讯雷快鸟",
"version": "0.3.6"
},
{
"build_date": "2018-12-06_13:29:29",
"description": "kms",
"home_url": "Module_kms.asp",
"md5": "647a16ede1b4cea1615391b6465b1525",
"name": "kms",
"tar_url": "kms/kms.tar.gz",
"title": "kms",
"version": "1.5"
},
{
"build_date": "2016-09-27_18:43:33",
"description": "阿里云解析自动更新IP",
"home_url": "Module_aliddns.asp",
"md5": "00c97793e5b7195dd1d1def15f506883",
"module": "aliddns",
"name": "aliddns",
"tar_url": "aliddns/aliddns.tar.gz",
"title": "aliddns",
"version": "1.0"
},
{
"build_date": "2016-09-01_17:20:40",
"description": "使用Dnspod的ddns服务",
"home_url": "Module_ddnspod.asp",
"md5": "85041eb4ae44c853dd61243d2c4f2fda",
"name": "ddnspod",
"tar_url": "ddnspod/ddnspod.tar.gz",
"title": "DDnspod",
"version": "0.1.3"
},
{
"name": "tunnel",
"tar_url": "tunnel/tunnel.tar.gz",
"title": "tunnel"
},
{
"build_date": "2016-09-01_17:20:46",
"description": "让分流更简单",
"home_url": "Module_policy_route.asp",
"md5": "3112c34fa479156b5872ae700b7015b3",
"name": "dualwan",
"tar_url": "dualwan/dualwan.tar.gz",
"title": "策略路由",
"version": "0.6"
},
{
"build_date": "2016-09-16_10:11:21",
"description": "广告屏蔽大师",
"home_url": "Module_adbyby.asp",
"md5": "8822d84a21ec33db53bdb4c1a98b2394",
"name": "adbyby",
"tar_url": "adbyby/adbyby.tar.gz",
"title": "adbyby",
"version": "1.1"
}
],
"home_url": "https://raw.githubusercontent.com/paldier/softcenter/master",
"md5": "3242715f2a71bec3ffc70252f92c977b",
"tar_url": "softcenter/softcenter.tar.gz",
"version": "1.1.6"
}

View File

@ -0,0 +1,21 @@
{
"version":"1.0.5",
"md5":"a16640f5a0df9186897be0de52e6629a",
"tar_url":"softcenter/softcenter.tar.gz",
"home_url":"https://raw.githubusercontent.com/paldier/softcenter/master",
"apps":
[
{
"name":"adm",
"title":"阿呆猫",
"ver":"0.5",
"home_url":"/Module_xunlei.asp",
"tar_url":"adm/adm.tar.gz",
"md5":"31559b347f6c8081ccdece78e50156d5"
},
{
}
]
}

25
softcenter/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 softcenter.tar.gz | awk '{print $1}'`
if [ -f ./softcenter.tar.gz ];then
if [ "$version_old" != "$version_new" ];then
mkdir ./history/$version_new/
cp ./softcenter.tar.gz ./history/$version_new/
echo $version_new $md5_new >> ./history/version
fi
fi

30
softcenter/build.sh Executable file
View File

@ -0,0 +1,30 @@
#! /bin/sh
VERSION=1.1.6
cat version
rm -f softcenter.tar.gz
mkdir -p ./softcenter/res
python ./gen_install.py stage1
chmod 755 ./softcenter/scripts/ks_app_install.sh
tar -zcvf softcenter.tar.gz softcenter
md5value=`md5sum softcenter.tar.gz|tr " " "\n"|sed -n 1p`
cat > ./version <<EOF
$VERSION
$md5value
EOF
cat version
cat > ./config.json.js <<EOF
{
"version":"$VERSION",
"md5":"$md5value"
}
EOF
python ./gen_install.py stage2
cat to_remove.txt|xargs rm -f
rm to_remove.txt

57
softcenter/build_base.sh Normal file
View File

@ -0,0 +1,57 @@
#!/bin/sh
# Now in module working directory
do_build_result() {
if [ "$VERSION" = "" ]; then
echo "version not found"
exit 3
fi
rm -f ${MODULE}.tar.gz
#清理mac os 下文件
rm -f $MODULE/.DS_Store
rm -f $MODULE/*/.DS_Store
tar -zcvf ${MODULE}.tar.gz $MODULE
#md5value=`md5sum ${MODULE}.tar.gz|awk -F ' = ' '{print $2}'|sed -n 1p`
md5value=`md5sum ${MODULE}.tar.gz|tr " " "\n"|sed -n 1p`
cat > ./version <<EOF
$VERSION
$md5value
EOF
cat > ./config.json.js <<EOF
{
"version":"$VERSION",
"md5":"$md5value"
}
EOF
cat version
rm -f ${MODULE}.tar.gz
tar -zcvf ${MODULE}.tar.gz $MODULE
md5value=`md5sum ${MODULE}.tar.gz|tr " " "\n"|sed -n 1p`
cat > ./version <<EOF
$VERSION
$md5value
EOF
cat version
DATE=`date +%Y-%m-%d_%H:%M:%S`
cat > ./config.json.js <<EOF
{
"version":"$VERSION",
"md5":"$md5value",
"home_url":"$HOME_URL",
"title":"$TITLE",
"description":"$DESCRIPTION",
"build_date":"$DATE"
}
EOF
#update md5
python ../softcenter/gen_install.py stage2
}

View File

@ -0,0 +1,4 @@
{
"version":"1.1.6",
"md5":"3242715f2a71bec3ffc70252f92c977b"
}

107
softcenter/gen_install.py Executable file
View File

@ -0,0 +1,107 @@
#!/usr/bin/env python
# _*_ coding:utf-8 _*_
import os
import json
import hashlib
import codecs
from shutil import copyfile
import sys
stage = "stage1"
if len(sys.argv) > 1:
stage = sys.argv[1]
curr_path = os.path.dirname(os.path.realpath(__file__))
parent_path = os.path.realpath(os.path.join(curr_path, ".."))
to_remove = None
def md5sum(full_path):
with open(full_path, 'rb') as rf:
return hashlib.md5(rf.read()).hexdigest()
def work_paths_by_walk():
index = 0
for root,subdirs,files in os.walk(parent_path):
index += 1
for filepath in files:
print os.path.join(root,filepath)
for sub in subdirs:
print os.path.join(root,sub)
def work_parent():
ignore_paths = frozenset(["maintain_files", "softcenter", "v2ray"])
for fname in os.listdir(parent_path):
if fname[0] == "." or fname in ignore_paths:
continue
path = os.path.join(parent_path, fname)
if os.path.isdir(path):
#print fname
#print path
yield fname, path
def work_files(parent, ext):
for fname in os.listdir(parent):
path = os.path.join(parent, fname)
if os.path.isfile(path):
yield path
def check_subdir(module, path, name, ext, target_path):
script_path = os.path.join(path, module, name)
if os.path.isdir(script_path):
for f in work_files(script_path, ext):
target_file = os.path.join(target_path, os.path.basename(f))
#print "copy", f, "-->", target_file
copyfile(f, target_file)
if not target_file.endswith(".png") and to_remove:
to_remove.write(target_file+"\n")
def check_and_cp():
for module, path in work_parent():
#check_subdir(module, path, "scripts", ".sh", os.path.join(curr_path, "softcenter", "scripts"))
#check_subdir(module, path, "webs", ".asp", os.path.join(curr_path, "softcenter", "webs"))
#check_subdir(module, path, "scripts", ".sh", os.path.join(curr_path, "softcenter", "scripts"))
check_subdir(module, path, "res", "*", os.path.join(curr_path, "softcenter", "res"))
def gen_modules(modules):
for module, path in work_parent():
conf = os.path.join(path, "config.json.js")
m = None
try:
with codecs.open(conf, "r", "utf-8") as fc:
m = json.loads(fc.read())
if m:
m["name"] = module
if "tar_url" not in m:
m["tar_url"] = module + "/" + module + ".tar.gz"
if "home_url" not in m:
m["home_url"] = "Module_" + module + ".asp"
except:
pass
if not m:
m = {"name":module, "title":module, "tar_url": module + "/" + module + ".tar.gz"}
modules.append(m)
if stage == "stage1":
to_remove = open(os.path.join(curr_path, "to_remove.txt"), "w")
check_and_cp()
to_remove.close()
else:
gmodules = None
with codecs.open(os.path.join(curr_path, "app.template.json.js"), "r", "utf-8") as fg:
gmodules = json.loads(fg.read())
gmodules["apps"] = []
gen_modules(gmodules["apps"])
with codecs.open(os.path.join(curr_path, "config.json.js"), "r", "utf-8") as fc:
conf = json.loads(fc.read())
gmodules["version"] = conf["version"]
gmodules["md5"] = conf["md5"]
with codecs.open(os.path.join(curr_path, "app.json.js"), "w", "utf-8") as fw:
json.dump(gmodules, fw, sort_keys = True, indent = 4, ensure_ascii=False, encoding='utf8')

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,2 @@
1.1.5 78c52468f168d06a87b17462cbcce395
1.1.6 3242715f2a71bec3ffc70252f92c977b

6
softcenter/index.html Normal file
View File

@ -0,0 +1,6 @@
<html>
<body>
<h1>Hello to softcenter home page </h1>
</body>
</html>

View File

@ -0,0 +1,7 @@
{
"title":"<em>梅林改版固件&nbsp;-&nbsp;软件中心</em>",
"content1":"<b>软件中心测试版2018年12月6日</b>",
"content2":"原软件中心暂时按原来方式运行;",
"content3":"新软件中心内不要启用和原软件中心冲突的插件",
"content4":"祝好!"
}

Binary file not shown.

View File

@ -0,0 +1,227 @@
#!/bin/sh -e
# perp: persistent process supervision
# perp-setup: one-time, post-install configurator for perp
# wcm, 2009.12.23 - 2012.01.04
# ===
## basename:
_PROG=${0##*/}
_PID=$$
_BASE_DEFAULT=/etc/perp
_CTL_DEFAULT=/var/run/perp
_BASE=${PERP_BASE:-${_BASE_DEFAULT}}
_CTL=${PERP_CTL:-${_CTL_DEFAULT}}
_INITTAB=/etc/inittab
_RCLOCAL=/etc/rc.local
_mesg() {
echo "${_PROG}(${_PID}): $1" >/dev/stderr
}
_fail() {
_mesg "failure: $1"
exit 1
}
_done() {
_mesg "perp configured."
exit 0
}
## command-line override for _BASE, _CTL:
if test $# -gt 0 ; then
_BASE=${1:-${_BASE}}
fi
if test $# -gt 1 ; then
_CTL=${2:-${_CTL}}
fi
if test 'X' != ${DESTDIR}'X' ; then
_mesg "configuring perp in DESTDIR ${DESTDIR} for ${_BASE} ..."
else
_mesg "configuring perp for ${DESTDIR}${_BASE} ..."
fi
if ! test -d ${DESTDIR}${_BASE} ; then
mkdir -p ${DESTDIR}${_BASE} || _fail "unable to create base directory"
fi
if ! test -d ${DESTDIR}${_BASE}/.boot ; then
mkdir -p ${DESTDIR}${_BASE}/.boot || _fail "unable to create .boot directory"
fi
if ! test -e ${DESTDIR}${_BASE}/.control -o -L ${DESTDIR}${_BASE}/.control ; then
## create symlink to control directory (possibly dangling):
ln -s ${_CTL} ${DESTDIR}${_BASE}/.control || \
_fail "unable to create symlink for .control directory"
fi
_mesg "configuring perpboot directory in ${DESTDIR}${_BASE}/.boot ..."
## clean any pre-existing *.new files:
for f in rc.log rc.perp rlimit.conf ; do
rm -f ${DESTDIR}${_BASE}/.boot/${f}.new
done
## rlimit.conf:
cat - > ${DESTDIR}${_BASE}/.boot/rlimit.conf.new << "%%"
# rlimit.conf
# runlimit setup for perpd
# ===
## set RLIMIT_NOFILE and RLIMIT_NPROC to hard limit:
RLIMIT_NOFILE=^
RLIMIT_NPROC=^
### EOF
%%
## rc.perp:
cat - > ${DESTDIR}${_BASE}/.boot/rc.perp.new << "%%"
#!/bin/sh -e
# rc.perp: perpd startup script for perpboot
# ===
### --- configure ---
PERPD_OPTS="-a6"
### --- script ---
## exec perpd:
## * options as configured above
## * runchoom(8) abate linux oom-killer
## * runlimit(8) configured in ./rlimit.conf
## * PERP_BASE defined in environment by perpboot(8)
exec \
runchoom \
runlimit -F ./rlimit.conf \
perpd ${PERPD_OPTS} ${PERP_BASE}
### EOF
%%
## rc.log:
cat - > ${DESTDIR}${_BASE}/.boot/rc.log.new << "%%"
#!/bin/sh
# rc.log: perpd logger script for perpboot
# ===
### --- configure ---
## required:
LOGDIR=/var/log/perpd
LOGOPTS="-k 8 -s 100000 -t -z"
## suggested:
LOGUSER=tinylog
### --- script ---
## initialize user:
if id ${LOGUSER} >/dev/null 2>/dev/null ; then
my_uid=$(id -u ${LOGUSER})
my_gid=$(id -g ${LOGUSER})
else
LOGUSER=$(id -un)
my_uid=$(id -u ${LOGUSER})
my_gid=$(id -g ${LOGUSER})
fi
## initialize logdir:
if ! test -d ${LOGDIR} ; then
mkdir -p ${LOGDIR}
fi
chown -R ${my_uid}:${my_gid} ${LOGDIR}
chmod 0755 ${LOGDIR}
## exec tinylog with privilege drop:
exec \
runuid ${LOGUSER} \
tinylog ${LOGOPTS} ${LOGDIR}
### EOF
%%
for f in rlimit.conf ; do
if ! test -f ${DESTDIR}${_BASE}/.boot/${f} ; then
mv ${DESTDIR}${_BASE}/.boot/${f}.new ${DESTDIR}${_BASE}/.boot/${f}
chmod 0644 ${DESTDIR}${_BASE}/.boot/${f}
fi
done
for f in rc.perp rc.log ; do
if ! test -f ${DESTDIR}${_BASE}/.boot/${f} ; then
mv ${DESTDIR}${_BASE}/.boot/${f}.new ${DESTDIR}${_BASE}/.boot/${f}
chmod 0755 ${DESTDIR}${_BASE}/.boot/${f}
fi
done
_mesg "perpboot directory configured"
## skip init configuration?
if test 'X' != ${DESTDIR}'X' ; then
_mesg "DESTDIR defined, skipping startup configuration"
_done
fi
if test 'X' != ${NO_INIT}'X' ; then
_mesg "NO_INIT defined, skipping startup configuration"
_done
fi
## /etc/inittab installation (sysv):
if test -f ${_INITTAB} ; then
_mesg "configuring perpboot entry for ${_INITTAB} ..."
if fgrep perpboot ${_INITTAB} >/dev/null 2>/dev/null ; then
_mesg "perpboot entry already found in ${_INITTAB}"
_done
else
rm -f ${_INITTAB}.new
cat ${_INITTAB} - > ${_INITTAB}.new << %%
## perp:
PB:12345:respawn:/tmp/p/sbin/perpboot -x ${_BASE}
### EOF
%%
mv ${_INITTAB}.new ${_INITTAB}
_mesg "perpboot entry added to ${_INITTAB}"
_mesg "*** please run \"kill -HUP 1\" to activate ***"
# kill -HUP 1
_done
fi
fi
## /etc/rc.local installation (bsd):
if test -f ${_RCLOCAL} ; then
_mesg "configuring perpboot entry for ${_RCLOCAL} ..."
if fgrep perpboot ${_RCLOCAL} >/dev/null 2>/dev/null ; then
_mesg "perpboot entry already found in ${_RCLOCAL}"
_done
else
rm -f ${_RCLOCAL}.new
cat ${_RCLOCAL} - > ${_RCLOCAL}.new << %%
## perp:
if [ -x /tmp/p/sbin/perpboot ]; then
echo -n ' perpd'
## to modify path within perp runscripts, edit/uncomment:
#PATH=/sbin:/bin:/usr/sbin:/usr/bin \\
/tmp/p/sbin/perpboot -d ${_BASE}
fi
### EOF
%%
mv ${_RCLOCAL}.new ${_RCLOCAL}
_mesg "perpboot entry added to ${_RCLOCAL}"
_mesg "*** please restart system to activate ***"
_done
fi
fi
_mesg "uh oh, neither ${_INITTAB} nor ${_RCLOCAL} were found on your system!"
_mesg "this system will require manual startup configuration for perpd(8)/perpboot(8)"
exit 1
### EOF

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,22 @@
#!/bin/sh
softcenter_install() {
if [ -d "/tmp/softcenter" ]; then
cp -rf /tmp/softcenter/webs/* /jffs/softcenter/webs
cp -rf /tmp/softcenter/res/* /jffs/softcenter/res/
cp -rf /tmp/softcenter/bin/* /jffs/softcenter/bin/
cp -rf /tmp/softcenter/perp /jffs/softcenter/
cp -rf /tmp/softcenter/scripts /jffs/softcenter/
chmod 755 /jffs/softcenter/bin/*
chmod 755 /jffs/softcenter/perp/*
chmod 755 /jffs/softcenter/perp/.boot/*
chmod 755 /jffs/softcenter/perp/.control/*
chmod 755 /jffs/softcenter/perp/adm/*
rm -rf /tmp/softcenter
if [ ! -f "/jffs/softcenter/init.d/S10Softcenter.sh" ]; then
ln -sf /jffs/softcenter/scripts/app_install.sh /jffs/softcenter/init.d/S10Softcenter.sh
fi
fi
}
softcenter_install

View File

@ -0,0 +1,3 @@
#!/bin/sh
LOGDIR=/var/log/perpd
exec tinylog -k 3 -s 50000 -t ${LOGDIR}

View File

@ -0,0 +1,2 @@
#!/bin/sh
exec perpd -a 6 $PERP_BASE

View File

@ -0,0 +1 @@
30237

View File

@ -0,0 +1,6 @@
#!/bin/sh
if test ${1} = 'start' ; then
exec tinylog -k 5 -t /var/log/${2}
fi
exit 0

View File

@ -0,0 +1,10 @@
#!/bin/sh
adm_enable=`dbus get adm_enable`
exec 2>&1
if test ${1} = 'start' ; then
if [ "$adm_enable" == "1" ];then
exec /jffs/softcenter/adm/ADM
fi
fi
exit 0

View File

@ -0,0 +1,23 @@
#!/bin/sh
source /jffs/softcenter/scripts/base.sh
export PERP_BASE=/koolshare/perp
case $ACTION in
start)
if ! pidof perpd > /dev/null; then
perpboot -d
fi
;;
stop)
if pidof perpd > /dev/null; then
kill -9 `pidof perpboot`
kill -9 `pidof tinylog`
kill -9 `pidof perpd`
fi
;;
*)
echo "Usage: $0 (start)"
exit 1
;;
esac

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1,256 @@
#!/bin/sh
#From dbus to local variable
eval `dbus export softcenter_installing_`
source /jffs/softcenter/scripts/base.sh
export PERP_BASE=/jffs/softcenter/perp
#softcenter_installing_module #正在安装的模块
#softcenter_installing_todo #希望安装的模块
#softcenter_installing_tick #上次安装开始的时间
#softcenter_installing_version #正在安装的版本
#softcenter_installing_md5 #正在安装的版本的md5值
#softcenter_installing_tar_url #模块对应的下载地址
#softcenter_installing_status= #尚未安装
#softcenter_installing_status=0 #尚未安装
#softcenter_installing_status=1 #已安装
#softcenter_installing_status=2 #将被安装到jffs分区...
#softcenter_installing_status=3 #正在下载中...请耐心等待...
#softcenter_installing_status=4 #正在安装中...
#softcenter_installing_status=5 #安装成功请5秒后刷新本页面...
#softcenter_installing_status=6 #卸载中......
#softcenter_installing_status=7 #卸载成功!
#softcenter_installing_status=8 #没有检测到在线版本号!
#softcenter_installing_status=9 #正在下载更新......
#softcenter_installing_status=10 #正在安装更新...
#softcenter_installing_status=11 #安装更新成功5秒后刷新本页
#softcenter_installing_status=12 #下载文件校验不一致!
#softcenter_installing_status=13 #然而并没有更新!
#softcenter_installing_status=14 #正在检查是否有更新~
#softcenter_installing_status=15 #检测更新错误!
softcenter_home_url=`dbus get softcenter_home_url`
CURR_TICK=`date +%s`
BIN_NAME=$(basename "$0")
BIN_NAME="${BIN_NAME%.*}"
if [ "$ACTION" != "" ]; then
BIN_NAME=$ACTION
fi
VER_SUFFIX=_version
MD5_SUFFIX=_md5
INSTALL_SUFFIX=_install
UNINSTALL_SUFFIX=_uninstall
LOGGER() {
# echo $1
logger $1
}
install_module() {
if [ "$softcenter_home_url" = "" -o "$softcenter_installing_md5" = "" -o "$softcenter_installing_version" = "" ]; then
LOGGER "input error, something not found"
exit 1
fi
if [ "$softcenter_installing_tick" = "" ]; then
export softcenter_installing_tick=0
fi
LAST_TICK=`expr $softcenter_installing_tick + 20`
if [ "$LAST_TICK" -ge "$CURR_TICK" -a "$softcenter_installing_module" != "" ]; then
LOGGER "module $softcenter_installing_module is installing"
exit 2
fi
if [ "$softcenter_installing_todo" = "" ]; then
#curr module name not found
LOGGER "module name not found"
exit 3
fi
# Just ignore the old installing_module
export softcenter_installing_module=$softcenter_installing_todo
export softcenter_installing_tick=`date +%s`
export softcenter_installing_status="2"
dbus save softcenter_installing_
URL_SPLIT="/"
#OLD_MD5=`dbus get softcenter_module_$softcenter_installing_module$MD5_SUFFIX`
OLD_VERSION=`dbus get softcenter_module_$softcenter_installing_module$VER_SUFFIX`
HOME_URL=`dbus get softcenter_home_url`
TAR_URL=$HOME_URL$URL_SPLIT$softcenter_installing_tar_url
FNAME=`basename $softcenter_installing_tar_url`
if [ "$OLD_VERSION" = "" ]; then
OLD_VERSION=0
fi
CMP=`versioncmp $softcenter_installing_version $OLD_VERSION`
if [ -f /jffs/softcenter/webs/Module_$softcenter_installing_module.sh -o "$softcenter_installing_todo" = "softcenter" ]; then
CMP="-1"
fi
if [ "$CMP" = "-1" ]; then
cd /tmp
rm -f $FNAME
rm -rf "/tmp/$softcenter_installing_module"
wget --no-check-certificate --tries=1 --timeout=15 $TAR_URL
RETURN_CODE=$?
if [ "$RETURN_CODE" != "0" ]; then
dbus set softcenter_installing_status="12"
sleep 2
dbus set softcenter_installing_status="0"
dbus set softcenter_installing_module=""
dbus set softcenter_installing_todo=""
LOGGER "wget error, $RETURN_CODE"
exit 4
fi
md5sum_gz=$(md5sum /tmp/$FNAME | sed 's/ /\n/g'| sed -n 1p)
if [ "$md5sum_gz"x != "$softcenter_installing_md5"x ]; then
LOGGER "md5 not equal $md5sum_gz"
dbus set softcenter_installing_status="12"
rm -f $FNAME
sleep 2
dbus set softcenter_installing_status="0"
dbus set softcenter_installing_module=""
dbus set softcenter_installing_todo=""
rm -f $FNAME
rm -rf "/tmp/$softcenter_installing_module"
exit
else
tar -zxf $FNAME
dbus set softcenter_installing_status="4"
if [ ! -f /tmp/$softcenter_installing_module/install.sh ]; then
dbus set softcenter_installing_status="0"
dbus set softcenter_installing_module=""
dbus set softcenter_installing_todo=""
#rm -f $FNAME
#rm -rf "/tmp/$softcenter_installing_module"
LOGGER "package hasn't install.sh"
exit 5
fi
if [ -f /tmp/$softcenter_installing_module/uninstall.sh ]; then
chmod 755 /tmp/$softcenter_installing_module/uninstall.sh
mv /tmp/$softcenter_installing_module/uninstall.sh /jffs/softcenter/scripts/uninstall_$softcenter_installing_todo.sh
fi
chmod a+x /tmp/$softcenter_installing_module/install.sh
sh /tmp/$softcenter_installing_module/install.sh
sleep 2
rm -f $FNAME
rm -rf "/tmp/$softcenter_installing_module"
if [ "$softcenter_installing_module" != "softcenter" ]; then
dbus set "softcenter_module_$softcenter_installing_module$MD5_SUFFIX=$softcenter_installing_md5"
dbus set "softcenter_module_$softcenter_installing_module$VER_SUFFIX=$softcenter_installing_version"
dbus set "softcenter_module_$softcenter_installing_module$INSTALL_SUFFIX=1"
dbus set "$softcenter_installing_module$VER_SUFFIX=$softcenter_installing_version"
else
dbus set softcenter_version=$softcenter_installing_version;
dbus set softcenter_md5=$softcenter_installing_md5
fi
dbus set softcenter_installing_module=""
dbus set softcenter_installing_todo=""
dbus set softcenter_installing_status="1"
fi
else
LOGGER "current version is newest version"
dbus set softcenter_installing_status="13"
sleep 3
dbus set softcenter_installing_status="0"
dbus set softcenter_installing_module=""
dbus set softcenter_installing_todo=""
fi
}
uninstall_module() {
if [ "$softcenter_installing_tick" = "" ]; then
export softcenter_installing_tick=0
fi
LAST_TICK=`expr $softcenter_installing_tick + 20`
if [ "$LAST_TICK" -ge "$CURR_TICK" -a "$softcenter_installing_module" != "" ]; then
LOGGER "module $softcenter_installing_module is installing"
exit 2
fi
if [ "$softcenter_installing_todo" = "" -o "$softcenter_installing_todo" = "softcenter" ]; then
#curr module name not found
LOGGER "module name not found"
exit 3
fi
ENABLED=`dbus get "$softcenter_installing_todo""_enable"`
if [ "$ENABLED" = "1" ]; then
LOGGER "please disable this module than try again"
exit 4
fi
# Just ignore the old installing_module
export softcenter_installing_module=$softcenter_installing_todo
export softcenter_installing_tick=`date +%s`
export softcenter_installing_status="6"
dbus save softcenter_installing_
dbus remove "softcenter_module_$softcenter_installing_module$MD5_SUFFIX"
dbus remove "softcenter_module_$softcenter_installing_module$VER_SUFFIX"
dbus remove "softcenter_module_$softcenter_installing_module$INSTALL_SUFFIX"
txt=`dbus list $softcenter_installing_todo`
printf "%s\n" "$txt" |
while IFS= read -r line; do
line2="${line%=*}"
if [ "$line2" != "" ]; then
dbus remove $line2
fi
done
sleep 3
dbus set softcenter_installing_module=""
dbus set softcenter_installing_status="7"
dbus set softcenter_installing_todo=""
#try to call uninstall script
if [ -f "/jffs/softcenter/scripts/$softcenter_installing_todo$UNINSTALL_SUFFIX.sh"]; then
sh /jffs/softcenter/scripts/$softcenter_installing_todo$UNINSTALL_SUFFIX.sh
elif [ -f "/jffs/softcenter/scripts/uninstall_$softcenter_installing_todo.sh" ]; then
sh /jffs/softcenter/scripts/uninstall_$softcenter_installing_todo.sh
else
rm -f /jffs/softcenter/webs/Module_$softcenter_installing_todo.asp
rm -f /jffs/softcenter/init.d/S*$softcenter_installing_todo.sh
fi
}
LOGGER $BIN_NAME
case $BIN_NAME in
start)
sh /jffs/softcenter/perp/perp.sh start
;;
update)
install_module
;;
install)
install_module
;;
ks_app_install)
install_module
;;
ks_app_remove)
uninstall_module
;;
*)
install_module
;;
esac

View File

@ -0,0 +1 @@
/koolshare/scripts/ks_app_install.sh

View File

@ -0,0 +1,57 @@
#!/bin/sh
#From dbus to local variable
eval `dbus export soft`
name=`echo "$soft_name"|cut -d "." -f1`
cat /dev/null > /tmp/syscmd.log
INSTALL_SUFFIX=_install
VER_SUFFIX=_version
cd /tmp
echo $(date): 开启软件离线安装!>> /tmp/syscmd.log
if [ -f /tmp/$soft_name ];then
echo $(date): /tmp目录下检测到上传的离线安装包$soft_name >> /tmp/syscmd.log
echo $(date): 尝试解压离线安装包离线安装包 >> /tmp/syscmd.log
tar -zxvf $soft_name >/dev/null 2>&1
echo $(date): 解压完成! >> /tmp/syscmd.log
if [ -f /tmp/$name/install.sh ];then
echo $(date): 找到安装脚本! >> /tmp/syscmd.log
echo $(date): 运行安装脚本... >> /tmp/syscmd.log
chmod +x /tmp/$name/install.sh >/dev/null 2>&1
sh /tmp/$name/install.sh >/dev/null 2>&1
dbus set "softcenter_module_$name$INSTALL_SUFFIX=1"
dbus set "softcenter_module_$name$VER_SUFFIX=$soft_install_version"
install_pid=`ps | grep install.sh | grep -v grep | awk '{print $1}'`
i=120
until [ ! -n "$install_pid" ]
do
i=$(($i-1))
if [ "$i" -lt 1 ];then
echo $(date): "Could not load nat rules!"
echo $(date): 安装似乎出了点问题,请手动重启路由器后重新尝试... >> /tmp/syscmd.log
echo $(date): 删除相关文件并退出... >> /tmp/syscmd.log
rm -rf /tmp/software
rm -rf /tmp/$soft_name
dbus remove "softcenter_module_$name$INSTALL_SUFFIX"
exit
fi
sleep 1
done
echo $(date): 离线包安装完成! >> /tmp/syscmd.log
echo $(date): 一点点清理工作... >> /tmp/syscmd.log
rm -rf /tmp/$soft_name
echo $(date): 完成! >> /tmp/syscmd.log
else
echo $(date): 没有找到安装脚本! >> /tmp/syscmd.log
echo $(date): 删除相关文件并退出... >> /tmp/syscmd.log
rm -rf /tmp/$soft_name
fi
else
echo $(date): 没有找到离线安装包! >> /tmp/syscmd.log
echo $(date): 删除相关文件并退出... >> /tmp/syscmd.log
rm -rf /tmp/software
rm -rf /tmp/$soft_name
fi
rm -rf /tmp/$soft_name

View File

@ -0,0 +1,765 @@
<!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>Merlin software center</title>
<link rel="stylesheet" type="text/css" href="index_style.css"/>
<link rel="stylesheet" type="text/css" href="form_style.css"/>
<script language="JavaScript" type="text/javascript" src="/state.js"></script>
<script language="JavaScript" type="text/javascript" src="/help.js"></script>
<script language="JavaScript" type="text/javascript" src="/general.js"></script>
<script language="JavaScript" type="text/javascript" src="/popup.js"></script>
<script language="JavaScript" type="text/javascript" src="/client_function.js"></script>
<script language="JavaScript" 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 type="text/javascript" src="/form.js"></script>
<style>
.cloud_main_radius_left{
-webkit-border-radius: 10px 0 0 10px;
-moz-border-radius: 10px 0 0 10px;
border-radius: 10px 0 0 10px;
}
.cloud_main_radius_right{
-webkit-border-radius: 0 10px 10px 0;
-moz-border-radius: 0 10px 10px 0;
border-radius: 0 10px 10px 0;
}
.cloud_main_radius{
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
</style>
<style>
/* 软件中心icon新样式 by acelan */
dl,dt,dd{
padding:0;
margin:0;
}
input[type=button]:focus {
outline: none;
}
.icon{
float:left;
position:relative;
margin: 10px 0px 30px 0px;
}
.icon-title{
line-height: 3em;
text-align:center;
}
.icon-pic{
margin: 10px 30px 0px 30px;
}
.icon-pic img{
border:0;
width: 60px;
height: 60px;
margin:2px;
}
.icon-desc{
position: absolute;
left: 0;
top: 0;
height: 105%;
visibility: hidden;
font-size:0;
width: 119px;
border-radius: 8px;
font-size: 16px;
opacity: 0;
background-color:#000;
margin:5px;
text-overflow:ellipsis;
transition: opacity .5s ease-in;
}
.icon-desc .text{
font-size: 12px;
line-height: 1.4em;
display: block;
height: 100%;
padding: 10px;
box-sizing: border-box;
}
.icon:hover .icon-desc{
opacity: .8;
visibility: visible;
}
.icon-desc .opt{
position: absolute;
bottom: 0;
height: 18px;
width: 100%;
}
.install-status-0 .icon-desc .opt{
height: 100%;
}
.icon-desc .install-btn,
.icon-desc .uninstall-btn,
.icon-desc .update-btn{
background: #fff;
color:#333;
cursor:pointer;
text-align: center;
font-size: 13px;
padding-bottom: 5px;
margin-left: 10px;
margin-right: 10px;
display: block;
width: 100%;
height: 18px;
border-radius: 0px 0px 5px 5px;
border: 0px;
position: absolute;
bottom: 0;
left: -10px;
}
.icon-desc .uninstall-btn{
display: none;
}
.icon-desc .update-btn{
display: none;
border-radius: 0px 0px 0px 5px;
width:60%;
border-right: 1px solid #000;
}
.show-install-btn,
.show-uninstall-btn{
border: none;
background: #444;
color: #fff;
padding: 10px 20px;
border-radius: 5px 5px 0px 0px;
}
.active{
background: #444f53;
}
.install-status-1 .uninstall-btn{
display: block;
}
.install-status-1 .install-btn{
display: none;
}
.update-btn{
display: none;
}
.install-status-1 .update-btn{
display: none;
}
.install-status-4 .uninstall-btn{
display: block;
}
.install-status-4 .install-btn{
display: none;
}
.install-status-4 .update-btn{
display: none;
}
.install-status-2 .uninstall-btn{
display: block;
width: 40%;
border-radius: 0px 0px 5px 0px;
right: -10px;
left: auto;
border-left: 1px solid #000;
}
.install-status-2 .install-btn{
display: none;
}
.install-status-2 .update-btn{
display: block;
}
.install-status-1{
display: none;
}
.install-status-2{
display: none;
}
.install-status-0{
display: block;
}
.install-status-4{
display: none;
}
.install-view .install-status-1{
display: block;
}
.install-view .install-status-2{
display: block;
}
.install-view .install-status-0{
display: none;
}
.install-view .install-status-4{
display: block;
}
.cloud_main_radius h2 { border-bottom:1px #AAA dashed;}
.cloud_main_radius h3,
.cloud_main_radius h4 { font-size:12px;color:#FC0;font-weight:normal;font-style: normal;}
.cloud_main_radius h5 { color:#FFF;font-weight:normal;font-style: normal;}
</style>
<script>
var db_softcenter_ = {};
//set tabstop=4 set shiftwidth=4 set expandtab
String.prototype.format = String.prototype.f = function() {
var s = this,
i = arguments.length;
while (i--) {
s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]);
}
return s;
};
function formatString(s, args) {
i = args.length;
while (i--) {
s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), args[i]);
}
return s;
}
String.prototype.endsWith = function (suffix) {
return (this.substr(this.length - suffix.length) === suffix);
}
String.prototype.startsWith = function(prefix) {
return (this.substr(0, prefix.length) === prefix);
}
String.prototype.capitalizeFirstLetter = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
function checkField(o, f, d) {
if(typeof o[f] == "undefined") {
o[f] = d;
}
return o[f];
}
function appPostScript(moduleInfo, script) {
if(currState.installing) {
console.log("current is in installing state");
return;
}
//Current page must has prefix of "Module_"
var data = {"SystemCmd":script, "current_page":"Module_koolnet.asp", "action_mode":" Refresh ", "action_script":""};
var applyUrl = "applydb.cgi?p=softcenter_";
//currState.name = moduleInfo.name;
//TODO auto choose for home_url
data["softcenter_home_url"] = "http://sc.paldier.com";
data["softcenter_installing_todo"] = moduleInfo.name;
if(script == "ks_app_install.sh") {
data["softcenter_installing_tar_url"] = moduleInfo.tar_url;
data["softcenter_installing_md5"] = moduleInfo.md5;
data["softcenter_installing_version"] = moduleInfo.version;
//Update title for this module
data[moduleInfo.name + "_title"] = moduleInfo.title;
applyUrl = applyUrl + "," + moduleInfo.name;
}
$.ajax({
type: "POST",
url: applyUrl,
dataType: "text",
data: data,
success: function() {
var d = new Date();
//持续更新
currState.lastChangeTick = d/1000 + TIMEOUT_SECONDS;
currState.installing = true;
showInstallStatus(true);
},
error: function() {
currState.installing = false;
console.log("install error");
}
});
}
function appInstallModule(moduleInfo) {
appPostScript(moduleInfo, "ks_app_install.sh");
}
function appUninstallModule(moduleInfo) {
if (!window.confirm('确定卸载吗')) {
return;
}
appPostScript(moduleInfo, "ks_app_remove.sh");
}
</script>
<script>
//TODO auto detect home url
db_softcenter_["softcenter_home_url"] = "sc.paldier.com";
// 安装信息更新策略:
// 当软件安装的时候,安装进程内部会有超时时间. 超过超时时间 没安装成功,则认为失败.
// 但是路由内部的绝对时间与浏览器上的时间可能不同步,所以无法使用路由器内的时间. 浏览器的策略是,
// 安装的时候会有一个同样的计时,若这个超时时间内,安装状态有变化,则更新安装状态.从而可以实时更新安装进程.
var currState = {"installing": false, "lastChangeTick": 0, "lastStatus": "-1", "module":""};
var TIMEOUT_SECONDS = 18;
// TODO 如何避免实用全局变量?
var softInfo = null;
function initInstallStatus() {
var o = db_softcenter_;
var base = "softcenter_installing_";
if(o[base+"status"]) {
//状态不是0/1/7,则当前正处于安装状态,实时更新安装信息
if((o[base+"status"] != "0") && (o[base+"status"] != "1") && (o[base+"status"] != "7")) {
var d = new Date();
currState.lastChangeTick = d/1000 + TIMEOUT_SECONDS;
currState.lastStatus = o[base+"status"];
currState.installing = true;
//currState.name = o[base+"module"];
showInstallStatus(true);
}
}
}
function showInstallStatus(isInit) {
$.ajax({
type: "get",
url: "dbconf?p=softcenter_installing_",
dataType: "script",
success: function(xhr) {
var o = db_softcenter_installing_;
var base = "softcenter_installing_";
console.log("status: " + o[base+"status"]);
if(isInit) {
currState.lastStatus = o[base+"status"];
}
var d = new Date();
var curr = d.getTime()/1000;
curr_module = checkField(o, "softcenter_installing_module", "");
if(o[base+"status"] != currState.lastStatus) {
currState.lastStatus = o[base+"status"];
showInstallInfo(curr_module, currState.lastStatus);
// Install ok now
if(currState.lastStatus == "1" || currState.lastStatus == "7") {
currState.installing = false;
setTimeout("window.location.reload()", 1000);
return;
} else if(currState.lastStatus == "0") {
currState.installing = false;
}
}
if(currState.lastChangeTick > curr) {
setTimeout("showInstallStatus()", 1500);
} else {
currState.installing = false;
$("#appInstallInfo").html("等待超时,可尝试手动刷新");
//showInstallInfo("", currState.lastStatus);
}
}
})
}
function showInstallInfo(module, scode) {
var code = parseInt(scode);
var s = module.capitalizeFirstLetter();
var infos = [
"操作失败",
"已安装",
"将被安装到jffs分区...",
"正在下载中...请耐心等待...",
"正在安装中...",
"安装成功请5秒后刷新本页面...",
"卸载中......",
"卸载成功!",
"没有检测到在线版本号!",
"正在下载更新......",
"正在安装更新...",
"安装更新成功5秒后刷新本页 ",
"下载文件校验不一致!",
"然而并没有更新!",
"正在检查是否有更新~",
"检测更新错误!"
];
document.getElementById("install_status").style.display = "";
$("#appInstallInfo").html(s + infos[code]);
}
//切换安装未安装面板
function toggleAppPanel(showInstall) {
$('.show-install-btn').removeClass('active');
$('.show-uninstall-btn').removeClass('active');
$(showInstall ? '.show-install-btn' : '.show-uninstall-btn').addClass('active');
$('#IconContainer')[showInstall ? 'addClass' : 'removeClass']('install-view');
}
/**
* 渲染apps安装和未安装按照class hook进行显示隐藏存在同一个面板中
*/
function renderView(apps) {
// set apps to global variable of softInfo
softInfo = apps;
//console.log(softInfo);
//简单模板函数
function _format(source, opts) {
var source = source.valueOf(),
data = Array.prototype.slice.call(arguments, 1),
toString = Object.prototype.toString;
if(data.length){
data = data.length == 1 ?
(opts !== null && (/\[object Array\]|\[object Object\]/.test(toString.call(opts))) ? opts : data)
: data;
return source.replace(/#\{(.+?)\}/g, function (match, key){
var replacer = data[key];
// chrome 下 typeof /a/ == 'function'
if('[object Function]' == toString.call(replacer)){
replacer = replacer(key);
}
return ('undefined' == typeof replacer ? '' : replacer);
});
}
return source;
}
//app 模板
var tpl = ['',
'<dl class="icon install-status-#{install}" data-name="#{name}">',
'<dd class="icon-pic">',
//当图标娶不到的时候,使用默认图标,如果已经是默认图标且娶不到,就狗带了,不管
'<img src="#{icon}" onerror="this.src.indexOf(\'icon-default.png\')===-1 && (this.src=\'/res/icon-default.png\');" alt="图标出走了~"/>',
'<img class="update-btn" style="position: absolute;width:20px;height:20px;margin-top:-66px;margin-left:44px;" src="/res/upgrade.png"',
'</dd>',
'<dt class="icon-title">#{title}</dt>',
'<dd class="icon-desc">',
'<a class="text" href="/#{home_url}" #{target}>',
'#{description}',
'</a>',
'<div class="opt">',
'<a type="button" class="install-btn" data-name="#{name}">安装</a>',
'<a type="button" class="update-btn" data-name="#{name}">更新</a>',
'<a type="button" class="uninstall-btn" data-name="#{name}">卸载</a>',
'</div>',
'</dd>',
'</dl>'
].join('');
var installCount = 0;
var uninstallCount = 0;
var html = $.map(apps, function (app, name) {
parseInt(app.install, 10) ? installCount++ : uninstallCount++;
return _format(tpl, app);
});
$('#IconContainer').html(html.join(''));
//更新安装数
$('.show-install-btn').val('已安装(' + installCount + ')');
$('.show-uninstall-btn').val('未安装(' + uninstallCount + ')');
}
var syncRemoteSuccess = 0; //判断是否进入页面后已经成功进行远端同步
function getRemoteData() {
var remoteURL = db_softcenter_["softcenter_home_url"] + '/softcenter/app.json.js';
return $.ajax({
url: remoteURL,
method: 'GET',
dataType: 'jsonp',
timeout: 5000
});
}
function softceterInitData(data) {
var remoteData = data;
$("#spnOnlineVersion").html(remoteData.version);
if(remoteData.version != db_softcenter_["softcenter_version"]) {
$("#updateBtn").show();
$("#updateBtn").click(function () {
var moduleInfo = {
"name":"softcenter",
"md5": remoteData.md5,
"tar_url": remoteData.tar_url,
"version": remoteData.version
};
appPostScript(moduleInfo, "ks_app_install.sh");
});
}
}
function init(cb) {
//设置默认值
function _setDefault(source, defaults) {
$.map(defaults, function (value, key) {
if (!source[key]) {
source[key] = value;
}
});
}
//把本地数据平面化转换成以app为对象
function _formatLocalData(localData) {
var result = {};
$.map(db_softcenter_, function (item, key) {
key = key.split('_');
if ('module' === key[1]) {
var name = key[2];
var prop = key.slice(3).join("_");
if (!result[name]) {
result[name] = {};
result[name].name = name;
}
if (prop) {
result[name][prop] = item;
}
}
});
return result;
}
//将本地和远程进行一次对比合并
function _mergeData(remoteData) {
var result = {};
var localData = _formatLocalData(db_softcenter_);
$.each(remoteData, function (i, app) {
var name = app.name;
var oldApp = localData[name] || {};
var install = (parseInt(oldApp.install, 10) === 1 && app.version !== oldApp.version) ? 2 : oldApp.install || "0";
result[name] = $.extend(oldApp, app);
result[name].install = install;
});
$.map(localData, function (app, name) {
if (!result[name]) {
result[name] = app;
}
});
//设置默认值和设置icon的路径
$.map(result, function (item, name) {
_setDefault(item, {
home_url: "Module_" + name + ".asp",
title: name.capitalizeFirstLetter(),
tar_url: "{0}/{0}.tar.gz".format(name),
install: "0",
description: "暂无",
new_version: false
});
// icon 规则:
// 如果已安装的插件,那图标必定在 /koolshare/res 目录, 通过 /res/icon-{name}.png 请求路径得到图标
// 如果是未安装的插件,则必定在 http://sc.paldier.com/{name}/{name}/icon-{name}.png
// TODO 如果因为一些错误导致没有图标, 有可能显示一张默认图标吗?
item.icon = parseInt(item.install, 10) !== 0
? ('/res/icon-' + item.name + '.png')
: ('http://sc.paldier.com' + new Array(3).join('/softcenter') + '/res/icon-' + item.name + '.png');
});
return result;
};
if (syncRemoteSuccess) {
cb();
return;
} else {
getRemoteData()
.done(function (remoteData) {
//远端更新成功
syncRemoteSuccess = 1;
softceterInitData(remoteData);
remoteData = remoteData.apps || [];
renderView(_mergeData(remoteData));
cb();
})
.fail(function () {
//如果没有更新成功比如没网络就用空数据merge本地
renderView(_mergeData({}));
cb();
});
}
notice_show();
}
//初始化整个界面展现,包括安装未安装的获取
//当初始化过程获取软件列表失败时候,用本地的模块进行渲染
//只要一次获取成功,以后不在重新获取,知道页面刷新重入
$(function () {
//梅林要求用这个函数来显示左测菜单
show_menu(menu_hook);
if(!db_softcenter_["softcenter_version"]) {
db_softcenter_["softcenter_version"] = "0.0";
}
$("#spnCurrVersion").html(db_softcenter_["softcenter_version"]);
init(function () {
toggleAppPanel(1);
//一刷新界面是否就正在插件在安装.
initInstallStatus();
});
//挂接tab切换安装状态事件
$('.show-install-btn').click(function () {
init(function () {
toggleAppPanel(1);
});
});
$('.show-uninstall-btn').click(function () {
init(function () {
toggleAppPanel(0);
});
});
//挂接安装或者卸载事件
$('#IconContainer').on('click', '.install-btn', function () {
var name = $(this).data('name');
console.log('install', name);
appInstallModule(softInfo[name]);
});
$('#IconContainer').on('click', '.uninstall-btn', function () {
var name = $(this).data('name');
console.log('uninstall', name);
appUninstallModule(softInfo[name]);
});
$('#IconContainer').on('click', '.update-btn', function () {
var name = $(this).data('name');
console.log('update', name);
appInstallModule(softInfo[name]);
});
});
function menu_hook() {
tabtitle[tabtitle.length -1] = new Array("", "软件中心", "离线安装");
tablink[tablink.length -1] = new Array("", "Main_Soft_center.asp", "Main_Soft_setting.asp");
}
function notice_show(){
$.ajax({
url: 'https://sc.paldier.com/softcenter/push_message.json.js',
type: 'GET',
dataType: 'jsonp',
success: function(res) {
$("#push_titile").html(res.title);
$("#push_content1").html(res.content1);
$("#push_content2").html(res.content2);
if(res.content3){
document.getElementById("push_content3_li").style.display = "";
$("#push_content3").html(res.content3);
}
if(res.content4){
document.getElementById("push_content4_li").style.display = "";
$("#push_content4").html(res.content4);
}
}
});
}
</script>
</head>
<body>
<div id="TopBanner"></div>
<div id="Loading" class="popup_bg"></div>
<input type="hidden" name="preferred_lang" id="preferred_lang" value="<% nvram_get("preferred_lang"); %>"/>
<input type="hidden" name="current_page" value="Main_Soft_center.asp">
<input type="hidden" name="next_page" value="Main_Soft_center.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="8">
<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="firmver" value="<% nvram_get("firmver"); %>">
<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">
<div>
<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 class="formfonttitle">Software Center</div>
<div style="margin-left:5px;margin-top:5px;margin-bottom:5px"><img src="/images/New_ui/export/line_export.png"></div>
<table width="100%" border="1" align="center" cellpadding="4" cellspacing="0" bordercolor="#6b8fa3" class="FormTable" >
</table>
<table width="100%" height="150px" style="border-collapse:collapse;">
<tr bgcolor="#444f53">
<td colspan="5" bgcolor="#444f53" class="cloud_main_radius">
<div style="padding:10px;width:95%;font-style:italic;font-size:14px;">
<br/><br/>
<table width="100%" >
<tr>
<td>
<ul style="margin-top:-50px;padding-left:15px;" >
<li style="margin-top:-5px;">
<h2 id="push_titile"><em>欢迎</em></h2>
</li>
<li style="margin-top:-5px;">
<h4 id="push_content1" >欢迎来到插件中心,目前正在紧张开发中,各种插件酝酿中!</h4>
</li>
<li style="margin-top:-5px;">
<h4 id="push_content2">如果你想加入我们的工作,在 <a href="http://www.koolshare.cn" target="_blank"> <i><u>www.koolshare.cn</u></i> </a>联系我们!</h4>
</li>
<li id="push_content3_li" style="margin-top:-5px;display: none;">
<h4 id="push_content3"></h4>
</li>
<li id="push_content4_li" style="margin-top:-5px;display: none;">
<h4 id="push_content4"></h4>
</li>
<li style="margin-top:-5px;">
<h5>当前版本:<span id="spnCurrVersion"></span> 在线版本:<span id="spnOnlineVersion"></span>
<input type="button" id="updateBtn" value="更新" style="display:none" /></h5>
</li>
</ul>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr height="10px">
<td colspan="3"></td>
</tr>
<tr bgcolor="#444f53" id="install_status" style="display: none;" width="235px">
<td>
<div style="padding:10px;width:95%;font-size:14px;" id="appInstallInfo">
</div>
</td>
<td class="cloud_main_radius_right">
</td>
</tr>
<tr height="10px">
<td colspan="3"></td>
</tr>
<tr width="235px">
<td colspan="4" cellpadding="0" cellspacing="0" style="padding:0">
<input class="show-install-btn" type="button" value="已安装"/>
<input class="show-uninstall-btn" type="button" value="未安装"/>
</td>
</tr>
<tr bgcolor="#444f53" width="235px">
<td colspan="4" id="IconContainer">
<div id="software_center_message" style="text-align:center; line-height: 4em;">更新中...</div>
</td>
</tr>
<tr height="10px">
<td colspan="3"></td>
</tr>
</table>
<div class="KoolshareBottom">论坛技术支持: <a href="http://www.koolshare.cn" target="_blank"> <i><u>www.koolshare.cn</u></i> </a>
<br/>Github项目 <a href="https://github.com/koolshare/koolshare.github.io" target="_blank"> <i><u>github.com/koolshare</u></i> </a>
<br/>Powered by <i>koolshare开发组</i>
<br/>修改版 by <i>paldier</i>
</div>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</td>
<td width="10" align="center" valign="top"></td>
</tr>
</table>
<div id="footer"></div>
</body>
</html>

View File

@ -0,0 +1,257 @@
<!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 type="text/javascript" src="/dbconf?p=adm_&v=<% uptime(); %>"></script>
<script type="text/javascript" src="/res/softcenter.js"></script>
<script language="JavaScript" type="text/javascript" src="/client_function.js"></script>
<script>
function init(menu_hook) {
show_menu();
}
function onSubmitCtrl(o, s) {
document.form.action_mode.value = s;
showLoading(7);
document.form.submit();
}
function conf2obj(){
$j.ajax({
type: "get",
url: "dbconf?p=adm_",
dataType: "script",
success: function(xhr) {
var p = "adm_";
var params = ["user_txt"];
for (var i = 0; i < params.length; i++) {
if (typeof db_adm_[p + params[i]] !== "undefined") {
$j("#adm_"+params[i]).val(db_adm_[p + params[i]]);
}
}
}
});
}
function reload_Soft_Center(){
location.href = "/Main_Soft_center.asp";
}
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("", "软件中心", "离线安装");
tablink[tablink.length -1] = new Array("", "Main_Soft_center.asp", "Main_Soft_setting.asp");
}
function upload_software() {
var fullPath = document.getElementById('ss_file').value;
if(!fullPath) {
return;
}
document.getElementById('file_info').style.display = "none";
document.getElementById('loadingicon').style.display = "block";
var startIndex = (fullPath.indexOf('\\') >= 0 ? fullPath.lastIndexOf('\\') : fullPath.lastIndexOf('/'));
var filename = fullPath.substring(startIndex);
if (filename.indexOf('\\') === 0 || filename.indexOf('/') === 0) {
filename = filename.substring(1);
}
document.form.soft_name.value = filename;
document.form.enctype = "multipart/form-data";
document.form.encoding = "multipart/form-data";
document.form.action="ssupload.cgi?a=/tmp/"+filename;
document.form.submit();
}
function upload_ok(isok) {
var info = $G('file_info');
if(isok==1){
info.innerHTML="上传完成";
checkCmdRet();
setTimeout("start_install();", 1000);
} else {
info.innerHTML="上传失败";
}
info.style.display = "block";
$G('loadingicon').style.display = "none";
}
function start_install() {
document.form.action_mode.value = ' Refresh ';
document.form.action = "/applydb.cgi?p=soft";
document.form.SystemCmd.value = "ks_tar_intall.sh";
document.form.enctype = "";
document.form.encoding = "";
document.form.submit();
}
var _responseLen;
var noChange = 0;
function checkCmdRet(){
$j.ajax({
url: '/cmdRet_check.htm',
dataType: 'html',
error: function(xhr){
setTimeout("checkCmdRet();", 1000);
},
success: function(response){
var retArea = $G("log_content1");
if(response.search("XU6J03M6") != -1){
retArea.value = response.replace("XU6J03M6", " ");
//retArea.scrollTop = retArea.scrollHeight - retArea.clientHeight;
retArea.scrollTop = retArea.scrollHeight;
//return false;
}
if(_responseLen == response.length){
noChange++;
}else{
noChange = 0;
}
if(noChange > 20){
//retArea.scrollTop = retArea.scrollHeight;
//setTimeout("checkCmdRet();", 2000);
return false;
}else{
setTimeout("checkCmdRet();", 500);
}
retArea.value = response;
//retArea.scrollTop = retArea.scrollHeight - retArea.clientHeight;
retArea.scrollTop = retArea.scrollHeight;
_responseLen = response.length;
}
});
}
</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=adm_" target="hidden_frame">
<input type="hidden" name="current_page" value="Module_adm_.asp"/>
<input type="hidden" name="next_page" value="Module_adm_.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=""/>
<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="adm_config.sh"/>
<input type="hidden" name="firmver" value="<% nvram_get("firmver"); %>"/>
<input type="hidden" id="soft_name" name="soft_name" value=""/>
<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" style="padding-top:5px;margin-top:0px;float: left;" id="cmdDesc"></div>
<div style="padding-top:5px;margin-top:0px;float: left;" id="NoteBox" >
<li>此页面功能需要在7.0及其以上的固件才能使用。 </li>
<li>通过本页面,你可以上传插件的离线安装包来安装插件; </li>
<li>离线安装会自动解压tar.gz后缀的压缩包识别压缩包一级目录下的install.sh文件并执行 </li>
<li>建议开发者将插件版本号md5等信息在install.sh文件内进行写入 </li>
<li>此页面也能用来安装SS离线安装包方便用户进行回滚操作上传前需要将历史文件包改名为shadowsocks.tar.gz建议安装时关闭SS安装后需要重新提交才能看到安装的版本号 </li>
</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="routing_table">
<thead>
<tr>
<td colspan="2">软件中心 - 高级设置</td>
</tr>
</thead>
<tr>
<th>安装包版本号</th>
<td>
<input type="text" maxlength="64" id="soft_install_version" name="soft_install_version" value="" class="input_ss_table" style="width:160px;float:left;" autocomplete="off" autocorrect="off" autocapitalize="off"></input>
</td>
</tr>
<tr>
<th><a class="hintstyle" href="javascript:void(0);" onclick="openssHint(24)">离线安装插件</a></th>
<td>
<input type="button" id="upload_btn" class="button_gen" onclick="upload_software();" value="上传并安装">
<input style="color:#FFCC00;*color:#000;width: 200px;" id="ss_file" type="file" name="file">
<img id="loadingicon" style="margin-left:5px;margin-right:5px;display:none;" src="/images/InternetScan.gif">
<span id="file_info" style="display:none;">完成</span>
</td>
</tr>
</table>
<div id="log_content" style="margin-top:10px;display: block;">
<textarea cols="63" rows="15" wrap="off" readonly="readonly" id="log_content1" style="width:99%; font-family:'Courier New', Courier, mono; font-size:11px;background:#475A5F;color:#FFFFFF;"></textarea>
</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>Sadoneli</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>

127
softcenter/tests/test_app.sh Executable file
View File

@ -0,0 +1,127 @@
#!/bin/sh
#dbus set softcenter_home_url="https://github.com/koolshare/koolshare.github.io/blob/acelan_softcenter_ui"
#dbus set softcenter_home_url="https://raw.githubusercontent.com/koolshare/koolshare.github.io/acelan_softcenter_ui"
dbus set softcenter_home_url="http://koolshare.ngrok.wang:5000"
#test001, normal installing
dbus remove adm_version
dbus remove adm_md5
#export softcenter_installing_module
#export softcenter_installing_tick
export softcenter_installing_todo=adm
export softcenter_installing_version=0.5
export softcenter_installing_md5=a9148835ab402d8f1ba920aea40011a3
export softcenter_installing_tar_url="adm/adm.tar.gz"
dbus save softcenter_installing
sh /koolshare/scripts/app_install.sh
rlt=`dbus get softcenter_installing_status`
if [ "$rlt" != "1" ]; then
echo "test001 failed"
exit
fi
#test002, normal udpating
dbus set adm_version=0.4
#export softcenter_installing_module
#export softcenter_installing_tick
export softcenter_installing_todo=adm
export softcenter_installing_version=0.5
export softcenter_installing_md5=a9148835ab402d8f1ba920aea40011a3
export softcenter_installing_tar_url="adm/adm.tar.gz"
dbus save softcenter_installing
sh /koolshare/scripts/app_install.sh
rlt=`dbus get softcenter_installing_status`
if [ "$rlt" != "1" ]; then
echo "test002 failed"
exit
fi
#test003, prefix exists but timeout
dbus set adm_version=0.4
export softcenter_installing_module=shadowvpn
export softcenter_installing_tick=10000
export softcenter_installing_todo=adm
export softcenter_installing_version=0.5
export softcenter_installing_md5=a9148835ab402d8f1ba920aea40011a3
export softcenter_installing_tar_url="adm/adm.tar.gz"
dbus save softcenter_installing
sh /koolshare/scripts/app_install.sh
rlt=`dbus get softcenter_installing_status`
if [ "$rlt" != "1" ]; then
echo "test003 failed"
exit
fi
#test004, the newest version
dbus set adm_version=0.5
#export softcenter_installing_module=shadowvpn
#export softcenter_installing_tick=10000
export softcenter_installing_todo=adm
export softcenter_installing_version=0.5
export softcenter_installing_md5=a9148835ab402d8f1ba920aea40011a3
export softcenter_installing_tar_url="adm/adm.tar.gz"
dbus save softcenter_installing
sh /koolshare/scripts/app_install.sh
rlt=`dbus get softcenter_installing_status`
if [ "$rlt" == "1" ]; then
echo "test004 failed"
exit
fi
#test005, prefix installing exits and not timeout
dbus set adm_version=0.4
export softcenter_installing_module=shadowvpn
export softcenter_installing_tick=`date +%s`
export softcenter_installing_todo=adm
export softcenter_installing_version=0.5
export softcenter_installing_md5=a9148835ab402d8f1ba920aea40011a3
export softcenter_installing_tar_url="adm/adm.tar.gz"
dbus save softcenter_installing
sh /koolshare/scripts/app_install.sh
rlt=`dbus get softcenter_installing_status`
if [ "$rlt" == "1" ]; then
echo "test005 failed"
exit
fi
#test006, home_url timeout
dbus set softcenter_home_url="http://koolshare.ngrok.wang:50000"
dbus set adm_version=0.4
export softcenter_installing_module=
export softcenter_installing_tick=
export softcenter_installing_todo=adm
export softcenter_installing_version=0.5
export softcenter_installing_md5=a9148835ab402d8f1ba920aea40011a3
export softcenter_installing_tar_url="adm/adm.tar.gz"
dbus save softcenter_installing
sh /koolshare/scripts/app_install.sh
rlt=`dbus get softcenter_installing_status`
echo "result $rlt"
if [ "$rlt" == "1" ]; then
echo "test006 failed"
exit
fi

View File

@ -0,0 +1,26 @@
#!/bin/sh
#dbus set softcenter_home_url="https://github.com/koolshare/koolshare.github.io/blob/acelan_softcenter_ui"
#dbus set softcenter_home_url="https://raw.githubusercontent.com/koolshare/koolshare.github.io/acelan_softcenter_ui"
dbus set softcenter_home_url="http://koolshare.ngrok.wang:5000"
#test001, normal installing
#dbus remove adm_version
#dbus remove adm_md5
#export softcenter_installing_module
#export softcenter_installing_tick
export softcenter_installing_todo=adm
export softcenter_installing_version=0.5
export softcenter_installing_md5=153ca93835ad7ac6a8fecd55f5b9bac5
export softcenter_installing_tar_url="adm/adm.tar.gz"
dbus save softcenter_installing
sh /koolshare/scripts/ks_app_install.sh
rlt=`dbus get softcenter_installing_status`
if [ "$rlt" != "1" ]; then
echo "test001 failed"
exit
fi

View File

@ -0,0 +1,6 @@
#!/bin/sh
dbus set softcenter_home_url="http://koolshare.ngrok.wang:5000"
dbus set softcenter_installing_todo=adm
sh /koolshare/scripts/app_remove.sh

2
softcenter/version Normal file
View File

@ -0,0 +1,2 @@
1.1.6
3242715f2a71bec3ffc70252f92c977b