代码拉取完成,页面将自动刷新
con importUtil = import("util")
con importPath = import("path")
con importConfig = import("config")
con isJson = importConfig.config.isJson
con wirteLogFile = importUtil.wirteLogFile
con versionLocal = function() {
con metaBin = importPath.pathMetaBin()
con versionFile = '{}/{}'.format(metaBin, 'version')
if (importUtil.guaFileExist(versionFile)) {
con c = 'cat {}'.format(versionFile)
con r = importUtil.call(c)
return importUtil.guaStringToInt(r)
} else {
return 0
}
}
con versionRemote = function() {
con c = 'curl -sL https://gitee.com/kuaibiancheng/store/raw/master/version'
con r = os.exec(c)
if (r.exitCode == 0) {
con output = r.output
var version = int(output)
return version
} else {
if (isJson) {
con m = "由于网络问题未检查更新"
wirteLogFile(m)
} else {
log('由于网络问题未检查更新')
}
return -1
}
}
con checkVersion = function() {
con l = versionLocal()
con r = versionRemote()
con isOldVersion = r > l
return isOldVersion
}
con replaceMeta = function() {
con pathTmp = '{}/tmp_repo'.format(importPath.pathHome())
con repoUrl = 'https://gitee.com/kuaibiancheng/store'
con commandGit = 'git clone --depth=1 {} {}'.format(repoUrl, pathTmp)
importUtil.call(commandGit)
con pathMetaBin = importPath.pathMetaBin()
con commandCp = 'cp -r {}/* {}'.format(pathTmp, pathMetaBin)
importUtil.call(commandCp)
updateGualang(pathTmp)
importUtil.guaFileRm(pathTmp)
}
con updateGualang = function(repoPath) {
con c1 = 'cp {}/gualang/* /usr/local/axe/meta'.format(repoPath)
con c2 = "chmod +x /usr/local/axe/meta/gualang"
importUtil.callWithoutOutput(c1)
importUtil.callWithoutOutput(c2)
}
con clear = function() {
con pathOutput = importPath.pathAsyncOutput()
importUtil.guaFileRm(pathOutput)
}
con updateStore = function() {
clear()
con isOldVersion = checkVersion()
if (isOldVersion) {
replaceMeta()
return true
} else {
return false
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。