This repository was archived by the owner on Jan 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
src/etc/one-context.d/loc-10-network.d Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ initialize_network()
5454 # shellcheck disable=SC2154
5555 [ " ${action} " = ' configure' ] || return 0
5656
57+ export onegate_proxy_route_missing=" yes" # flag route not setup
58+
5759 _context_interfaces=$( get_context_interfaces)
5860 _iface_mac=$( get_interface_mac)
5961
@@ -593,16 +595,14 @@ is_link_local() {
593595}
594596
595597get_onegate_ip () {
596- if [[ -n $ONEGATE_ENDPOINT ]]; then
597- # Regular expression to match an IPv4 address
598- ipv4_regex=" ([0-9]{1,3}\.){3}[0-9]{1,3}"
599-
600- export onegate_host=$( echo " $ONEGATE_ENDPOINT " | grep -oE " $ipv4_regex " )
598+ if [[ -n $ONEGATE_ENDPOINT ]]; then
599+ # Regular expression to match an IPv4 address
600+ ipv4_regex=" ([0-9]{1,3}\.){3}[0-9]{1,3}"
601601
602- echo " $onegate_host "
603- fi
602+ export onegate_host= $( echo " $ONEGATE_ENDPOINT " | grep -oE " $ipv4_regex " )
603+ fi
604604}
605605
606606add_onegate_proxy_route? () {
607- is_link_local " $( get_onegate_ip ) " && [[ $onegate_proxy_route_missing == " yes" ]]
607+ is_link_local " $onegate_host " && [[ $onegate_proxy_route_missing == " yes" ]]
608608}
Original file line number Diff line number Diff line change @@ -163,7 +163,8 @@ gen_iface_conf()
163163 fi
164164
165165 # Add ONEGATE Proxy static route
166- if [[ $( add_onegate_proxy_route? ) ]]; then
166+ get_onegate_ip
167+ if add_onegate_proxy_route? ; then
167168 route_name=" r_onegateproxy"
168169
169170 sed -i " s/${route_names} /${route_names} ${route_name} /g" " $routes_conf_path "
Original file line number Diff line number Diff line change 175175 fi
176176
177177 # Add ONEGATE Proxy static route
178- if [[ $( add_onegate_proxy_route? ) ]]; then
179- echo " up ip route replace ${onegate_host} via ${dev} "
178+ get_onegate_ip
179+ if add_onegate_proxy_route? ; then
180+ echo " up ip route replace ${onegate_host} dev ${dev} "
180181
181182 # Will make proxy static route only applicable to 1st interface
182183 unset onegate_proxy_route_missing
375376
376377 _context_interfaces=$( get_context_interfaces)
377378
378- export onegate_proxy_route_missing=" yes" # flag route not setup
379-
380379 for _iface in $_context_interfaces ; do
381380 setup_iface_vars " $_iface "
382381
Original file line number Diff line number Diff line change 167167 fi
168168
169169 # Add ONEGATE Proxy static route
170- if [[ $( add_onegate_proxy_route? ) ]]; then
170+ get_onegate_ip
171+ if add_onegate_proxy_route? ; then
171172 # ip route replace 169.254.16.9/32 via eth0
172173 cat << EOT
173174 - to: "${onegate_host} "
Original file line number Diff line number Diff line change 137137 fi
138138
139139 # Add ONEGATE Proxy static route
140- if [[ $( add_onegate_proxy_route? ) ]]; then
140+ get_onegate_ip
141+ if add_onegate_proxy_route? ; then
141142 # ip route replace 169.254.16.9/32 via eth0
142143 echo " [Route]"
143144 echo " Destination=${onegate_host} "
Original file line number Diff line number Diff line change @@ -140,7 +140,8 @@ gen_iface_conf()
140140 fi
141141
142142 # Add ONEGATE Proxy static route
143- if [[ $( add_onegate_proxy_route? ) ]]; then
143+ get_onegate_ip
144+ if add_onegate_proxy_route? ; then
144145 # ip route replace 169.254.16.9/32 via eth0
145146 nmcli con mod " $dev " +ipv4.routes " $onegate_host "
146147
Original file line number Diff line number Diff line change 141141 fi
142142
143143 # Add ONEGATE Proxy static route
144- if [[ $( add_onegate_proxy_route? ) ]]; then
145- route=" ${onegate_host} via ${dev} "
144+ get_onegate_ip
145+ if add_onegate_proxy_route? ; then
146+ route=" ${onegate_host} dev ${dev} "
146147 echo " $route " >> " ${config_path} /route-${dev} "
147148
148149 # Will make proxy static route only applicable to 1st interface
You can’t perform that action at this time.
0 commit comments