update 2026-09-24 16:56:26

This commit is contained in:
action committed 2026-09-24 16:56:26 +08:00
1 parent b31a5c3878
commit e4cee331e9
6885 files changed
+3240523

No files matched your search

@@ -0,0 +1,3 @@
config status
option version '0'
option base '1'
@@ -0,0 +1,6 @@
#!/bin/sh
[ "${ACTION}" = "add" ] && {
/sbin/wifi config
[[ -z "$(uci -q get base_config.@status[0].wifi)" ]] && . /sbin/mywifi &
}
@@ -0,0 +1,42 @@
server
{
listen 8877;
#listen 443 ssl http2;
server_name _lan;
index index.html index.htm index.php default.html default.htm default.php;
root /data;
# ssl_certificate /etc/acme/supes.top/fullchain.cer;
# ssl_certificate_key /etc/acme/supes.top/supes.top.key;
# ssl_session_timeout '64m';
# ssl_protocols TLSv1.2 TLSv1.3;
# ssl_prefer_server_ciphers on;
# ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
# ssl_session_cache 'shared:SSL:10m';
client_max_body_size 0;
location / {
set $dest $http_destination;
if (-d $request_filename) {
rewrite ^(.*[^/])$ $1/;
set $dest $dest/;
}
if ($request_method ~ (MOVE|COPY)) {
more_set_input_headers 'Destination: $dest';
}
if ($request_method ~ MKCOL) {
rewrite ^(.*[^/])$ $1/ break;
}
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS;
dav_access user:rw group:rw all:r;
create_full_put_path on;
auth_basic "Restricted access";
auth_basic_user_file /etc/nginx/htpasswd.conf;
}
}
@@ -0,0 +1 @@
root:fU70Nx.37Ofww
@@ -0,0 +1,121 @@
#!/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export LANG=zh_CN.UTF-8
THIS_SCRIPT="sysinfo"
MOTD_DISABLE=""
SHOW_IP_PATTERN="^[ewr].*|^br.*|^lt.*|^umts.*"
DATA_STORAGE=/userdisk/data
MEDIA_STORAGE=/userdisk/snail
# don't edit below here
function display()
{
# $1=name $2=value $3=red_limit $4=minimal_show_limit $5=unit $6=after $7=acs/desc{
# battery red color is opposite, lower number
if [[ "$1" == "Battery" ]]; then
local great="<";
else
local great=">";
fi
if [[ -n "$2" && "$2" > "0" && (( "${2%.*}" -ge "$4" )) ]]; then
printf "%-14s%s" "$1:"
if awk "BEGIN{exit ! ($2 $great $3)}"; then
echo -ne "\e[0;91m $2";
else
echo -ne "\e[0;92m $2";
fi
printf "%-1s%s\x1B[0m" "$5"
printf "%-11s%s\t" "$6"
return 1
fi
} # display
function get_ip_addresses()
{
local ips=()
for f in /sys/class/net/*; do
local intf=$(basename $f)
# match only interface names starting with e (Ethernet), br (bridge), w (wireless), r (some Ralink drivers use ra<number> format)
if [[ $intf =~ $SHOW_IP_PATTERN ]]; then
local tmp=$(ip -4 addr show dev $intf | awk '/inet/ {print $2}' | cut -d'/' -f1)
# add both name and IP - can be informative but becomes ugly with long persistent/predictable device names
#[[ -n $tmp ]] && ips+=("$intf: $tmp")
# add IP only
[[ -n $tmp ]] && ips+=("$tmp")
fi
done
echo "${ips[@]}"
} # get_ip_addresses
function storage_info()
{
# storage info
RootInfo=$(df -h /)
root_usage=$(awk '/\// {print $(NF-1)}' <<<${RootInfo} | sed 's/%//g')
root_total=$(awk '/\// {print $(NF-4)}' <<<${RootInfo})
} # storage_info
# query various systems and send some stuff to the background for overall faster execution.
# Works only with ambienttemp and batteryinfo since A20 is slow enough :)
storage_info
critical_load=$(( 1 + $(grep -c processor /proc/cpuinfo) / 2 ))
# get uptime, logged in users and load in one take
UptimeString=$(uptime | tr -d ',')
time=$(awk -F" " '{print $3" "$4}' <<<"${UptimeString}")
load="$(awk -F"average: " '{print $2}'<<<"${UptimeString}")"
case ${time} in
1:*) # 1-2 hours
time=$(awk -F" " '{print $3" 小时"}' <<<"${UptimeString}")
;;
*:*) # 2-24 hours
time=$(awk -F" " '{print $3" 小时"}' <<<"${UptimeString}")
;;
*day) # days
days=$(awk -F" " '{print $3"天"}' <<<"${UptimeString}")
time=$(awk -F" " '{print $5}' <<<"${UptimeString}")
time="$days "$(awk -F":" '{print $1"小时 "$2"分钟"}' <<<"${time}")
;;
esac
# memory and swap
mem_info=$(LC_ALL=C free -w 2>/dev/null | grep "^Mem" || LC_ALL=C free | grep "^Mem")
memory_usage=$(awk '{printf("%.0f",(($2-($4+$6))/$2) * 100)}' <<<${mem_info})
memory_total=$(awk '{printf("%d",$2/1024)}' <<<${mem_info})
swap_info=$(LC_ALL=C free -m | grep "^Swap")
swap_usage=$( (awk '/Swap/ { printf("%3.0f", $3/$2*100) }' <<<${swap_info} 2>/dev/null || echo 0) | tr -c -d '[:digit:]')
swap_total=$(awk '{print $(2)}' <<<${swap_info})
c=0
while [ ! -n "$(get_ip_addresses)" ];do
[ $c -eq 3 ] && break || let c++
sleep 1
done
ip_address="$(get_ip_addresses)"
# display info
display "系统负载" "${load%% *}" "${critical_load}" "0" "" "${load#* }"
printf "运行时间: \x1B[92m%s\x1B[0m\t\t" "$time"
echo "" # fixed newline
display "内存已用" "$memory_usage" "70" "0" " %" " of ${memory_total}MB"
display "交换内存" "$swap_usage" "10" "0" " %" " of $swap_total""Mb"
printf "IP 地址: \x1B[92m%s\x1B[0m" "$ip_address"
echo "" # fixed newline
display "系统存储" "$root_usage" "90" "1" "%" " of $root_total"
if [ -x /sbin/cpuinfo ]; then
printf "CPU 信息: \x1B[92m%s\x1B[0m\t" "$(echo `/sbin/cpuinfo | cut -d ' ' -f -4`)"
fi
echo ""
echo ""
@@ -0,0 +1,14 @@
#!/bin/sh /etc/rc.common
[[ -f "/bin/coremark" && ! -f "/etc/bench.log" && "$(uci -q get wizard.default.coremark)" == '1' ]] && {
(
sleep 5
while :; do
[ -f /var/lock/opkg.lock ] || {
/sbin/coremark
break;
}
sleep 1
done
) &
}
@@ -0,0 +1,149 @@
#!/bin/sh
# 1. 基础系统与组件链接修正
sed -i 's|op.supes.top|dl.openwrt.ai|g' /etc/opkg/distfeeds.conf 2>/dev/null
[ -x /bin/bash ] && sed -i 's|/bin/ash|/bin/bash|g' /etc/passwd 2>/dev/null && ln -sf /bin/bash /bin/sh 2>/dev/null
[ -x /usr/bin/wget ] && [ ! -x /usr/bin/wget-ssl ] && ln -sf /usr/bin/wget /usr/bin/wget-ssl
sed -i -e '/profile.d/d' /lib/upgrade/keep.d/base-files \
-e 's/git-.*-\(.*\)/git-\1/g' /usr/lib/lua/luci/version.lua 2>/dev/null
# 2. 版本与环境参数提取
version=$(uci -q get base_config.@status[0].version)
case "$version" in ''|*[!0-9]*) version=0 ;; esac
for ip in $(uci -q get network.lan.ipaddr); do
case "$ip" in *.*) lan_ip="${ip%%/*}"; break ;; esac
done
lan_ip="${lan_ip:-10.0.0.1}"
[ -z "$(uci -q get system.@system[0].hostname)" ] && uci -q set system.@system[0].hostname='Kwrt'
[ "$(uci -q get dropbear.main._direct)" != "1" ] && uci -q delete dropbear.main.Interface
case "$(uci -q get uhttpd.main.index_page)" in *cgi-bin/luci*) ;; *) uci -q add_list uhttpd.main.index_page='cgi-bin/luci' ;; esac
proc=$(grep -c '^processor' /proc/cpuinfo 2>/dev/null)
[ "${proc:-0}" -gt 0 ] 2>/dev/null || proc=3
sed -i "s/^threads =.*/threads = $proc/" /etc/uwsgi/vassals/luci-webui.ini 2>/dev/null
# 3. 内存分级计算
mem=0
[ -r /proc/meminfo ] && read -r _ mem _ < /proc/meminfo
case "$mem" in ''|*[!0-9]*) mem=0 ;; esac
c=1024; nf=16384
[ "$mem" -ge 65536 ] && { c=2048; nf=32768; }
[ "$mem" -ge 131072 ] && { c=4096; nf=65536; }
[ "$mem" -ge 262144 ] && { c=8192; nf=65536; }
[ "$mem" -ge 524288 ] && { c=10000; nf=131072; }
[ "$mem" -ge 1048576 ] && { c=10000; nf=262144; }
# 4. 首次开机参数统一批量预设
if [ "$version" -lt 1 ]; then
uci -q batch <<-EOF
set luci.main.lang='auto'
set uhttpd.main.rfc1918_filter='0'
set uhttpd.main.redirect_https='0'
set uhttpd.main.script_timeout='120'
set upnpd.config.enabled='1'
set firewall.@defaults[0].flow_offloading='1'
set firewall.@defaults[0].flow_offloading_hw='1'
set fstab.@global[0].anon_mount='1'
set network.globals.packet_steering='1'
set nft-qos.default.limit_enable='0'
set system.@system[0].zonename='Asia/Shanghai'
set system.@system[0].timezone='CST-8'
set system.@system[0].ttylogin='1'
set system.@system[0].zram_size_mb='$((mem / 1024 / 3))'
del system.ntp.server
add_list system.ntp.server='ntp.aliyun.com'
add_list system.ntp.server='0.openwrt.pool.ntp.org'
set dhcp.@dnsmasq[0].port='53'
set dhcp.@dnsmasq[0].dns_redirect='1'
set dhcp.@dnsmasq[0].allservers='1'
del dhcp.@dnsmasq[0].noresolv
set dhcp.@dnsmasq[0].cachesize='$c'
set dhcp.@dnsmasq[0].dnsforwardmax='$c'
set dhcp.@dnsmasq[0].min_ttl='3600'
set dhcp.lan.force='1'
set dhcp._ta=domain
set dhcp._ta.name='time.android.com'
set dhcp._ta.ip='203.107.6.88'
set dhcp._ta.comments='time.android'
EOF
(echo root; echo root) | passwd root >/dev/null 2>&1
[ -f /usr/share/rpcd/acl.d/luci-theme-argon.json ] && uci -q set luci.main.mediaurlbase='/luci-static/argon'
grep -q 'log-facility' /etc/dnsmasq.conf 2>/dev/null || echo "log-facility=/dev/null" >> /etc/dnsmasq.conf
mkdir -p /etc/sysctl.d
printf "net.nf_conntrack_max=%s\nnet.core.rmem_max=%s\n" "$nf" "$nf" > /etc/sysctl.d/50-local.conf
if command -v nginx >/dev/null 2>&1 && [ -z "$(uci -q get wizard.pw)" ]; then
uci -q batch <<-EOF
set wizard.pw=shortcuts
set wizard.pw.shortcut='pw'
set wizard.pw.to_url='http://${lan_ip}/cgi-bin/luci/admin/services/passwall'
set wizard.pw.comments='passwall'
set nginx._sc_pw=server
set nginx._sc_pw.server_name='pw'
add_list nginx._sc_pw.listen='80'
add_list nginx._sc_pw.listen='443'
set nginx._sc_pw.return='302 http://${lan_ip}/cgi-bin/luci/admin/services/passwall'
set dhcp._sc_pw=domain
set dhcp._sc_pw.name='pw'
set dhcp._sc_pw.ip='${lan_ip}'
set dhcp._sc_pw.comments='PassWall'
EOF
fi
version=1
fi
# 5. 默认后台域名映射与 Nginx 规则
[ -z "$(uci -q get dhcp.default_server)" ] && uci -q batch <<-EOF
set dhcp.default_server=domain
set dhcp.default_server.name='kwrt'
set dhcp.default_server.ip='${lan_ip}'
set dhcp.default_server.comments='后台地址'
EOF
if command -v nginx >/dev/null 2>&1; then
[ -z "$(uci -q get nginx.default_server)" ] && uci -q batch <<-EOF
set nginx.default_server=server
set nginx.default_server.server_name='kwrt'
add_list nginx.default_server.listen='80 default_server'
add_list nginx.default_server.listen='[::]:80 default_server'
add_list nginx.default_server.include='conf.d/*.locations'
set nginx.default_server.access_log='off; # logd openwrt'
EOF
if [ -f /etc/nginx/conf.d/luci.locations ]; then
grep -q 'uwsgi_read_timeout' /etc/nginx/conf.d/luci.locations || sed -i '/include uwsgi_params;/a\\t\tuwsgi_read_timeout 300s;' /etc/nginx/conf.d/luci.locations
grep -q 'ubus_script_timeout' /etc/nginx/conf.d/luci.locations || sed -i '/ubus_parallel_req/a\ ubus_script_timeout 600;' /etc/nginx/conf.d/luci.locations
fi
if [ -f /etc/nginx/uci.conf.template ]; then
sed -i -e 's/128M/3072M/' -e 's/2 1k/4 512k/' /etc/nginx/uci.conf.template
grep -q 'client_body_buffer_size' /etc/nginx/uci.conf.template || sed -i '/large_client_header_buffers/a\\tclient_body_buffer_size 128K;' /etc/nginx/uci.conf.template
fi
fi
# 6. uWSGI 超时与 FullCone 探测(兼容 fw3/fw4)
for ini in /etc/uwsgi/vassals/luci-*.ini; do
[ -f "$ini" ] && ! grep -q 'cgi-timeout' "$ini" && echo "cgi-timeout = 500" >> "$ini"
done
sed -i 's/limit-as = 1000/limit-as = 5000/g' /etc/uwsgi/vassals/luci-webui.ini 2>/dev/null
modprobe xt_FULLCONENAT >/dev/null 2>&1 || modprobe nft_fullcone >/dev/null 2>&1 || {
iptables -L -t nat 2>/dev/null | grep -q 'FULLCONENAT' || \
nft list ruleset 2>/dev/null | grep -q 'fullcone' || \
uci -q set firewall.@defaults[0].fullcone='0'
}
# 7. 更新版本状态、一次性提交所有 UCI 配置并安全退出
[ -f /etc/config/base_config ] && {
uci -q get base_config.@status[0] >/dev/null || uci -q add base_config status >/dev/null
uci -q set base_config.@status[0].version="$version"
}
uci -q commit
rm -rf /tmp/luci-*
exit 0