Interface trigger. Disable sing-box autostart. dont touch dhcp. reload without dnsmasq restart

This commit is contained in:
itdoginfo
2025-04-24 19:25:08 +03:00
parent 615241aa37
commit ba44966c02
5 changed files with 92 additions and 27 deletions

View File

@@ -36,4 +36,5 @@ config main 'main'
option dns_rewrite_ttl '60'
option cache_file '/tmp/cache.db'
list iface 'br-lan'
list restart_ifaces 'wan'
option ss_uot '0'

View File

@@ -6,13 +6,15 @@ USE_PROCD=1
script=$(readlink "$initscript")
NAME="$(basename ${script:-$initscript})"
config_load "$NAME"
RESOLV_CONF="/etc/resolv.conf"
start_service() {
echo "Start podkop"
config_get restart_ifaces "main" "restart_ifaces"
procd_open_instance
procd_set_param command /bin/sh -c "/usr/bin/podkop start"
procd_set_param command /usr/bin/podkop start
[ -z "$restart_ifaces" ] || procd_set_param netdev $restart_ifaces
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
@@ -22,17 +24,19 @@ stop_service() {
/usr/bin/podkop stop
}
restart_service() {
stop
start
}
reload_service() {
stop
start
/usr/bin/podkop reload > /dev/null 2>&1
}
service_triggers() {
echo "service_triggers start"
procd_add_config_trigger "config.change" "$NAME" "$initscript" reload 'on_config_change'
config_get restart_ifaces "main" "restart_ifaces"
procd_open_trigger
procd_add_config_trigger "config.change" "$NAME" "$initscript" reload 'on_config_change'
for iface in $restart_ifaces; do
procd_add_reload_interface_trigger $iface
done
procd_close_trigger
}

View File

@@ -45,7 +45,7 @@ nolog() {
echo -e "${CYAN}[$timestamp]${RESET} ${GREEN}$message${RESET}"
}
start() {
start_main() {
log "Starting podkop"
# checking
@@ -136,7 +136,12 @@ start() {
sing_box_config_check
/etc/init.d/sing-box start
/etc/init.d/sing-box enable
#/etc/init.d/sing-box enable
log "Nice"
}
start() {
start_main
config_get proxy_string "main" "proxy_string"
config_get interface "main" "interface"
@@ -150,7 +155,7 @@ start() {
fi
}
stop() {
stop_main() {
log "Stopping the podkop"
if [ -f /var/run/podkop_list_update.pid ]; then
@@ -164,11 +169,6 @@ stop() {
remove_cron_job
config_get_bool dont_touch_dhcp "main" "dont_touch_dhcp" "0"
if [ "$dont_touch_dhcp" -eq 0 ]; then
dnsmasq_restore
fi
rm -rf /tmp/podkop/*.lst
log "Flush nft"
@@ -188,8 +188,22 @@ stop() {
log "Stop sing-box"
/etc/init.d/sing-box stop
/etc/init.d/sing-box disable
#/etc/init.d/sing-box disable
}
stop() {
config_get_bool dont_touch_dhcp "main" "dont_touch_dhcp" "0"
if [ "$dont_touch_dhcp" -eq 0 ]; then
dnsmasq_restore
fi
stop_main
}
reload() {
log "Podkop reload"
stop_main
start_main
}
# Migrations and validation funcs
@@ -592,10 +606,12 @@ sing_box_uci() {
log "Change sing-box UCI config"
fi
if grep -q '#\s*list ifaces' "$config"; then
sed -i '/ifaces/s/#//g' $config
log "Uncommented list ifaces"
fi
[ -f /etc/rc.d/S99sing-box ] && log "Disable sing-box" && /etc/init.d/sing-box disable
# if grep -q '#\s*list ifaces' "$config"; then
# sed -i '/ifaces/s/#//g' $config
# log "Uncommented list ifaces"
# fi
}
add_socks5_for_section() {
@@ -2156,9 +2172,8 @@ case "$1" in
stop)
stop
;;
restart)
stop
start
reload)
reload
;;
main)
main
@@ -2218,7 +2233,7 @@ case "$1" in
check_dns_available
;;
*)
echo "Usage: $0 {start|stop|restart|reload|enable|disable|main|list_update|check_proxy|check_nft|check_github|check_logs|check_sing_box_connections|check_sing_box_logs|check_fakeip|check_dnsmasq|show_config|show_version|show_sing_box_config|show_luci_version|show_sing_box_version|show_system_info|get_status|get_sing_box_status|check_dns_available}"
echo "Usage: $0 {start|stop|reload|enable|disable|main|list_update|check_proxy|check_nft|check_github|check_logs|check_sing_box_connections|check_sing_box_logs|check_fakeip|check_dnsmasq|show_config|show_version|show_sing_box_config|show_luci_version|show_sing_box_version|show_system_info|get_status|get_sing_box_status|check_dns_available}"
exit 1
;;
esac