mirror of
https://github.com/kenzok8/small-package
synced 2025-01-07 07:06:58 +08:00
update 2022-11-15 20:21:22
This commit is contained in:
parent
7842f18c33
commit
a9697e4e7d
@ -1,7 +1,7 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_VERSION:=1.0.0
|
||||
PKG_RELEASE:=20220626
|
||||
PKG_VERSION:=1.1.1
|
||||
PKG_RELEASE:=20221115
|
||||
PKG_MAINTAINER:=xiaobao <xiaobao@linkease.com>
|
||||
|
||||
LUCI_TITLE:=LuCI library for json form
|
||||
|
6
luci-lib-iform/root/www/luci-static/iform/1.1/index.js
Normal file
6
luci-lib-iform/root/www/luci-static/iform/1.1/index.js
Normal file
File diff suppressed because one or more lines are too long
1
luci-lib-iform/root/www/luci-static/iform/1.1/style.css
Normal file
1
luci-lib-iform/root/www/luci-static/iform/1.1/style.css
Normal file
@ -0,0 +1 @@
|
||||
[lock-scroll=true]{overflow:hidden!important}.software-log_shade[data-v-27cc98a0],.software-log_shade *[data-v-27cc98a0]{-webkit-box-sizing:border-box;-webkit-tap-highlight-color:transparent;box-sizing:border-box;word-wrap:break-word;outline:none}.software-log_shade[data-v-27cc98a0]{width:100%;height:100%;display:flex;flex-wrap:wrap;align-items:center;justify-content:center;position:fixed;inset:0;z-index:99999}.software-log_shade .software-log_shade__bg[data-v-27cc98a0]{position:fixed;inset:0;background:rgba(68,79,83,.94) none repeat scroll 0 0!important;background-position:0 0;background-size:cover;opacity:.94}.software-log_shade .software-log_shade__pannel[data-v-27cc98a0]{width:800px;min-width:800px;border-radius:10px;z-index:100;box-shadow:3px 3px 10px #000;background:rgba(0,0,0,.9);padding:10px}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-title[data-v-27cc98a0]{text-align:center;font-size:18px;color:#9f0;padding:10px;font-weight:700}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-now i[data-v-27cc98a0]{color:#fc0;font-style:normal}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content[data-v-27cc98a0]{padding:10px;width:100%;text-align:center;overflow:hidden;height:400px;overflow:overlay}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-27cc98a0]{width:100%;border:0px solid #222;font-family:Lucida Console;font-size:11px;background:transparent;color:#fff;outline:none;overflow-x:hidden;resize:none;transition:.5s}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-27cc98a0]:focus,.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-27cc98a0]:hover{box-shadow:none;border-color:#fff0!important}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-27cc98a0]::-webkit-scrollbar{width:5px;height:5px}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-27cc98a0]::-webkit-scrollbar-thumb{height:30px;outline:none;border:none;border-radius:1rem;background-color:#4c595c;-webkit-border-radius:1rem}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-content textarea[data-v-27cc98a0]::-webkit-scrollbar-track-piece{background:none;-webkit-border-radius:0;border-radius:0}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-btn[data-v-27cc98a0]{width:100%;display:flex;flex-wrap:wrap;align-items:center;justify-content:center}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-btn button[data-v-27cc98a0]{visibility:visible;min-width:88px;font-weight:bolder;text-shadow:1px 1px 0px black;border-radius:8px;height:33px;font-family:Verdana,Microsoft Yahei UI,sans-serif;font-size:12px;padding:0 .7em;width:auto;min-width:122px;margin:0 10px;cursor:pointer;background:#090a0a!important;border:1px solid #fff!important;color:#fff!important;opacity:1!important}.software-log_shade .software-log_shade__pannel .software-log_shade__pannel-btn button[data-v-27cc98a0]:hover{opacity:.9!important}.cbi-section .title{font-size:1.1rem;line-height:1;display:block;width:100%;margin:0;color:#32325d;padding:1rem 1.25rem}.cbi-page-actions{display:inline-block;width:100%}.loading[data-v-23d08f2c]{position:absolute;top:50%;left:50%;transform:translate(-50%);display:block;padding:20px;text-align:center}.loading--inline[data-v-23d08f2c]{display:inline-block;padding:0;vertical-align:middle}.loading__spinner[data-v-23d08f2c]{-webkit-animation:loading-rotator-23d08f2c 1.5s linear infinite;animation:loading-rotator-23d08f2c 1.5s linear infinite;height:35px;width:35px}.loading__path[data-v-23d08f2c]{-webkit-animation:loading-dash-23d08f2c 1.5s ease-in-out infinite;animation:loading-dash-23d08f2c 1.5s ease-in-out infinite;stroke:#5e72e4;stroke-dasharray:187;stroke-dashoffset:0;transform-origin:center}@-webkit-keyframes loading-rotator-23d08f2c{0%{transform:rotate(0)}to{transform:rotate(270deg)}}@keyframes loading-rotator-23d08f2c{0%{transform:rotate(0)}to{transform:rotate(270deg)}}@-webkit-keyframes loading-dash-23d08f2c{0%{stroke-dashoffset:187}50%{stroke-dashoffset:46.75;transform:rotate(135deg)}to{stroke-dashoffset:187;transform:rotate(450deg)}}@keyframes loading-dash-23d08f2c{0%{stroke-dashoffset:187}50%{stroke-dashoffset:46.75;transform:rotate(135deg)}to{stroke-dashoffset:187;transform:rotate(450deg)}}#app{font-family:Avenir,Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}
|
@ -6,7 +6,7 @@ START=95
|
||||
disable_gro() {
|
||||
which ethtool &>/dev/null || return 0
|
||||
for eth in $(ifconfig | grep "^eth\|^dsa" | awk '{print $1}' | sort | uniq); do
|
||||
ethtool -k eth0 | grep -q "generic-segmentation-offload: on" || {
|
||||
ethtool -k "$eth" | grep -q "generic-segmentation-offload: on" || {
|
||||
ethtool -K "$eth" gro off
|
||||
logger -t natfflow "disable gro for <$eth>"
|
||||
}
|
||||
|
16
openwrt-app-actions/applications/luci-app-systools/Makefile
Normal file
16
openwrt-app-actions/applications/luci-app-systools/Makefile
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_VERSION:=1.0.1
|
||||
PKG_RELEASE:=20221115
|
||||
|
||||
LUCI_TITLE:=LuCI support for SysTools
|
||||
LUCI_PKGARCH:=all
|
||||
LUCI_DEPENDS:=+docker +luci-lib-iform +luci-lib-taskd +speedtestcli
|
||||
LUCI_EXTRA_DEPENDS:=luci-lib-iform (>=1.1)
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
@ -0,0 +1,190 @@
|
||||
local util = require "luci.util"
|
||||
local http = require "luci.http"
|
||||
local lng = require "luci.i18n"
|
||||
local iform = require "luci.iform"
|
||||
local jsonc = require "luci.jsonc"
|
||||
|
||||
module("luci.controller.systools", package.seeall)
|
||||
|
||||
function index()
|
||||
|
||||
entry({"admin", "system", "systools"}, call("redirect_index"), _("System Convenient Tools"), 30).dependent = true
|
||||
entry({"admin", "system", "systools", "pages"}, call("systools_index")).leaf = true
|
||||
entry({"admin", "system", "systools", "form"}, call("systools_form"))
|
||||
entry({"admin", "system", "systools", "submit"}, call("systools_submit"))
|
||||
|
||||
end
|
||||
|
||||
local page_index = {"admin", "system", "systools", "pages"}
|
||||
|
||||
function redirect_index()
|
||||
http.redirect(luci.dispatcher.build_url(unpack(page_index)))
|
||||
end
|
||||
|
||||
function systools_index()
|
||||
luci.template.render("systools/main", {prefix=luci.dispatcher.build_url(unpack(page_index))})
|
||||
end
|
||||
|
||||
function systools_form()
|
||||
local error = ""
|
||||
local scope = ""
|
||||
local success = 0
|
||||
|
||||
local data, extra = get_data()
|
||||
local result = {
|
||||
data = data,
|
||||
schema = get_schema(data, extra)
|
||||
}
|
||||
local response = {
|
||||
error = error,
|
||||
scope = scope,
|
||||
success = success,
|
||||
result = result,
|
||||
}
|
||||
http.prepare_content("application/json")
|
||||
http.write_json(response)
|
||||
end
|
||||
|
||||
function get_schema(data, extra)
|
||||
local actions
|
||||
actions = {
|
||||
{
|
||||
name = "install",
|
||||
text = lng.translate("Execute"),
|
||||
type = "apply",
|
||||
},
|
||||
}
|
||||
local schema = {
|
||||
actions = actions,
|
||||
containers = get_containers(data, extra),
|
||||
description = lng.translate("Some convenient tools which can fix some errors."),
|
||||
title = lng.translate("System Convenient Tools")
|
||||
}
|
||||
return schema
|
||||
end
|
||||
|
||||
function get_containers(data, extra)
|
||||
local containers = {
|
||||
main_container(data, extra)
|
||||
}
|
||||
return containers
|
||||
end
|
||||
|
||||
function main_container(data, extra)
|
||||
local speedServerEnums = {}
|
||||
local speedServerNames = {}
|
||||
if data["tool"] == "speedtest" then
|
||||
speedServerEnums[#speedServerEnums+1] = "auto"
|
||||
speedServerNames[#speedServerNames+1] = "Auto Select"
|
||||
for key, val in pairs(extra.speedTestServers) do
|
||||
speedServerEnums[#speedServerEnums+1] = key
|
||||
speedServerNames[#speedServerNames+1] = val
|
||||
end
|
||||
end
|
||||
local main_c2 = {
|
||||
properties = {
|
||||
{
|
||||
name = "tool",
|
||||
required = true,
|
||||
title = "可执行操作",
|
||||
type = "string",
|
||||
enum = {"turn_off_ipv6", "reset_rom_pkgs", "qb_reset_password", "disk_power_mode", "speedtest"},
|
||||
enumNames = {
|
||||
lng.translate("Turn off IPv6"),
|
||||
lng.translate("Reset rom pkgs"),
|
||||
lng.translate("Reset qBittorrent Password"),
|
||||
lng.translate("HDD hibernation Status"),
|
||||
lng.translate("Run SpeedTest")
|
||||
}
|
||||
},
|
||||
{
|
||||
name = "speedTestServer",
|
||||
title = "Servers",
|
||||
type = "string",
|
||||
["ui:hidden"] = "{{rootValue.tool !== 'speedtest' }}",
|
||||
enum = speedServerEnums,
|
||||
enumNames = speedServerNames
|
||||
},
|
||||
},
|
||||
description = lng.translate("Select the action to run:"),
|
||||
title = lng.translate("Actions")
|
||||
}
|
||||
return main_c2
|
||||
end
|
||||
|
||||
function get_speedtest_servers()
|
||||
local vals = {}
|
||||
local f = io.popen("/usr/share/systools/speedtest-servers.run", "r")
|
||||
if f then
|
||||
local ret = f:read("*all")
|
||||
f:close()
|
||||
local obj = jsonc.parse(ret)
|
||||
if obj == nil then
|
||||
return vals
|
||||
end
|
||||
for _, val in pairs(obj["servers"]) do
|
||||
if type(val["name"]) == "number" then
|
||||
vals[tostring(val["id"])] = string.format("%s,%s", val["location"], val["country"])
|
||||
else
|
||||
vals[tostring(val["id"])] = string.format("%s,%s,%s", val["name"], val["location"], val["country"])
|
||||
end
|
||||
end
|
||||
end
|
||||
return vals
|
||||
end
|
||||
|
||||
function get_data()
|
||||
local tool = luci.http.formvalue("tool")
|
||||
local extra = {}
|
||||
if tool then
|
||||
if tool == "speedtest" then
|
||||
extra["speedTestServers"] = get_speedtest_servers()
|
||||
end
|
||||
else
|
||||
tool = "turn_off_ipv6"
|
||||
end
|
||||
local data = {
|
||||
tool = tool,
|
||||
speedTestServer = "auto"
|
||||
}
|
||||
return data, extra
|
||||
end
|
||||
|
||||
function systools_submit()
|
||||
local error = ""
|
||||
local scope = ""
|
||||
local success = 0
|
||||
local result
|
||||
|
||||
local content = http.content()
|
||||
local req = jsonc.parse(content)
|
||||
if req["$apply"] == "install" then
|
||||
result = install_execute_systools(req)
|
||||
end
|
||||
http.prepare_content("application/json")
|
||||
local resp = {
|
||||
error = error,
|
||||
scope = scope,
|
||||
success = success,
|
||||
result = result,
|
||||
}
|
||||
http.write_json(resp)
|
||||
end
|
||||
|
||||
function install_execute_systools(req)
|
||||
local cmd
|
||||
if req["tool"] == "speedtest" then
|
||||
cmd = string.format("/usr/libexec/istorec/systools.sh %s %s", req["tool"], req["speedTestServer"])
|
||||
else
|
||||
cmd = string.format("/usr/libexec/istorec/systools.sh %s", req["tool"])
|
||||
end
|
||||
cmd = "/etc/init.d/tasks task_add systools " .. luci.util.shellquote(cmd)
|
||||
os.execute(cmd .. " >/dev/null 2>&1")
|
||||
|
||||
local result = {
|
||||
async = true,
|
||||
async_state = "systools"
|
||||
}
|
||||
return result
|
||||
end
|
||||
|
@ -0,0 +1,40 @@
|
||||
<%+header%>
|
||||
|
||||
<%+tasks/embed%>
|
||||
|
||||
<script>
|
||||
(function(){
|
||||
})();
|
||||
</script>
|
||||
<div id="app">
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.IstoreosData = {};
|
||||
window.IstoreosFormConfig = {
|
||||
getApi:"/cgi-bin/luci/admin/system/systools/form/",
|
||||
submitApi:"/cgi-bin/luci/admin/system/systools/submit",
|
||||
logApi:"/cgi-bin/luci/admin/system/systools/log",
|
||||
getHook:function(resp){
|
||||
window.IstoreosData = resp.result.data;
|
||||
//console.log("resp=", resp.result.data);
|
||||
return resp;
|
||||
},
|
||||
onFormChange: function(changedField, val) {
|
||||
//console.log("changedField=", changedField, "formData=", val)
|
||||
if (changedField === "tool" &&
|
||||
val["tool"] == "speedtest" &&
|
||||
window.IstoreosData["tool"] !== val["tool"]) {
|
||||
window.istoreos.reloadFromGetApi(val, true)
|
||||
}
|
||||
},
|
||||
submitHook:function(params){
|
||||
//console.log(params);
|
||||
return params;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script type="module" crossorigin src="/luci-static/iform/1.1/index.js?v=<%=math.random(1,100000)%>"></script>
|
||||
<link rel="stylesheet" href="/luci-static/iform/1.1/style.css?v=<%=math.random(1,100000)%>">
|
||||
|
||||
<%+footer%>
|
@ -0,0 +1,30 @@
|
||||
msgid "System Convenient Tools"
|
||||
msgstr "系统便利工具"
|
||||
|
||||
msgid "Execute"
|
||||
msgstr "执行"
|
||||
|
||||
msgid "Some convenient tools which can fix some errors."
|
||||
msgstr "一些便利的工具集,方便修复一些问题。"
|
||||
|
||||
msgid "Reset rom pkgs"
|
||||
msgstr "修复系统软件"
|
||||
|
||||
msgid "Turn off IPv6"
|
||||
msgstr "关闭 IPv6"
|
||||
|
||||
msgid "Reset qBittorrent Password"
|
||||
msgstr "重置 qBittorrent 密码"
|
||||
|
||||
msgid "HDD hibernation Status"
|
||||
msgstr "查看硬盘休眠"
|
||||
|
||||
msgid "Run SpeedTest"
|
||||
msgstr "外网测速"
|
||||
|
||||
msgid "Select the action to run:"
|
||||
msgstr "选择执行的操作:"
|
||||
|
||||
msgid "Actions"
|
||||
msgstr "操作"
|
||||
|
@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
# Author Xiaobao(xiaobao@linkease.com)
|
||||
|
||||
ACTION=${1}
|
||||
shift 1
|
||||
|
||||
usage() {
|
||||
echo "usage: $0 sub-command"
|
||||
echo "where sub-command is one of:"
|
||||
echo " turn_off_ipv6 Disable IPv6"
|
||||
echo " reset_rom_pkgs Reset pkgs from rom"
|
||||
echo " qb_reset_password Reset qBitorent password"
|
||||
echo " disk_power_mode Show disk power status"
|
||||
echo " speedtest Start a speedtest"
|
||||
}
|
||||
|
||||
case ${ACTION} in
|
||||
"turn_off_ipv6")
|
||||
/usr/share/systools/turn_off_ipv6.run
|
||||
;;
|
||||
"reset_rom_pkgs")
|
||||
/usr/share/systools/reset_rom_pkgs.run
|
||||
;;
|
||||
"qb_reset_password")
|
||||
/usr/share/systools/qb_reset_password.run
|
||||
;;
|
||||
"disk_power_mode")
|
||||
/usr/share/systools/disk_power_mode.run
|
||||
;;
|
||||
"speedtest")
|
||||
/usr/share/systools/speedtest.run ${1}
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
#function-1:显示硬盘盘符+Lable+容量以及硬盘上电状态
|
||||
#function-2:通过echo -e转义与if...elif...else语句使其active呈现红色,standby呈现绿色,方便快速检视硬盘上电情况
|
||||
#function-3:原for循环语句中加入判断和循环计数方式,统计active和standby的数量
|
||||
#function-4:增加 if 嵌套语句判断除开 active 和 standby 之外状态的硬盘,并将其标记为 unknown
|
||||
#function-5:将unknown状态的硬盘列举出来(对for语句上瘾了……
|
||||
|
||||
dsk=`ls /dev/sd* | grep -Eo 'sd(a{2}|[a-z]+)$'`
|
||||
echo `date +%c`
|
||||
standby=0
|
||||
active=0
|
||||
unknown=0
|
||||
c=0
|
||||
|
||||
if readlink /proc/$$/fd/1 2>/dev/null | grep -qF /dev/ ; then
|
||||
highlight(){
|
||||
echo -e "$1 $2 \033[0m"
|
||||
}
|
||||
else
|
||||
highlight(){
|
||||
echo -e "$2"
|
||||
}
|
||||
fi
|
||||
|
||||
for i in $dsk;
|
||||
do
|
||||
echo -e "\n";
|
||||
echo -e "-----------------------";
|
||||
echo -n "/dev/$i : " ;
|
||||
stats=`smartctl -i -n standby /dev/$i|grep "mode"|awk '{print $4}' `;
|
||||
#echo $stats
|
||||
if [[ $stats == STANDBY ]]||[[ $stats == ACTIVE ]]||[[ $stats == IDLE_A ]]
|
||||
then
|
||||
for s in $stats;
|
||||
do
|
||||
if [ $s == STANDBY ]
|
||||
then
|
||||
highlight "\033[30;42m" " STANDBY "
|
||||
let standby=$standby+1
|
||||
else
|
||||
highlight "\033[37;41m" " ACTIVE "
|
||||
let active=$active+1
|
||||
fi
|
||||
done
|
||||
else
|
||||
highlight "\033[30;47m" " UNKNOWN "
|
||||
let unknown=$unknown+1
|
||||
for un in $i
|
||||
do
|
||||
list[c]=$un
|
||||
((c++))
|
||||
done
|
||||
fi
|
||||
echo `lsblk /dev/$i|grep "/srv/dev-disk-by-label-"|awk '{print $7}' `;
|
||||
echo `lsblk /dev/$i|grep "/srv/dev-disk-by-label-"|awk '{print $4}' `;
|
||||
done
|
||||
|
||||
echo -e "\n";
|
||||
highlight "\033[37;41m" "Active Disk in Total=$active ";
|
||||
highlight "\033[30;42m" "Standby Disk in Total=$standby ";
|
||||
highlight "\033[30;47m" "Unknown Disk in Total=$unknown ";
|
||||
#echo $c
|
||||
echo -e "Unknown Disk list: ";
|
||||
for((b=0;b<=$c;b++));
|
||||
do
|
||||
if [[ $b -lt $c ]]
|
||||
then
|
||||
echo ${list[b]}
|
||||
fi
|
||||
done
|
||||
echo -e "\n";
|
||||
exit
|
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete firewall.wxedge
|
||||
set firewall.wxedge=rule
|
||||
set firewall.wxedge.name="wxedge"
|
||||
set firewall.wxedge.target="ACCEPT"
|
||||
set firewall.wxedge.src="wan"
|
||||
set firewall.wxedge.dest_port="40000-65535"
|
||||
set firewall.wxedge.enabled="1"
|
||||
commit firewall
|
||||
EOF
|
||||
|
||||
/etc/init.d/firewall reload
|
||||
|
||||
echo "done"
|
@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
# @jjm2473
|
||||
|
||||
hosts() {
|
||||
cat <<-EOF
|
||||
api.themoviedb.org 13.35.67.86
|
||||
image.tmdb.org 104.16.61.155
|
||||
www.themoviedb.org 54.192.151.79
|
||||
EOF
|
||||
}
|
||||
|
||||
filter() {
|
||||
local EXISTED=`uci show dhcp | grep -E '^dhcp\.@domain\[\d+\]\.name=' | sed 's/.*=//g'"; s/'//g" | sort -u`
|
||||
if [ "x$EXISTED" = "x" ]; then
|
||||
cat
|
||||
else
|
||||
grep -vFwe "$EXISTED"
|
||||
fi
|
||||
}
|
||||
add_host() {
|
||||
[ "x$1" = "x" -o "x$2" = "x" ] && return
|
||||
echo "set $1 = $2"
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
add dhcp domain
|
||||
set dhcp.@domain[-1].name=$1
|
||||
set dhcp.@domain[-1].ip=$2
|
||||
EOF
|
||||
}
|
||||
add_hosts() {
|
||||
local line
|
||||
while read; do
|
||||
line="$REPLY"
|
||||
add_host $line
|
||||
done
|
||||
if [ -n "`uci changes dhcp`" ]; then
|
||||
echo "commit changes and reload dnsmasq"
|
||||
uci commit dhcp
|
||||
/etc/init.d/dnsmasq reload
|
||||
else
|
||||
echo "there is nothing to do"
|
||||
fi
|
||||
}
|
||||
|
||||
hosts | filter | add_hosts
|
||||
|
||||
echo "done"
|
@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
date
|
||||
|
||||
nslookup baidu.com
|
||||
|
||||
ping -c 4 baidu.com
|
||||
|
||||
curl -o /dev/null https://www.baidu.com/
|
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
profile=`uci get qbittorrent.main.profile`
|
||||
if [ -n "$profile" ]; then
|
||||
echo "qb profile: $profile"
|
||||
echo "stop qb"
|
||||
/etc/init.d/qbittorrent stop
|
||||
sleep 2
|
||||
echo "delete password"
|
||||
sed -i '/^WebUI\\Password_/d' "$profile/qBittorrent/config/qBittorrent.conf"
|
||||
echo "start qb"
|
||||
/etc/init.d/qbittorrent start
|
||||
else
|
||||
echo "profile not defined!"
|
||||
fi
|
||||
|
||||
echo "done"
|
@ -0,0 +1,64 @@
|
||||
#!/bin/sh
|
||||
|
||||
nonconf_files_of_pkg() {
|
||||
local pkgname="$1"
|
||||
if [ -s /rom/usr/lib/opkg/info/${pkgname}.conffiles ]; then
|
||||
grep -hvxFf /rom/usr/lib/opkg/info/${pkgname}.conffiles \
|
||||
/rom/usr/lib/opkg/info/${pkgname}.list
|
||||
else
|
||||
cat /rom/usr/lib/opkg/info/${pkgname}.list
|
||||
fi
|
||||
}
|
||||
|
||||
reset_pkg() {
|
||||
local pkgname="$1"
|
||||
local line
|
||||
local dep
|
||||
local deps
|
||||
echo "${pkgname}" | grep -q "^kmod-\
|
||||
^kernel$\
|
||||
^libc$\
|
||||
^libgcc1$\
|
||||
^libatomic1$\
|
||||
^busybox$\
|
||||
" && return
|
||||
if [ -f /rom/usr/lib/opkg/info/${pkgname}.control -a -e /overlay/upper/usr/lib/opkg/info/${pkgname}.control ]; then
|
||||
echo "reset ${pkgname}"
|
||||
if [ -f /rom/usr/lib/opkg/info/${pkgname}.list ]; then
|
||||
nonconf_files_of_pkg "${pkgname}" | while read; do
|
||||
line="$REPLY"
|
||||
rm -f "/overlay/upper/${line}"
|
||||
done
|
||||
rm -f /overlay/upper/usr/lib/opkg/info/${pkgname}.list
|
||||
fi
|
||||
deps=`grep '^Depends: ' /rom/usr/lib/opkg/info/${pkgname}.control | dd bs=1 skip=8 2>/dev/null | sed 's/,/ /g'`
|
||||
# avoid loop deps
|
||||
rm -f /overlay/upper/usr/lib/opkg/info/${pkgname}.control
|
||||
for dep in $deps ; do
|
||||
reset_pkg "$dep"
|
||||
done
|
||||
rm -f /overlay/upper/usr/lib/opkg/info/${pkgname}.*
|
||||
fi
|
||||
}
|
||||
|
||||
ls_all_rom_pkgs() {
|
||||
( cd /rom/usr/lib/opkg/info ; find . -maxdepth 1 -name '*.control' | sed -E 's#./(.*).control#\1#g' )
|
||||
}
|
||||
|
||||
reset_all_rom() {
|
||||
local line
|
||||
ls_all_rom_pkgs | while read; do
|
||||
line="$REPLY"
|
||||
reset_pkg "$line"
|
||||
done
|
||||
}
|
||||
|
||||
reset_all_rom
|
||||
|
||||
touch /overlay/upper/usr/lib/opkg/.upgrading
|
||||
|
||||
echo "done, please reboot, it will reboot in 10s"
|
||||
|
||||
sleep 10
|
||||
reboot
|
||||
|
@ -0,0 +1,34 @@
|
||||
#!/bin/sh
|
||||
|
||||
export PATH=/usr/bin:/sbin:/bin/usr/bin:/sbin:/bin
|
||||
export HOME=/root
|
||||
export GATEWAY_INTERFACE=
|
||||
export REMOTE_HOST=
|
||||
export REMOTE_ADDR=
|
||||
export SHLVL=
|
||||
export QUERY_STRING=
|
||||
export HTTP_USER_AGENT=
|
||||
export DOCUMENT_ROOT=
|
||||
export REMOTE_PORT=
|
||||
export HTTP_ACCEPT=
|
||||
export SCRIPT_FILENAME=
|
||||
export HTTP_HOST=
|
||||
export REQUEST_URI=
|
||||
export SERVER_SOFTWARE=
|
||||
export HTTP_CONNECTION=
|
||||
export HTTP_COOKIE=
|
||||
export HTTP_ACCEPT_LANGUAGE=
|
||||
export SERVER_PROTOCOL=
|
||||
export HTTP_ACCEPT_ENCODING=
|
||||
export PATH_INFO=
|
||||
export REDIRECT_STATUS=
|
||||
export REQUEST_METHOD=
|
||||
export SERVER_ADDR=
|
||||
export PWD=
|
||||
export SERVER_PORT=
|
||||
export SCRIPT_NAME=
|
||||
export SERVER_NAME=
|
||||
export TERM=screen-256color
|
||||
|
||||
/usr/bin/speedtest --format=json --accept-license --accept-gdpr --servers 2>/dev/null
|
||||
|
@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
|
||||
cd /root
|
||||
export HOME=/root
|
||||
SERVER=${1}
|
||||
|
||||
echo "run speedtest"
|
||||
if [ "$SERVER" == "auto" ]; then
|
||||
echo "yes"|/usr/bin/speedtest
|
||||
else
|
||||
echo "yes"|/usr/bin/speedtest -s $SERVER
|
||||
fi
|
||||
|
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "uci settings"
|
||||
|
||||
uci -q batch <<-EOF
|
||||
del dhcp.lan.ra
|
||||
del dhcp.lan.dhcpv6
|
||||
del dhcp.lan.ra_flags
|
||||
add_list dhcp.lan.ra_flags=none
|
||||
|
||||
set network.wan.ipv6='0'
|
||||
del dhcp.wan.ra_flags
|
||||
add_list dhcp.wan.ra_flags=none
|
||||
|
||||
set network.wan6.auto=0
|
||||
|
||||
set dhcp.@dnsmasq[0].filter_aaaa='1'
|
||||
|
||||
commit network
|
||||
commit dhcp
|
||||
EOF
|
||||
|
||||
echo "reload_config"
|
||||
reload_config
|
||||
echo -n "wait for device online"
|
||||
for i in `seq 10 -1 1`; do
|
||||
echo -n "."
|
||||
sleep 1
|
||||
done
|
||||
echo ""
|
||||
echo "done"
|
@ -2,12 +2,13 @@
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_VERSION:=1.0.6
|
||||
PKG_RELEASE:=20220626
|
||||
PKG_VERSION:=1.1.0
|
||||
PKG_RELEASE:=20221115
|
||||
|
||||
LUCI_TITLE:=LuCI support for ubuntu
|
||||
LUCI_PKGARCH:=all
|
||||
LUCI_DEPENDS:=+docker +luci-lib-iform
|
||||
LUCI_DEPENDS:=+docker +luci-lib-iform +luci-lib-taskd
|
||||
LUCI_EXTRA_DEPENDS:=luci-lib-iform (>=1.1)
|
||||
|
||||
define Package/luci-app-ubuntu/conffiles
|
||||
/etc/config/ubuntu
|
||||
|
@ -11,11 +11,9 @@ function index()
|
||||
entry({"admin", "services", "ubuntu", "pages"}, call("ubuntu_index")).leaf = true
|
||||
entry({"admin", "services", "ubuntu", "form"}, call("ubuntu_form"))
|
||||
entry({"admin", "services", "ubuntu", "submit"}, call("ubuntu_submit"))
|
||||
entry({"admin", "services", "ubuntu", "log"}, call("ubuntu_log"))
|
||||
|
||||
end
|
||||
|
||||
local const_log_end = "XU6J03M6"
|
||||
local appname = "ubuntu"
|
||||
local page_index = {"admin", "services", "ubuntu", "pages"}
|
||||
|
||||
@ -198,10 +196,6 @@ function ubuntu_submit()
|
||||
http.write_json(resp)
|
||||
end
|
||||
|
||||
function ubuntu_log()
|
||||
iform.response_log("/var/log/"..appname..".log")
|
||||
end
|
||||
|
||||
function install_upgrade_ubuntu(req)
|
||||
local password = req["password"]
|
||||
local port = req["port"]
|
||||
@ -217,15 +211,13 @@ function install_upgrade_ubuntu(req)
|
||||
uci:save(appname)
|
||||
uci:commit(appname)
|
||||
|
||||
-- local exec_cmd = string.format("start-stop-daemon -q -S -b -x /usr/share/ubuntu/install.sh -- %s", req["$apply"])
|
||||
-- os.execute(exec_cmd)
|
||||
local exec_cmd = string.format("/usr/share/ubuntu/install.sh %s", req["$apply"])
|
||||
iform.fork_exec(exec_cmd)
|
||||
local exec_cmd = string.format("/usr/libexec/istorec/ubuntu.sh %s", req["$apply"])
|
||||
exec_cmd = "/etc/init.d/tasks task_add ubuntu " .. luci.util.shellquote(exec_cmd)
|
||||
os.execute(exec_cmd .. " >/dev/null 2>&1")
|
||||
|
||||
local result = {
|
||||
async = true,
|
||||
exec = exec_cmd,
|
||||
async_state = req["$apply"]
|
||||
async_state = appname
|
||||
}
|
||||
return result
|
||||
end
|
||||
|
@ -1,5 +1,7 @@
|
||||
<%+header%>
|
||||
|
||||
<%+tasks/embed%>
|
||||
|
||||
<script>
|
||||
(function(){
|
||||
})();
|
||||
@ -23,12 +25,11 @@
|
||||
return resp;
|
||||
},
|
||||
submitHook:function(params){
|
||||
console.log(params);
|
||||
return params;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<script type="module" crossorigin src="/luci-static/iform/1.0/index.js?v=<%=math.random(1,100000)%>"></script>
|
||||
<link rel="stylesheet" href="/luci-static/iform/1.0/style.css?v=<%=math.random(1,100000)%>">
|
||||
<script type="module" crossorigin src="/luci-static/iform/1.1/index.js?v=<%=math.random(1,100000)%>"></script>
|
||||
<link rel="stylesheet" href="/luci-static/iform/1.1/style.css?v=<%=math.random(1,100000)%>">
|
||||
|
||||
<%+footer%>
|
||||
|
@ -0,0 +1,91 @@
|
||||
#!/bin/sh
|
||||
# Author Xiaobao(xiaobao@linkease.com)
|
||||
|
||||
ACTION=${1}
|
||||
shift 1
|
||||
|
||||
IMAGE_NAME=''
|
||||
# linkease/desktop-ubuntu-full-arm64:latest
|
||||
# linkease/desktop-ubuntu-standard-arm64:latest
|
||||
# linkease/desktop-ubuntu-full-amd64:latest
|
||||
# linkease/desktop-ubuntu-standard-amd64:latest
|
||||
|
||||
get_image() {
|
||||
local version=`uci get ubuntu.@ubuntu[0].version 2>/dev/null`
|
||||
|
||||
ARCH="arm64"
|
||||
if echo `uname -m` | grep -Eqi 'x86_64'; then
|
||||
ARCH='amd64'
|
||||
elif echo `uname -m` | grep -Eqi 'aarch64'; then
|
||||
ARCH='arm64'
|
||||
else
|
||||
ARCH='arm64'
|
||||
fi
|
||||
|
||||
IMAGE_NAME=linkease/desktop-ubuntu-${version}-${ARCH}:latest
|
||||
}
|
||||
|
||||
do_install() {
|
||||
local http_port=`uci get ubuntu.@ubuntu[0].port 2>/dev/null`
|
||||
local password=`uci get ubuntu.@ubuntu[0].password 2>/dev/null`
|
||||
[ -z $password ] || password="password"
|
||||
[ -z $http_port ] || http_port=6901
|
||||
|
||||
get_image
|
||||
echo "docker pull ${IMAGE_NAME}"
|
||||
docker pull ${IMAGE_NAME}
|
||||
docker rm -f ubuntu
|
||||
|
||||
local cmd="docker run --restart=unless-stopped -d \
|
||||
--dns=172.17.0.1 \
|
||||
-u=0:0 \
|
||||
--shm-size=512m \
|
||||
-p ${http_port}:6901 \
|
||||
-e VNC_PW=${password} \
|
||||
-e VNC_USE_HTTP=0 "
|
||||
|
||||
local tz="`cat /tmp/TZ`"
|
||||
[ -z "$tz" ] || cmd="$cmd -e TZ=$tz"
|
||||
|
||||
cmd="$cmd -v /mnt:/mnt"
|
||||
mountpoint -q /mnt && cmd="$cmd:rslave"
|
||||
cmd="$cmd --name ubuntu \"$IMAGE_NAME\""
|
||||
|
||||
echo "$cmd"
|
||||
eval "$cmd"
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "usage: $0 sub-command"
|
||||
echo "where sub-command is one of:"
|
||||
echo " install Install the ubuntu"
|
||||
echo " upgrade Upgrade the ubuntu"
|
||||
echo " rm/start/stop/restart Remove/Start/Stop/Restart the ubuntu"
|
||||
echo " status Ubuntu status"
|
||||
echo " port Ubuntu port"
|
||||
}
|
||||
|
||||
case ${ACTION} in
|
||||
"install")
|
||||
do_install
|
||||
;;
|
||||
"upgrade")
|
||||
do_install
|
||||
;;
|
||||
"rm")
|
||||
docker rm -f ubuntu
|
||||
;;
|
||||
"start" | "stop" | "restart")
|
||||
docker ${ACTION} ubuntu
|
||||
;;
|
||||
"status")
|
||||
docker ps --all -f 'name=ubuntu' --format '{{.State}}'
|
||||
;;
|
||||
"port")
|
||||
docker ps --all -f 'name=ubuntu' --format '{{.Ports}}' | grep -om1 '0.0.0.0:[0-9]*' | sed 's/0.0.0.0://'
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
@ -1,133 +0,0 @@
|
||||
#!/bin/sh
|
||||
# Author Xiaobao(xiaobao@linkease.com)
|
||||
|
||||
ACTION=${1}
|
||||
WRLOCK=/var/lock/ubuntu.lock
|
||||
LOGFILE=/var/log/ubuntu.log
|
||||
LOGEND="XU6J03M6"
|
||||
shift 1
|
||||
|
||||
IMAGE_NAME=''
|
||||
# linkease/desktop-ubuntu-full-arm64:latest
|
||||
# linkease/desktop-ubuntu-standard-arm64:latest
|
||||
# linkease/desktop-ubuntu-full-amd64:latest
|
||||
# linkease/desktop-ubuntu-standard-amd64:latest
|
||||
|
||||
check_params() {
|
||||
|
||||
if [ -z "${WRLOCK}" ]; then
|
||||
echo "lock file not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "${LOGFILE}" ]; then
|
||||
echo "logger file not found"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
lock_run() {
|
||||
local lock="$WRLOCK"
|
||||
exec 300>$lock
|
||||
flock -n 300 || return
|
||||
do_run
|
||||
flock -u 300
|
||||
return
|
||||
}
|
||||
|
||||
run_action() {
|
||||
if check_params; then
|
||||
lock_run
|
||||
fi
|
||||
}
|
||||
|
||||
get_image() {
|
||||
local version=`uci get ubuntu.@ubuntu[0].version 2>/dev/null`
|
||||
|
||||
ARCH="arm64"
|
||||
if echo `uname -m` | grep -Eqi 'x86_64'; then
|
||||
ARCH='amd64'
|
||||
elif echo `uname -m` | grep -Eqi 'aarch64'; then
|
||||
ARCH='arm64'
|
||||
else
|
||||
ARCH='arm64'
|
||||
fi
|
||||
|
||||
IMAGE_NAME=linkease/desktop-ubuntu-${version}-${ARCH}:latest
|
||||
}
|
||||
|
||||
do_install() {
|
||||
local PASSWORD=`uci get ubuntu.@ubuntu[0].password 2>/dev/null`
|
||||
local PORT=`uci get ubuntu.@ubuntu[0].port 2>/dev/null`
|
||||
[ -z "$PASSWORD" ] && PASSWORD="password"
|
||||
[ -z "$PORT" ] && PORT=6901
|
||||
echo "docker create pcnet" >${LOGFILE}
|
||||
local mntv="/mnt:/mnt"
|
||||
mountpoint -q /mnt && mntv="$mntv:rslave"
|
||||
get_image
|
||||
echo "docker pull ${IMAGE_NAME}" >>${LOGFILE}
|
||||
docker pull ${IMAGE_NAME} >>${LOGFILE} 2>&1
|
||||
docker rm -f ubuntu
|
||||
|
||||
# --net="docker-pcnet" \
|
||||
|
||||
docker run -d --name ubuntu \
|
||||
--dns=223.5.5.5 -u=0:0 \
|
||||
-v=${mntv} \
|
||||
--shm-size=512m \
|
||||
-p ${PORT}:6901 \
|
||||
-e VNC_PW=${PASSWORD} \
|
||||
-e VNC_USE_HTTP=0 \
|
||||
--restart unless-stopped \
|
||||
$IMAGE_NAME >>${LOGFILE} 2>&1
|
||||
|
||||
RET=$?
|
||||
if [ "${RET}" = "0" ]; then
|
||||
# mark END, remove the log file
|
||||
echo ${LOGEND} >> ${LOGFILE}
|
||||
sleep 5
|
||||
rm -f ${LOGFILE}
|
||||
else
|
||||
# reserve the log
|
||||
echo "docker run ${IMAGE_NAME} failed" >>${LOGFILE}
|
||||
echo ${LOGEND} >> ${LOGFILE}
|
||||
fi
|
||||
exit ${RET}
|
||||
}
|
||||
|
||||
# run in lock
|
||||
do_run() {
|
||||
case ${ACTION} in
|
||||
"install")
|
||||
do_install
|
||||
;;
|
||||
"upgrade")
|
||||
do_install
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "usage: wxedge sub-command"
|
||||
echo "where sub-command is one of:"
|
||||
echo " install Install the ubuntu"
|
||||
echo " upgrade Upgrade the ubuntu"
|
||||
echo " remove Remove the ubuntu"
|
||||
}
|
||||
|
||||
case ${ACTION} in
|
||||
"install")
|
||||
run_action
|
||||
;;
|
||||
"upgrade")
|
||||
run_action
|
||||
;;
|
||||
"remove")
|
||||
docker rm -f ubuntu
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
56
openwrt-app-actions/applications/speedtestcli/Makefile
Normal file
56
openwrt-app-actions/applications/speedtestcli/Makefile
Normal file
@ -0,0 +1,56 @@
|
||||
#
|
||||
# Copyright (C) 2015-2016 OpenWrt.org
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_ARCH_SPEEDTEST:=$(ARCH)
|
||||
|
||||
PKG_NAME:=speedtestcli
|
||||
PKG_VERSION:=1.2.0
|
||||
PKG_RELEASE:=$(PKG_ARCH_SPEEDTEST)-1
|
||||
PKG_SOURCE:=$(PKG_NAME)-binary-$(PKG_VERSION).tar.gz
|
||||
PKG_SOURCE_URL:=http://fw.koolcenter.com/binary/SpeedTestCli/
|
||||
PKG_HASH:=a7c24e1594251b376684d221c64cc0e717726c7229944eab9b3b5b74ec64238f
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-binary-$(PKG_VERSION)
|
||||
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_USE_MIPS16:=0
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/$(PKG_NAME)
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Web Servers/Proxies
|
||||
TITLE:=SpeedTestCli - network speed test
|
||||
PKGARCH:=all
|
||||
URL:=https://www.speedtest.net
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
SpeedTestCli is a network speed test command
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/postinst
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/speedtest.$(PKG_ARCH_SPEEDTEST) $(1)/usr/bin/speedtest
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
|
Loading…
Reference in New Issue
Block a user