mirror of
https://github.com/remittor/zapret-openwrt.git
synced 2025-12-07 12:06:53 +03:00
config: Add check syntax of main config into sync_config.sh
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
EXEDIR=/opt/zapret
|
EXEDIR=/opt/zapret
|
||||||
ZAPRET_BASE=/opt/zapret
|
ZAPRET_BASE=/opt/zapret
|
||||||
ZAPRET_CONFIG="$ZAPRET_BASE/config"
|
ZAPRET_CONFIG="$ZAPRET_BASE/config"
|
||||||
|
ZAPRET_CONFIG_NEW="$ZAPRET_BASE/config.new"
|
||||||
ZAPRET_CONFIG_DEF="$ZAPRET_BASE/config.default"
|
ZAPRET_CONFIG_DEF="$ZAPRET_BASE/config.default"
|
||||||
ZAPRET_CFG=/etc/config/zapret
|
ZAPRET_CFG=/etc/config/zapret
|
||||||
|
|
||||||
@@ -11,7 +12,7 @@ ZAPRET_CFG_SEC_NAME="$( uci -q get zapret.config )"
|
|||||||
|
|
||||||
if [ -z "$ZAPRET_CFG_SEC_NAME" ]; then
|
if [ -z "$ZAPRET_CFG_SEC_NAME" ]; then
|
||||||
# wrong uci-config
|
# wrong uci-config
|
||||||
return 1
|
return 96
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function get_sed_compat
|
function get_sed_compat
|
||||||
@@ -20,6 +21,13 @@ function get_sed_compat
|
|||||||
echo "$str"
|
echo "$str"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function is_valid_sh_syntax
|
||||||
|
{
|
||||||
|
local fname=${1:-$ZAPRET_CONFIG}
|
||||||
|
sh -n "$fname" &>/dev/null
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
function uncomment_param
|
function uncomment_param
|
||||||
{
|
{
|
||||||
local param=$1
|
local param=$1
|
||||||
@@ -80,6 +88,10 @@ if [ ! -f "$ZAPRET_CONFIG" ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cp -f "$ZAPRET_CONFIG" "$ZAPRET_CONFIG_NEW"
|
||||||
|
|
||||||
|
ZAPRET_CONFIG="$ZAPRET_CONFIG_NEW"
|
||||||
|
|
||||||
sync_param FWTYPE
|
sync_param FWTYPE
|
||||||
sync_param POSTNAT
|
sync_param POSTNAT
|
||||||
sync_param FLOWOFFLOAD
|
sync_param FLOWOFFLOAD
|
||||||
@@ -105,3 +117,13 @@ sync_param NFQWS_UDP_PKT_IN str
|
|||||||
sync_param NFQWS_PORTS_TCP_KEEPALIVE
|
sync_param NFQWS_PORTS_TCP_KEEPALIVE
|
||||||
sync_param NFQWS_PORTS_UDP_KEEPALIVE
|
sync_param NFQWS_PORTS_UDP_KEEPALIVE
|
||||||
sync_param NFQWS_OPT str
|
sync_param NFQWS_OPT str
|
||||||
|
|
||||||
|
ZAPRET_CONFIG="$ZAPRET_BASE/config"
|
||||||
|
|
||||||
|
if is_valid_sh_syntax "$ZAPRET_CONFIG_NEW" ; then
|
||||||
|
cp -f "$ZAPRET_CONFIG_NEW" "$ZAPRET_CONFIG"
|
||||||
|
rm -f "$ZAPRET_CONFIG_NEW"
|
||||||
|
else
|
||||||
|
rm -f "$ZAPRET_CONFIG_NEW"
|
||||||
|
return 97
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user