Added ZBX_ALLOWKEY and ZBX_DENYKEY variables processing

This commit is contained in:
Alexey Pustovalov 2020-07-14 00:34:02 +03:00
parent a373770baf
commit 9f1bb2118c
7 changed files with 33 additions and 10 deletions

View File

@ -1,6 +1,6 @@
# ZBX_SOURCEIP=
# ZBX_DEBUGLEVEL=3
# ZBX_ENABLEREMOTECOMMANDS=0
# ZBX_ENABLEREMOTECOMMANDS=0 # Deprecated since 5.0.0
# ZBX_LOGREMOTECOMMANDS=0
# ZBX_HOSTINTERFACE= # Available since 4.4.0
# ZBX_HOSTINTERFACEITEM= # Available since 4.4.0
@ -33,3 +33,5 @@
# ZBX_TLSKEYFILE=
# ZBX_TLSPSKIDENTITY=
# ZBX_TLSPSKFILE=
# ZBX_DENYKEY=system.run[*]
# ZBX_ALLOWKEY=

View File

@ -137,7 +137,7 @@ Additionally the image allows to specify many other environment variables listed
```
ZBX_SOURCEIP=
ZBX_ENABLEREMOTECOMMANDS=0
ZBX_ENABLEREMOTECOMMANDS=0 # Deprecated since 5.0.0
ZBX_LOGREMOTECOMMANDS=0
ZBX_HOSTINTERFACE= # Available since 4.4.0
ZBX_HOSTINTERFACEITEM= # Available since 4.4.0
@ -161,6 +161,8 @@ ZBX_TLSCERTFILE=
ZBX_TLSKEYFILE=
ZBX_TLSPSKIDENTITY=
ZBX_TLSPSKFILE=
ZBX_DENYKEY=system.run[*] # Available since 5.0.0
ZBX_ALLOWKEY= # Available since 5.0.0
```
Default values of these variables are specified after equal sign.

View File

