mirror of
https://github.com/caiwx86/small-packages.git
synced 2026-10-29 07:15:13 +08:00
update 2026-09-26 11:07:27
This commit is contained in:
1 parent
7b88b273d0
commit
97ae9f68da
4898 files changed
-1712274
No files matched your search
@@ -1,3 +0,0 @@
|
||||
|
||||
config basic
|
||||
|
||||
@@ -1,155 +0,0 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright 2023-2024 sirpdboy team <herboy2008@gmail.com>
|
||||
|
||||
|
||||
START=99
|
||||
STOP=10
|
||||
USE_PROCD=1
|
||||
PROG="/usr/bin/uhttpd-watchdog"
|
||||
NAME="uhttpd-watchdog"
|
||||
LOCK=/var/lock/advancedplus-boot.lock
|
||||
|
||||
|
||||
cpumodeset()
|
||||
{
|
||||
for i in 0 1 2 3 ;do
|
||||
echo $1 > /sys/devices/system/cpu/cpufreq/policy$i/scaling_governor
|
||||
done
|
||||
}
|
||||
|
||||
tsoset() {
|
||||
tautocore=/etc/init.d/autocore
|
||||
[ -f $tautocore ] || return
|
||||
if [ "x$(uci -q get advancedplus.@basic[0].tsoset)" = "x1" ] ;then
|
||||
sed -i 's/tso on/tso off/g' $tautocore
|
||||
$tautocore restart
|
||||
else
|
||||
sed -i 's/tso off/tso on/g' $tautocore
|
||||
$tautocore restart
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
setnetwizard(){
|
||||
if [ "x$(uci -q get advancedplus.@basic[0].wizard)" == "x1" ] ; then
|
||||
[ `grep -e '-netwizard' /usr/share/luci/menu.d/luci-app-netwizard.json | wc -l` == 1 ] && {
|
||||
sed -i 's|-netwizard|-znetwizard|' /usr/share/luci/menu.d/luci-app-netwizard.json
|
||||
/etc/init.d/rpcd restart
|
||||
}
|
||||
uci -q set netwizard.default.showhide="1"
|
||||
uci commit netwizard
|
||||
else
|
||||
uci -q set netwizard.default.showhide="0"
|
||||
uci commit netwizard
|
||||
[ `grep -e '-znetwizard' /usr/share/luci/menu.d/luci-app-netwizard.json | wc -l` == 1 ] && {
|
||||
sed -i 's|-znetwizard|-netwizard|' /usr/share/luci/menu.d/luci-app-netwizard.json
|
||||
/etc/init.d/rpcd restart
|
||||
}
|
||||
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
set_login() {
|
||||
if [ "x$(uci -q get advancedplus.@basic[0].set_login)" == "x1" ] ; then
|
||||
sed -i '$ s|exec /bin/sh -l$|exec /bin/login|' /usr/libexec/login.sh
|
||||
else
|
||||
sed -i '$ s|exec /bin/login$|exec /bin/sh -l|' /usr/libexec/login.sh
|
||||
fi
|
||||
}
|
||||
|
||||
dhcp_domain() {
|
||||
if [ "x$(uci -q get advancedplus.@basic[0].dhcp_domain)" = "x1" ] ; then
|
||||
local domain_name="time.android.com"
|
||||
local domain_ip="203.107.6.88"
|
||||
existing_records=$(uci show dhcp | grep "dhcp.@domain\[[0-9]\+\].name='$domain_name'")
|
||||
if [ -z "$existing_records" ]; then
|
||||
uci add dhcp domain
|
||||
uci -q set "dhcp.@domain[-1].name=$domain_name"
|
||||
uci -q set "dhcp.@domain[-1].ip=$domain_ip"
|
||||
uci commit dhcp
|
||||
fi
|
||||
else
|
||||
existing_records=$(uci show dhcp | grep "dhcp.@domain\[[0-9]\+\].name='$domain_name'")
|
||||
if [ -z "$existing_records" ]; then
|
||||
uci delete dhcp.@domain[-1].name
|
||||
uci delete dhcp.@domain[-1].ip
|
||||
uci commit dhcp
|
||||
fi
|
||||
fi
|
||||
}
|
||||
advancedset(){
|
||||
dev=`ifconfig | grep "Point-to-Point" | cut -d " " -f1`
|
||||
[ ! $dev ] && dev=` uci -q get network.wan.ifname ` || dev=` uci -q get network.wan.device `
|
||||
[ ! $dev ] && dev=br-lan
|
||||
setnetwizard
|
||||
set_login
|
||||
# tsoset
|
||||
sed -i "\/bin\/zsh/d" /etc/profile
|
||||
[ "x$(uci -q get advancedplus.@basic[0].usshmenu)" = "x1" ] || echo '/usr/bin/zsh' >> /etc/profile
|
||||
}
|
||||
|
||||
start_service() {
|
||||
[ -f $LOCK ] && exit
|
||||
[ "x$(uci -q get advancedplus.@basic[0].uhttpd)" = "x1" ] && uhttpd_service
|
||||
touch $LOCK
|
||||
advancedset
|
||||
rm -rf /tmp/luci-*
|
||||
rm -f $LOCK 2>/dev/null
|
||||
}
|
||||
|
||||
validate_service_file() {
|
||||
if [ ! -x "/usr/sbin/uhttpd" ]; then
|
||||
echo "错误:/usr/sbin/uhttpd 不存在或不可执行" >&2
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
uhttpd_service() {
|
||||
validate_service_file || return 1
|
||||
|
||||
echo "uhttpd 服务启用检测!"
|
||||
if ! /etc/init.d/uhttpd enabled; then
|
||||
echo "uhttpd 服务未启用,监控服务不启动" >&2
|
||||
return 0
|
||||
fi
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command "$PROG" start
|
||||
procd_set_param respawn
|
||||
procd_set_param respawn_retry 5
|
||||
procd_set_param respawn_threshold 3600
|
||||
procd_set_param respawn_timeout 10
|
||||
procd_set_param stderr 1
|
||||
procd_set_param stdout 1
|
||||
# procd_set_param file "$PROG"
|
||||
# procd_set_param pidfile "/var/run/${NAME}.pid"
|
||||
# procd_append_param env CHECK_INTERVAL=30
|
||||
# procd_append_param env MAX_FAILURES=3
|
||||
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger 'advancedplus'
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
|
||||
rm -f $LOCK 2>/dev/null
|
||||
$PROG stop 2>/dev/null
|
||||
rm -f "/var/run/${NAME}.pid"
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
sleep 2
|
||||
start
|
||||
}
|
||||
|
||||
reload() {
|
||||
restart
|
||||
}
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
chmod +x /etc/init.d/advancedplus /usr/bin/advancedplusipk /usr/bin/uhttpd-watchdog
|
||||
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
||||
@@ -1,95 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
skin="Kucat"
|
||||
|
||||
is_x86_64() {
|
||||
DISTRIB_ARCH=$(cat /etc/openwrt_release | grep "DISTRIB_ARCH" | cut -d "'" -f 2)
|
||||
if [ "$DISTRIB_ARCH" = "x86_64" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
remove_check_signature() {
|
||||
local opkg_conf="/etc/opkg.conf"
|
||||
sed -i '/option check_signature/d' "$opkg_conf"
|
||||
}
|
||||
|
||||
is_iStore() {
|
||||
[ -s "/www/luci-static/istore/index.js" ] && return 0 || return 1
|
||||
}
|
||||
|
||||
is_vip() {
|
||||
local ezver
|
||||
ezver=$(grep -o "EZVER=\S*" /etc/ezopenwrt_version 2>/dev/null | cut -d'-' -f3)
|
||||
[[ "${ezver^^}" =~ VIP ]]
|
||||
}
|
||||
|
||||
istore_install(){
|
||||
if is_iStore; then
|
||||
echo "已存在有iStore应用商店,无须再安装!"
|
||||
else
|
||||
echo "正在安装iStore应用商店...."
|
||||
remove_check_signature
|
||||
opkg update
|
||||
opkg remove git-lfs
|
||||
setup_software_source 1
|
||||
ISTORE_REPO=https://istore.linkease.com/repo/all/store
|
||||
FCURL="curl --fail --show-error"
|
||||
|
||||
IPK=$($FCURL "$ISTORE_REPO/Packages.gz" | zcat | grep -m1 '^Filename: luci-app-store.*\.ipk$' | sed -n -e 's/^Filename: \(.\+\)$/\1/p')
|
||||
[ -n "$IPK" ] || exit 1
|
||||
$FCURL "$ISTORE_REPO/$IPK" | tar -xzO ./data.tar.gz | tar -xzO ./bin/is-opkg >/tmp/is-opkg
|
||||
chmod 755 /tmp/is-opkg
|
||||
|
||||
|
||||
/tmp/is-opkg update
|
||||
/tmp/is-opkg install taskd
|
||||
/tmp/is-opkg opkg install --force-reinstall luci-lib-taskd luci-lib-xterm
|
||||
/tmp/is-opkg opkg install --force-reinstall luci-app-store || exit $?
|
||||
[ -s "/etc/init.d/tasks" ] || /tmp/is-opkg opkg install --force-reinstall taskd
|
||||
[ -s "/usr/lib/lua/luci/cbi.lua" ] || /tmp/is-opkg opkg install luci-compat >/dev/null 2>&1
|
||||
|
||||
sed -i 's/istore.linkease.com/istore.istoreos.com/g' /bin/is-opkg
|
||||
|
||||
sed -i 's/istore.linkease.com/istore.istoreos.com/g' /etc/opkg/compatfeeds.conf
|
||||
sed -i 's/istore.linkease.com/istore.istoreos.com/g' /www/luci-static/istore/index.js
|
||||
|
||||
uci -q set luci.main.mediaurlbase='/luci-static/kucat'
|
||||
uci commit
|
||||
rm -rf /tmp/is-opkg /tmp/luci*
|
||||
echo "iStore应用商店安装完成!"
|
||||
fi
|
||||
exit
|
||||
}
|
||||
|
||||
drv_install(){
|
||||
if is_vip; then
|
||||
bash /etc/kmodreg drv
|
||||
else
|
||||
echo "目前此功能仅限VIP版本提供!"
|
||||
fi
|
||||
exit
|
||||
}
|
||||
|
||||
docker_install(){
|
||||
if is_vip; then
|
||||
bash /etc/kmodreg docker
|
||||
else
|
||||
echo "目前此功能仅限VIP版本提供!"
|
||||
fi
|
||||
exit
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"istore")
|
||||
istore_install
|
||||
;;
|
||||
"drv")
|
||||
drv_install
|
||||
;;
|
||||
"docker")
|
||||
docker_install
|
||||
;;
|
||||
esac
|
||||
@@ -1,109 +0,0 @@
|
||||
#!/bin/sh
|
||||
# uhttpd 进程监控守护进程 2025-2026 by sirpdboy
|
||||
|
||||
PROG="uhttpd-watchdog"
|
||||
UHTTPD_BIN="/usr/sbin/uhttpd"
|
||||
UHTTPD_SERVICE="uhttpd"
|
||||
CHECK_INTERVAL=30 # 检查间隔(秒)
|
||||
MAX_FAILURES=3 # 最大连续失败次数
|
||||
LOG_IDENT="$PROG"
|
||||
|
||||
log() {
|
||||
logger -t "$LOG_IDENT" "$1"
|
||||
}
|
||||
|
||||
check_binary() {
|
||||
if [ ! -x "$UHTTPD_BIN" ]; then
|
||||
log "错误:$UHTTPD_BIN 不存在或不可执行,监控停止"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
check_process() {
|
||||
if pgrep -f "/usr/sbin/uhttpd" >/dev/null 2>&1 || \
|
||||
pgrep -x uhttpd >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
restart_service() {
|
||||
log "尝试重启 $UHTTPD_SERVICE 服务..."
|
||||
if /etc/init.d/$UHTTPD_SERVICE restart >/dev/null 2>&1; then
|
||||
sleep 3 # 等待服务启动
|
||||
if check_process; then
|
||||
log "$UHTTPD_SERVICE 重启成功"
|
||||
return 0
|
||||
else
|
||||
log "$UHTTPD_SERVICE 重启后进程仍不存在"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
log "执行 service $UHTTPD_SERVICE restart 失败"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
monitor_loop() {
|
||||
local failures=0
|
||||
|
||||
log "启动 $UHTTPD_SERVICE 监控守护进程"
|
||||
|
||||
while true; do
|
||||
# 检查二进制文件
|
||||
if ! check_binary; then
|
||||
sleep 60
|
||||
continue
|
||||
fi
|
||||
|
||||
# 检查进程状态
|
||||
if ! check_process; then
|
||||
failures=$((failures + 1))
|
||||
log "检测到 $UHTTPD_SERVICE 进程停止 (失败次数: $failures/$MAX_FAILURES)"
|
||||
|
||||
if [ $failures -ge $MAX_FAILURES ]; then
|
||||
log "达到最大失败次数,尝试重启服务..."
|
||||
if restart_service; then
|
||||
failures=0
|
||||
else
|
||||
sleep 60
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# 进程正常,重置失败计数器
|
||||
if [ $failures -gt 0 ]; then
|
||||
log "$UHTTPD_SERVICE 恢复正常运行"
|
||||
failures=0
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep $CHECK_INTERVAL
|
||||
done
|
||||
}
|
||||
|
||||
start() {
|
||||
if pgrep -f "$PROG" | grep -v $$ >/dev/null 2>&1; then
|
||||
log "警告:$PROG 已经在运行"
|
||||
exit 1
|
||||
fi
|
||||
monitor_loop
|
||||
}
|
||||
|
||||
stop() {
|
||||
pkill -f "$PROG" 2>/dev/null
|
||||
log "监控服务已停止"
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
*)
|
||||
echo "用法: $0 {start|stop}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"luci-app-advancedplus": {
|
||||
"description": "Grant UCI access for luci-app-advancedplus",
|
||||
"read": {
|
||||
"uci": [ "advancedplus" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "advancedplus" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user