update 2026-07-28 01:38:11

This commit is contained in:
action committed 2026-07-28 01:38:11 +08:00
1 parent 20b786ab77
commit 25d570431d
6243 files changed
+2850542

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
config npc
option enable '0'
option server_addr '1.2.3.4:123'
option protocol 'tcp'
option vkey 'abcdefg'
option dns ''
option extra_args '-debug=false -log=off'
+69
View File
@@ -0,0 +1,69 @@
#!/bin/sh /etc/rc.common
START=95
USE_PROCD=1
LOGGER="logger -t [NPC]"
npc_Path="$(command -v npc)"
start_service() {
if [ -f /usr/local/bin/npc ] ; then
${LOGGER} "Moving npc to /usr/bin ..."
mv -f /usr/local/bin/npc /usr/bin/npc
fi
if [ -f /usr/local/bin/npc-update ] ; then
${LOGGER} "Moving npc-update to /usr/bin ..."
mv -f /usr/local/bin/npc-update /usr/bin/npc-update
fi
local basic_list="enable server_addr protocol vkey dns extra_args"
for i in $(echo $basic_list);do
local eval $i="$(uci_get_by_type npc 0 $i)"
done;unset i
if [ "$enable" != "1" ]; then
${LOGGER} "NPS Client(NPC) is disabled"
return
fi
${LOGGER} "Starting NPS Client(NPC) ..."
cmd_args=""
if ! printf '%s\n' "$extra_args" | grep -q -- '\-server='; then
cmd_args="$cmd_args -server=${server_addr}"
fi
if ! printf '%s\n' "$extra_args" | grep -q -- '\-vkey='; then
cmd_args="$cmd_args -vkey=${vkey}"
fi
if ! printf '%s\n' "$extra_args" | grep -q -- '\-type='; then
cmd_args="$cmd_args -type=${protocol}"
fi
if ! printf '%s\n' "$extra_args" | grep -q -- '\-dns_server='; then
cmd_args="$cmd_args -dns_server=${dns}"
fi
[ -n "$extra_args" ] && cmd_args="$cmd_args $extra_args"
if ! printf '%s\n' "$cmd_args" | grep -q -- '\-log='; then
cmd_args="$cmd_args -log=off"
fi
procd_open_instance
procd_set_param command $npc_Path $cmd_args
procd_set_param respawn
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
stop_service() {
${LOGGER} "Stopping NPS Client(NPC) ..."
}
service_triggers() {
procd_add_reload_trigger "npc"
}
uci_get_by_type() {
local ret=$(uci get npc.@$1[$2].$3 2>/dev/null)
echo ${ret:=$4}
}
+11
View File
@@ -0,0 +1,11 @@
#!/bin/sh
uci -q batch <<-EOF >/dev/null
delete ucitrack.@npc[-1]
add ucitrack npc
set ucitrack.@npc[-1].init=npc
commit ucitrack
EOF
rm -f /tmp/luci-indexcache
exit 0
+11
View File
@@ -0,0 +1,11 @@
{
"luci-app-npc": {
"description": "Grant UCI access for luci-app-npc",
"read": {
"uci": [ "npc" ]
},
"write": {
"uci": [ "npc" ]
}
}
}