GUACAMOLE-374: Merge fix xmlstarlet syntax for RemoteIpValve attributes

This commit is contained in:
Virtually Nick
2024-07-30 14:14:03 -04:00
committed by GitHub

View File

@@ -29,7 +29,7 @@
## RemoteIpValve attributes that correspond to various "REMOTE_IP_VALVE_*" ## RemoteIpValve attributes that correspond to various "REMOTE_IP_VALVE_*"
## environment variables. ## environment variables.
## ##
declare -a VALVE_ATTRIBUTES=( --type attr -n className -v org.apache.catalina.valves.RemoteIpValve ) declare -a VALVE_ATTRIBUTES=( --insert '/Server/Service/Engine/Host/Valve[not(@className)]' --type attr -n className -v org.apache.catalina.valves.RemoteIpValve )
# Translate all properties supported by RemoteIpValve into corresponding # Translate all properties supported by RemoteIpValve into corresponding
# environment variables # environment variables
@@ -45,7 +45,7 @@ for ATTRIBUTE in \
VAR_NAME="REMOTE_IP_VALVE_$(echo "$ATTRIBUTE" | sed 's/\([a-z]\)\([A-Z]\)/\1_\2/g' | tr 'a-z' 'A-Z')" VAR_NAME="REMOTE_IP_VALVE_$(echo "$ATTRIBUTE" | sed 's/\([a-z]\)\([A-Z]\)/\1_\2/g' | tr 'a-z' 'A-Z')"
if [ -n "${!VAR_NAME}" ]; then if [ -n "${!VAR_NAME}" ]; then
VALVE_ATTRIBUTES+=( --type attr -n "$ATTRIBUTE" -v "${!VAR_NAME}" ) VALVE_ATTRIBUTES+=( --insert '/Server/Service/Engine/Host/Valve[@className="org.apache.catalina.valves.RemoteIpValve"]' --type attr -n "$ATTRIBUTE" -v "${!VAR_NAME}" )
else else
echo "Using default RemoteIpValve value for \"$ATTRIBUTE\" attribute." echo "Using default RemoteIpValve value for \"$ATTRIBUTE\" attribute."
fi fi
@@ -55,7 +55,6 @@ done
# Programmatically add requested RemoteIpValve entry # Programmatically add requested RemoteIpValve entry
xmlstarlet edit --inplace \ xmlstarlet edit --inplace \
--insert '/Server/Service/Engine/Host/*' --type elem -n Valve \ --insert '/Server/Service/Engine/Host/*' --type elem -n Valve \
--insert '/Server/Service/Engine/Host/Valve[not(@className)]' \
"${VALVE_ATTRIBUTES[@]}" \ "${VALVE_ATTRIBUTES[@]}" \
"$CATALINA_BASE/conf/server.xml" "$CATALINA_BASE/conf/server.xml"