From 6c5a27110572416b46939ae6a36ad4021041b227 Mon Sep 17 00:00:00 2001 From: Andrey Petelin Date: Tue, 16 Sep 2025 20:11:13 +0500 Subject: [PATCH] fix: Move sing-box config check to after temp file creation --- podkop/files/usr/bin/podkop | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/podkop/files/usr/bin/podkop b/podkop/files/usr/bin/podkop index 6dbc926..e642424 100755 --- a/podkop/files/usr/bin/podkop +++ b/podkop/files/usr/bin/podkop @@ -66,7 +66,6 @@ start_main() { # sing-box sing_box_init_config - sing_box_config_check config_foreach add_cron_job /etc/init.d/sing-box start @@ -1167,6 +1166,8 @@ sing_box_save_config() { log "Save sing-box temporary config to $temp_file_path" "debug" sing_box_cm_save_config_to_file "$config" "$temp_file_path" + sing_box_config_check "$temp_file_path" + current_config_hash=$(md5sum "$sing_box_config_path" 2> /dev/null | awk '{print $1}') temp_config_hash=$(md5sum "$temp_file_path" | awk '{print $1}') log "Current sing-box config hash: $current_config_hash" "debug" @@ -1181,10 +1182,10 @@ sing_box_save_config() { } sing_box_config_check() { - local sing_box_config_path - config_get sing_box_config_path "main" "config_path" - if ! sing-box -c "$sing_box_config_path" check > /dev/null 2>&1; then - log "Sing-box configuration is invalid" "fatal" + local config_path="$1" + + if ! sing-box -c "$config_path" check > /dev/null 2>&1; then + log "Sing-box configuration $config_path is invalid" "fatal" exit 1 fi }