@@ -168,7 +168,7 @@ output_okbn() { output 1 "$_OKB_\n"; output 2 "$__OKB__\n"; }
168
168
output_fail () { output 1 " $_FAIL_ " ; output 2 " $__FAIL__ \n" ; }
169
169
output_failn () { output 1 " $_FAIL_ \n" ; output 2 " $__FAIL__ \n" ; }
170
170
output_error () { output " ${_ERROR_} $* !\n" ; }
171
- output_warning () { output " ${_WARNING_} $* ! \n" ; }
171
+ output_warning () { output " ${_WARNING_} $* . \n" ; }
172
172
quiet_mode () {
173
173
case " $1 " in
174
174
on) verbosity=0;;
@@ -358,65 +358,63 @@ try() {
358
358
}
359
359
360
360
get_text () {
361
- local r
362
- case " $1 " in
363
- errorConfigValidation) r=" Config ($packageConfigFile ) validation failure!" ;;
364
- errorNoNft) r=" Resolver set support (${resolver_set} ) requires nftables, but nft binary cannot be found!" ;;
365
- errorResolverNotSupported) r=" Resolver set (${resolver_set} ) is not supported on this system!" ;;
366
- errorServiceDisabled) r=" The ${packageName} service is currently disabled" ;;
367
- errorNoWanGateway) r=" The ${serviceName} service failed to discover WAN gateway!" ;;
368
- errorNoWanInterface) r=" The %s interface not found, you need to set the 'pbr.config.procd_wan_interface' option!" ;;
369
- errorNoWanInterfaceHint) r=" Refer to https://docs.openwrt.melmac.ca/pbr/#procd_wan_interface." ;;
370
- errorNftsetNameTooLong) r=" The nft set name '%s' is longer than allowed 255 characters!" ;;
371
- errorUnexpectedExit) r=" Unexpected exit or service termination: '%s'!" ;;
372
- errorPolicyNoSrcDest) r=" Policy '%s' has no source/destination parameters!" ;;
373
- errorPolicyNoInterface) r=" Policy '%s' has no assigned interface!" ;;
374
- errorPolicyNoDns) r=" Policy '%s' has no assigned DNS!" ;;
375
- errorPolicyProcessNoInterfaceDns) r=" Interface '%s' has no assigned DNS!" ;;
376
- errorPolicyUnknownInterface) r=" Policy '%s' has an unknown interface!" ;;
377
- errorPolicyProcessCMD) r=" '%s'!" ;;
378
- errorFailedSetup) r=" Failed to set up '%s'!" ;;
379
- errorFailedReload) r=" Failed to reload '%s'!" ;;
380
- errorUserFileNotFound) r=" Custom user file '%s' not found or empty!" ;;
381
- errorUserFileSyntax) r=" Syntax error in custom user file '%s'!" ;;
382
- errorUserFileRunning) r=" Error running custom user file '%s'!" ;;
383
- errorUserFileNoCurl) r=" Use of 'curl' is detected in custom user file '%s', but 'curl' isn't installed!" ;;
384
- errorNoGateways) r=" Failed to set up any gateway!" ;;
385
- errorResolver) r=" Resolver '%s'!" ;;
386
- errorPolicyProcessNoIpv6) r=" Skipping IPv6 policy '%s' as IPv6 support is disabled!" ;;
387
- errorPolicyProcessUnknownFwmark) r=" Unknown packet mark for interface '%s'!" ;;
388
- errorPolicyProcessMismatchFamily) r=" Mismatched IP family between in policy '%s'!" ;;
389
- errorPolicyProcessUnknownProtocol) r=" Unknown protocol in policy '%s'!" ;;
390
- errorPolicyProcessInsertionFailed) r=" Insertion failed for both IPv4 and IPv6 for policy '%s'!" ;;
391
- errorPolicyProcessInsertionFailedIpv4) r=" Insertion failed for IPv4 for policy '%s'!" ;;
392
- errorPolicyProcessUnknownEntry) r=" Unknown entry in policy '%s'!" ;;
393
- errorInterfaceRoutingEmptyValues) r=" Received empty tid/mark or interface name when setting up routing!" ;;
394
- errorFailedToResolve) r=" Failed to resolve '%s'!" ;;
395
- errorTryFailed) r=" Command failed: %s" ;;
396
- errorNftFileInstall) r=" Failed to install fw4 nft file '%s'!" ;;
397
- errorDownloadUrlNoHttps) r=" Failed to download '%s', HTTPS is not supported!" ;;
398
- errorDownloadUrl) r=" Failed to download '%s'!" ;;
399
- errorNoDownloadWithSecureReload) r=" Policy '%s' refers to URL which can't be downloaded in 'secure_reload' mode!" ;;
400
- errorFileSchemaRequiresCurl) r=" The file:// schema requires curl, but it's not detected on this system!" ;;
401
- errorIncompatibleUserFile) r=" Incompatible custom user file detected '%s'!" ;;
402
- errorDefaultFw4TableMissing) r=" Default fw4 table '%s' is missing!" ;;
403
- errorDefaultFw4ChainMissing) r=" Default fw4 chain '%s' is missing!" ;;
404
- errorRequiredBinaryMissing) r=" Required binary '%s' is missing!" ;;
405
- errorInterfaceRoutingUnknownDevType) r=" Unknown IPv6 Link type for device '%s'!" ;;
406
- errorUplinkDown) r=" Uplink/WAN interface is still down, increase value of 'procd_boot_trigger_delay' option" ;;
407
- warningInvalidOVPNConfig) r=" Invalid OpenVPN config for '%s' interface." ;;
408
- warningResolverNotSupported) r=" Resolver set (${resolver_set} ) is not supported on this system." ;;
409
- warningPolicyProcessCMD) r=" '%s'" ;;
410
- warningTorUnsetParams) r=" Please unset 'src_addr', 'src_port' and 'dest_port' for policy '%s'." ;;
411
- warningTorUnsetProto) r=" Please unset 'proto' or set 'proto' to 'all' for policy '%s'." ;;
412
- warningTorUnsetChainNft) r=" Please unset 'chain' or set 'chain' to 'prerouting' for policy '%s'." ;;
413
- warningOutdatedWebUIApp) r=" The WebUI application is outdated (version %s), please update it." ;;
414
- warningBadNftCallsInUserFile) r=" Incompatible nft calls detected in user include file, disabling fw4 nft file support." ;;
415
- warningDnsmasqInstanceNoConfdir) r=" Dnsmasq instance '%s' targeted in settings, but it doesn't have its own confdir." ;;
416
- warningDhcpLanForce) r=" Please set 'dhcp.%s.force=1' to speed up service start-up." ;;
417
- * ) r=" Unknown error '%s'!" ;;
361
+ local r=" $1 " ; shift ;
362
+ case " $r " in
363
+ errorConfigValidation) printf " Config (%s) validation failure" " $$ packageConfigFile" ;;
364
+ errorNoNft) printf " Resolver set support (%s) requires nftables, but nft binary cannot be found" " $resolver_set " ;;
365
+ errorResolverNotSupported) printf " Resolver set (%s) is not supported on this system" " $resolver_set " ;;
366
+ errorServiceDisabled) printf " The %s service is currently disabled" " $packageName " ;;
367
+ errorNoWanGateway) printf " The %s service failed to discover WAN gateway" " $serviceName " ;;
368
+ errorNoWanInterface) printf " The %s interface not found, you need to set the 'pbr.config.procd_wan_interface' option" " $@ " ;;
369
+ errorNoWanInterfaceHint) printf " Refer to %s" ' https://docs.openwrt.melmac.ca/pbr/#procd_wan_interface' ;;
370
+ errorNftsetNameTooLong) printf " The nft set name '%s' is longer than allowed 255 characters" " $@ " ;;
371
+ errorUnexpectedExit) printf " Unexpected exit or service termination: '%s'" " $@ " ;;
372
+ errorPolicyNoSrcDest) printf " Policy '%s' has no source/destination parameters" " $@ " ;;
373
+ errorPolicyNoInterface) printf " Policy '%s' has no assigned interface" " $@ " ;;
374
+ errorPolicyNoDns) printf " Policy '%s' has no assigned DNS" " $@ " ;;
375
+ errorPolicyProcessNoInterfaceDns) printf " Interface '%s' has no assigned DNS" " $@ " ;;
376
+ errorPolicyUnknownInterface) printf " Policy '%s' has an unknown interface" " $@ " ;;
377
+ errorPolicyProcessCMD) printf " '%s'" " $@ " ;;
378
+ errorFailedSetup) printf " Failed to set up '%s'" " $@ " ;;
379
+ errorFailedReload) printf " Failed to reload '%s'" " $@ " ;;
380
+ errorUserFileNotFound) printf " Custom user file '%s' not found or empty" " $@ " ;;
381
+ errorUserFileSyntax) printf " Syntax error in custom user file '%s'" " $@ " ;;
382
+ errorUserFileRunning) printf " Error running custom user file '%s'" " $@ " ;;
383
+ errorUserFileNoCurl) printf " Use of 'curl' is detected in custom user file '%s', but 'curl' isn't installed" " $@ " ;;
384
+ errorNoGateways) printf " Failed to set up any gateway" ;;
385
+ errorResolver) printf " Resolver '%s'" " $@ " ;;
386
+ errorPolicyProcessNoIpv6) printf " Skipping IPv6 policy '%s' as IPv6 support is disabled" " $@ " ;;
387
+ errorPolicyProcessUnknownFwmark) printf " Unknown packet mark for interface '%s'" " $@ " ;;
388
+ errorPolicyProcessMismatchFamily) printf " Mismatched IP family between in policy '%s'" " $@ " ;;
389
+ errorPolicyProcessUnknownProtocol) printf " Unknown protocol in policy '%s'" " $@ " ;;
390
+ errorPolicyProcessInsertionFailed) printf " Insertion failed for both IPv4 and IPv6 for policy '%s'" " $@ " ;;
391
+ errorPolicyProcessInsertionFailedIpv4) printf " Insertion failed for IPv4 for policy '%s'" " $@ " ;;
392
+ errorPolicyProcessUnknownEntry) printf " Unknown entry in policy '%s'" " $@ " ;;
393
+ errorInterfaceRoutingEmptyValues) printf " Received empty tid/mark or interface name when setting up routing" ;;
394
+ errorFailedToResolve) printf " Failed to resolve '%s'" " $@ " ;;
395
+ errorTryFailed) printf " Command failed: %s" " $@ " ;;
396
+ errorNftFileInstall) printf " Failed to install fw4 nft file '%s'" " $@ " ;;
397
+ errorDownloadUrlNoHttps) printf " Failed to download '%s', HTTPS is not supported" " $@ " ;;
398
+ errorDownloadUrl) printf " Failed to download '%s'" " $@ " ;;
399
+ errorNoDownloadWithSecureReload) printf " Policy '%s' refers to URL which can't be downloaded in 'secure_reload' mode" " $@ " ;;
400
+ errorFileSchemaRequiresCurl) printf " The file:// schema requires curl, but it's not detected on this system" ;;
401
+ errorIncompatibleUserFile) printf " Incompatible custom user file detected '%s'" " $@ " ;;
402
+ errorDefaultFw4TableMissing) printf " Default fw4 table '%s' is missing" " $@ " ;;
403
+ errorDefaultFw4ChainMissing) printf " Default fw4 chain '%s' is missing" " $@ " ;;
404
+ errorRequiredBinaryMissing) printf " Required binary '%s' is missing" " $@ " ;;
405
+ errorInterfaceRoutingUnknownDevType) printf " Unknown IPv6 Link type for device '%s'" " $@ " ;;
406
+ errorUplinkDown) printf " Uplink/WAN interface is still down, increase value of 'procd_boot_trigger_delay' option" ;;
407
+ warningInvalidOVPNConfig) printf " Invalid OpenVPN config for '%s' interface" " $@ " ;;
408
+ warningResolverNotSupported) printf " Resolver set (%s) is not supported on this system" " $resolver_set " ;;
409
+ warningPolicyProcessCMD) printf " '%s'" " $@ " ;;
410
+ warningTorUnsetParams) printf " Please unset 'src_addr', 'src_port' and 'dest_port' for policy '%s'" " $@ " ;;
411
+ warningTorUnsetProto) printf " Please unset 'proto' or set 'proto' to 'all' for policy '%s'" " $@ " ;;
412
+ warningTorUnsetChainNft) printf " Please unset 'chain' or set 'chain' to 'prerouting' for policy '%s'" " $@ " ;;
413
+ warningOutdatedWebUIApp) printf " The WebUI application is outdated (version %s), please update it" " $@ " ;;
414
+ warningDnsmasqInstanceNoConfdir) printf " Dnsmasq instance '%s' targeted in settings, but it doesn't have its own confdir" " $@ " ;;
415
+ warningDhcpLanForce) printf " Please set 'dhcp.%s.force=1' to speed up service start-up" " $@ " ;;
416
+ * ) printf " Unknown error/warning '%s'" " $@ " ;;
418
417
esac
419
- echo " $r "
420
418
}
421
419
422
420
process_url () {
@@ -572,9 +570,9 @@ load_environment() {
572
570
}
573
571
local param=" $1 " validation_result=" $2 "
574
572
[ -z " $load_environment_flag " ] || return 0
575
- json init
576
573
case " $param " in
577
574
on_boot|on_start)
575
+ json init
578
576
output 1 " Loading environment ($param ) "
579
577
load_package_config " $param "
580
578
if [ " $enabled " -eq ' 0' ]; then
@@ -598,6 +596,7 @@ load_environment() {
598
596
output 1 " $_OK_ \n"
599
597
;;
600
598
on_stop)
599
+ json init
601
600
output 1 " Loading environment ($param ) "
602
601
load_package_config " $param "
603
602
load_network " $param "
@@ -870,20 +869,19 @@ json() {
870
869
{ json_load_file " $runningStatusFile " || json_init; } > /dev/null 2>&1
871
870
case " $action " in
872
871
' get' )
873
- if json_select " $param " > /dev/null 2>&1 ; then
874
- if [ -n " $value " ]; then
875
- {
876
- if json_select " $value " ; then
877
- json_get_var ' i' " ${info:- code} "
878
- json_select ..
879
- fi
880
- } > /dev/null 2>&1
881
- else
882
- json_get_keys i
872
+ json_select " $param " > /dev/null 2>&1 || return
873
+ if [ -n " $value " ]; then
874
+ {
875
+ if json_select " $value " ; then
876
+ json_get_var ' i' " ${info:- code} "
877
+ json_select ..
883
878
fi
884
- printf " %b" " $i "
885
- json_select ..
879
+ } > /dev/null 2>&1
880
+ else
881
+ json_get_keys i
886
882
fi
883
+ printf " %b" " $i "
884
+ json_select ..
887
885
return
888
886
;;
889
887
' add' )
@@ -2020,9 +2018,13 @@ on_interface_reload() {
2020
2018
start_service () {
2021
2019
local resolverStoredHash resolverNewHash i param=" $1 " reloadedIface k
2022
2020
2023
- [ -n " $pbr_boot_flag " ] && return 0
2024
- [ " $param " = ' on_boot' ] && return 0
2021
+ # [ -n "$pbr_boot_flag" ] && return 0
2022
+ # [ "$param" = 'on_boot' ] && return 0
2025
2023
load_environment " ${param:- on_start} " " $( load_validate_config) " || return 1
2024
+ if [ -n " $pbr_boot_flag " ] || [ " $param " = ' on_boot' ]; then
2025
+ [ -n " $wanGW " ] || return 0
2026
+ unset pbr_boot_flag
2027
+ fi
2026
2028
2027
2029
output " Processing environment (${param:- on_start} ) "
2028
2030
is_wan_up " $param " || { output_error " $( get_text ' errorUplinkDown' ) " ; return 1; }
@@ -2226,7 +2228,9 @@ service_triggers() {
2226
2228
procd_close_validate
2227
2229
if [ -n " $pbr_boot_flag " ] && is_integer " $procd_boot_trigger_delay " ; then
2228
2230
output " Setting trigger (on_boot) "
2229
- procd_add_raw_trigger " interface.*.up" " $procd_boot_trigger_delay " " /etc/init.d/${packageName} " start && output_okn || output_failn
2231
+ procd_open_trigger
2232
+ procd_add_raw_trigger " interface.*.up" " $procd_boot_trigger_delay " " /etc/init.d/${packageName} " start && output_okn || output_failn
2233
+ procd_close_trigger
2230
2234
else
2231
2235
procd_open_trigger
2232
2236
procd_add_config_trigger " config.change" ' openvpn' " /etc/init.d/${packageName} " reload ' on_openvpn_change'
0 commit comments