@ -86,9 +86,12 @@ update_config_var() {
elif [ "$(grep -Ec "^# $var_name=" $config_path)" -gt 1 ]; then
sed -i -e "/^[#;] $var_name=$/i\\$var_name=$var_value" "$config_path"
echo "added first occurrence"
else
elif [ "$(grep -Ec "^[#;] $var_name=" $config_path)" -gt 0 ]; then
sed -i -e "/^[#;] $var_name=/s/.*/&\n$var_name=$var_value/" "$config_path"
echo "added"
else
sed -i -e '$a\' -e "$var_name=$var_value" "$config_path"
echo "added at the end"
fi
}
@ -130,7 +133,6 @@ prepare_zbx_agent_config() {
update_config_var $ZBX_AGENT_CONFIG "LogFileSize"
update_config_var $ZBX_AGENT_CONFIG "DebugLevel" "${ZBX_DEBUGLEVEL}"
update_config_var $ZBX_AGENT_CONFIG "SourceIP"
update_config_var $ZBX_AGENT_CONFIG "EnableRemoteCommands" "${ZBX_ENABLEREMOTECOMMANDS}"
update_config_var $ZBX_AGENT_CONFIG "LogRemoteCommands" "${ZBX_LOGREMOTECOMMANDS}"
: ${ZBX_PASSIVE_ALLOW:="true"}
@ -182,6 +184,9 @@ prepare_zbx_agent_config() {
update_config_var $ZBX_AGENT_CONFIG "TLSPSKIdentity" "${ZBX_TLSPSKIDENTITY}"
update_config_var $ZBX_AGENT_CONFIG "TLSPSKFile" "${ZBX_TLSPSKFILE}"
update_config_multiple_var $ZBX_AGENT_CONFIG "DenyKey" "${ZBX_DENYKEY}"
update_config_multiple_var $ZBX_AGENT_CONFIG "AllowKey" "${ZBX_ALLOWKEY}"
if [ "$(id -u)" != '0' ]; then
update_config_var $ZBX_AGENT_CONFIG "User" "$(whoami)"
else

View File

@ -137,7 +137,7 @@ Additionally the image allows to specify many other environment variables listed
```
ZBX_SOURCEIP=
ZBX_ENABLEREMOTECOMMANDS=0
ZBX_ENABLEREMOTECOMMANDS=0 # Deprecated since 5.0.0
ZBX_LOGREMOTECOMMANDS=0
ZBX_HOSTINTERFACE= # Available since 4.4.0
ZBX_HOSTINTERFACEITEM= # Available since 4.4.0
@ -161,6 +161,8 @@ ZBX_TLSCERTFILE=
ZBX_TLSKEYFILE=
ZBX_TLSPSKIDENTITY=
ZBX_TLSPSKFILE=
ZBX_DENYKEY=system.run[*] # Available since 5.0.0
ZBX_ALLOWKEY= # Available since 5.0.0
```
Default values of these variables are specified after equal sign.

View File

@ -86,9 +86,12 @@ update_config_var() {
elif [ "$(grep -Ec "^# $var_name=" $config_path)" -gt 1 ]; then
sed -i -e "/^[#;] $var_name=$/i\\$var_name=$var_value" "$config_path"
echo "added first occurrence"
else
elif [ "$(grep -Ec "^[#;] $var_name=" $config_path)" -gt 0 ]; then
sed -i -e "/^[#;] $var_name=/s/.*/&\n$var_name=$var_value/" "$config_path"
echo "added"
else
sed -i -e '$a\' -e "$var_name=$var_value" "$config_path"
echo "added at the end"
fi
}
@ -130,7 +133,6 @@ prepare_zbx_agent_config() {
update_config_var $ZBX_AGENT_CONFIG "LogFileSize"
update_config_var $ZBX_AGENT_CONFIG "DebugLevel" "${ZBX_DEBUGLEVEL}"
update_config_var $ZBX_AGENT_CONFIG "SourceIP"
update_config_var $ZBX_AGENT_CONFIG "EnableRemoteCommands" "${ZBX_ENABLEREMOTECOMMANDS}"
update_config_var $ZBX_AGENT_CONFIG "LogRemoteCommands" "${ZBX_LOGREMOTECOMMANDS}"
: ${ZBX_PASSIVE_ALLOW:="true"}
@ -182,6 +184,9 @@ prepare_zbx_agent_config() {
update_config_var $ZBX_AGENT_CONFIG "TLSPSKIdentity" "${ZBX_TLSPSKIDENTITY}"
update_config_var $ZBX_AGENT_CONFIG "TLSPSKFile" "${ZBX_TLSPSKFILE}"
update_config_multiple_var $ZBX_AGENT_CONFIG "DenyKey" "${ZBX_DENYKEY}"
update_config_multiple_var $ZBX_AGENT_CONFIG "AllowKey" "${ZBX_ALLOWKEY}"
if [ "$(id -u)" != '0' ]; then
update_config_var $ZBX_AGENT_CONFIG "User" "$(whoami)"
else

View File

@ -137,7 +137,7 @@ Additionally the image allows to specify many other environment variables listed
```
ZBX_SOURCEIP=
ZBX_ENABLEREMOTECOMMANDS=0
ZBX_ENABLEREMOTECOMMANDS=0 # Deprecated since 5.0.0
ZBX_LOGREMOTECOMMANDS=0
ZBX_HOSTINTERFACE= # Available since 4.4.0
ZBX_HOSTINTERFACEITEM= # Available since 4.4.0
@ -161,6 +161,8 @@ ZBX_TLSCERTFILE=
ZBX_TLSKEYFILE=
ZBX_TLSPSKIDENTITY=
ZBX_TLSPSKFILE=
ZBX_DENYKEY=system.run[*] # Available since 5.0.0
ZBX_ALLOWKEY= # Available since 5.0.0
```
Default values of these variables are specified after equal sign.

View File

@ -86,9 +86,12 @@ update_config_var() {
elif [ "$(grep -Ec "^# $var_name=" $config_path)" -gt 1 ]; then
sed -i -e "/^[#;] $var_name=$/i\\$var_name=$var_value" "$config_path"
echo "added first occurrence"
else
elif [ "$(grep -Ec "^[#;] $var_name=" $config_path)" -gt 0 ]; then
sed -i -e "/^[#;] $var_name=/s/.*/&\n$var_name=$var_value/" "$config_path"
echo "added"
else
sed -i -e '$a\' -e "$var_name=$var_value" "$config_path"
echo "added at the end"
fi
}
@ -130,7 +133,6 @@ prepare_zbx_agent_config() {
update_config_var $ZBX_AGENT_CONFIG "LogFileSize"
update_config_var $ZBX_AGENT_CONFIG "DebugLevel" "${ZBX_DEBUGLEVEL}"
update_config_var $ZBX_AGENT_CONFIG "SourceIP"
update_config_var $ZBX_AGENT_CONFIG "EnableRemoteCommands" "${ZBX_ENABLEREMOTECOMMANDS}"
update_config_var $ZBX_AGENT_CONFIG "LogRemoteCommands" "${ZBX_LOGREMOTECOMMANDS}"
: ${ZBX_PASSIVE_ALLOW:="true"}
@ -182,6 +184,9 @@ prepare_zbx_agent_config() {
update_config_var $ZBX_AGENT_CONFIG "TLSPSKIdentity" "${ZBX_TLSPSKIDENTITY}"
update_config_var $ZBX_AGENT_CONFIG "TLSPSKFile" "${ZBX_TLSPSKFILE}"
update_config_multiple_var $ZBX_AGENT_CONFIG "DenyKey" "${ZBX_DENYKEY}"
update_config_multiple_var $ZBX_AGENT_CONFIG "AllowKey" "${ZBX_ALLOWKEY}"
if [ "$(id -u)" != '0' ]; then
update_config_var $ZBX_AGENT_CONFIG "User" "$(whoami)"
else