Skip to content

Commit a1343fe

Browse files
committed
Fix: mod_rpaf config wasn't updated when add/removing system ips
- Don't leave a newline behind in mod_remoteip conf on every ip removal
1 parent 42c6814 commit a1343fe

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

bin/v-add-sys-ip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ if [ ! -z "$PROXY_SYSTEM" ]; then
157157
rpaf_conf="/etc/$WEB_SYSTEM/mods-enabled/rpaf.conf"
158158
if [ -e "$rpaf_conf" ]; then
159159
rpaf_str=$(grep RPAFproxy_ips $rpaf_conf)
160+
[ -z "$rpaf_str" ] && sed -i 's|</IfModule>|RPAFproxy_ips\n</IfModule>|' $rpaf_conf && rpaf_str='RPAFproxy_ips'
160161
rpaf_str="$rpaf_str $ip"
161162
sed -i "s/.*RPAFproxy_ips.*/$rpaf_str/" $rpaf_conf
162163
fi

bin/v-delete-sys-ip

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,17 @@ if [ ! -z "$PROXY_SYSTEM" ]; then
105105
rpaf_conf="/etc/$WEB_SYSTEM/mods-enabled/rpaf.conf"
106106
if [ -e "$rpaf_conf" ]; then
107107
ips=$(grep RPAFproxy_ips $rpaf_conf)
108-
new_ips=$(echo "$rpaf_str" | sed "s/$ip//")
108+
new_ips=$(echo "$ips" | sed "s/ $ip//")
109109
sed -i "s/$ips/$new_ips/g" $rpaf_conf
110+
111+
# Remove RPAFproxy_ips line when ip list is empty
112+
[ "$(grep RPAFproxy_ips $rpaf_conf | sed 's/^[[:space:]]*//g')" = "RPAFproxy_ips" ] && sed -i "/RPAFproxy_ips/d" $rpaf_conf
110113
fi
111114

112115
#mod_remoteip
113116
remoteip_conf="/etc/$WEB_SYSTEM/mods-enabled/remoteip.conf"
114117
if [ -e "$remoteip_conf" ]; then
115-
sed -i "s/RemoteIPInternalProxy $ip//g" $remoteip_conf
118+
sed -i "/RemoteIPInternalProxy $ip\$/d" $remoteip_conf
116119
fi
117120
fi
118121

0 commit comments

Comments
 (0)