/[smecontribs]/rpms/smeserver-bridge-interface/contribs10/smeserver-bridge-interface-0.2-Move-exec-to-usr-sbin-and-add-service-file.patch
ViewVC logotype

Contents of /rpms/smeserver-bridge-interface/contribs10/smeserver-bridge-interface-0.2-Move-exec-to-usr-sbin-and-add-service-file.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Fri Jan 22 08:50:42 2021 UTC (3 years, 9 months ago) by brianr
Branch: MAIN
CVS Tags: smeserver-bridge-interface-0_2-6_el7_sme, smeserver-bridge-interface-0_2-3_el7_sme, smeserver-bridge-interface-0_2-4_el7_sme, smeserver-bridge-interface-0_2-7_el7_sme, smeserver-bridge-interface-0_2-8_el7_sme, smeserver-bridge-interface-0_2-5_el7_sme, smeserver-bridge-interface-0_2-9_el7_sme, HEAD
* Thu Jan 21 2021 Brian Read <brianr@bjsystems.co.uk> 0.2-3.sme
- Move exec to /usr/sbin, add service file [SME: 11324]

1 diff -urN smeserver-bridge-interface-0.2.old/root/etc/rc.d/init.d/bridge smeserver-bridge-interface-0.2/root/etc/rc.d/init.d/bridge
2 --- smeserver-bridge-interface-0.2.old/root/etc/rc.d/init.d/bridge 2013-11-11 17:18:21.000000000 +0000
3 +++ smeserver-bridge-interface-0.2/root/etc/rc.d/init.d/bridge 1970-01-01 01:00:00.000000000 +0100
4 @@ -1,175 +0,0 @@
5 -#!/bin/bash
6 -# Bridge service on SME
7 -# This service will configure a bridge interface on your server
8 -# allowing each enslaved interfaces to act as a switch port.
9 -
10 -# Source function library.
11 -. /etc/rc.d/init.d/functions
12 -
13 -# Bridge Interface
14 -BRIDGE_IF=$(/sbin/e-smith/db configuration getprop bridge bridgeInterface)
15 -BRIDGE_PROMISC=$(/sbin/e-smith/db configuration getprop bridge Promiscuous)
16 -
17 -# Define list of TAP interfaces to be bridged,
18 -# for example tap="tap0 tap1 tap2".
19 -# Defaults is tap0
20 -TAP_IF=$(/sbin/e-smith/db configuration getprop bridge tapInterface)
21 -# Replace ; and , with spaces
22 -TAP_IF=$(echo $TAP_IF | sed -e "s/[,;]/ /g")
23 -
24 -# Define physical ethernet interface to be bridged
25 -# with TAP interface(s) above.
26 -ETH_IF=$(/sbin/e-smith/db configuration getprop bridge ethernetInterface)
27 -ETH_MAC=$(/sbin/e-smith/db configuration getprop InternalInterface HWAddress)
28 -ETH_IP=$(/sbin/e-smith/db configuration get LocalIP)
29 -ETH_MASK=$(/sbin/e-smith/db configuration getprop InternalInterface Netmask)
30 -
31 -# System mode: serveronly, server&gateway ...
32 -MODE=$(/sbin/e-smith/db configuration get SystemMode)
33 -
34 -# Path of openvpn binary
35 -openvpn=""
36 -openvpn_locations="/usr/sbin/openvpn /usr/local/sbin/openvpn"
37 -for location in $openvpn_locations
38 -do
39 - if [ -f "$location" ]
40 - then
41 - openvpn=$location
42 - fi
43 -done
44 -
45 -# Check that binary exists
46 -if ! [ -f $openvpn ]
47 -then
48 - echo "openvpn binary not found"
49 - exit 0
50 -fi
51 -
52 -
53 -
54 -# Sub to reconfigure the firewall
55 -firewall(){
56 - /sbin/e-smith/expand-template /etc/rc.d/init.d/masq >/dev/null 2>&1
57 - /sbin/service masq restart >/dev/null 2>&1
58 -}
59 -
60 -# Sub to restart dhcpd
61 -dhcpd(){
62 - /usr/bin/sv t dhcpd
63 -}
64 -
65 -# Sub to reconfigures routes and defaults gateway
66 -routes(){
67 - # We need to push all the routes of local networks as the interface has changed
68 - for NET in $(/sbin/e-smith/db networks keys); do
69 - SYSTEM=$(/sbin/e-smith/db networks getprop $NET SystemLocalNetwork)
70 - if (! test $SYSTEM); then
71 - NETMASK=$(/sbin/e-smith/db networks getprop $NET Mask)
72 - ROUTER=$(/sbin/e-smith/db networks getprop $NET Router)
73 - /sbin/route add -net $NET netmask $NETMASK gw $ROUTER >/dev/null 2>&1
74 - fi
75 - done
76 -
77 - # If the server runs in serveronly, we need to reconfigure the default gateway:
78 - if [ $MODE == 'serveronly' ]; then
79 - GW=$(/sbin/e-smith/db configuration get GatewayIP)
80 - /sbin/route add default gw $GW >/dev/null 2>&1
81 - fi
82 -}
83 -
84 -start(){
85 - # First, create the bridge interface
86 - /usr/sbin/brctl addbr $BRIDGE_IF
87 -
88 - # Then, create the tap interface(s) and enslave it in the bridge one
89 - for t in $TAP_IF; do
90 - $openvpn --mktun --dev $t >/dev/null 2>&1
91 - /sbin/ifconfig $t 0.0.0.0 promisc up >/dev/null 2>&1
92 - /usr/sbin/brctl addif $BRIDGE_IF $t >/dev/null 2>&1
93 - done
94 -
95 - # Now make the real ethernet interface promiscuous
96 - /sbin/ifconfig $ETH_IF 0.0.0.0 promisc up >/dev/null 2>&1
97 - sleep 1
98 -
99 - # And add it to the bridge
100 - /usr/sbin/brctl addif $BRIDGE_IF $ETH_IF >/dev/null 2>&1
101 -
102 - [ -n "$ETH_MAC" ] && /sbin/ifconfig $BRIDGE_IF hw ether $ETH_MAC
103 -
104 - [ "$BRIDGE_PROMISC" == "yes" ] && /sbin/ifconfig $BRIDGE_IF promisc
105 -
106 - # Now configure the LocalIP on the bridge interface
107 - /sbin/e-smith/db configuration setprop InternalInterface Name $BRIDGE_IF
108 - /sbin/ifconfig $BRIDGE_IF $ETH_IP netmask $ETH_MASK >/dev/null 2>&1
109 -
110 - # Push the routes for the new interface
111 - routes
112 -
113 - # Now we have to reconfigure the firewall
114 - firewall
115 -
116 - # And dhcpd (the configuration file is expanded each time the service starts
117 - # so no need to do it manually
118 - dhcpd
119 -}
120 -
121 -stop(){
122 - # Shutdown the bridge and remove it
123 - /sbin/ifconfig $BRIDGE_IF down >/dev/null 2>&1
124 - /usr/sbin/brctl delbr $BRIDGE_IF >/dev/null 2>&1
125 -
126 - # Then delete each tap interfaces
127 - for t in $TAP_IF; do
128 - $openvpn --rmtun --dev $t >/dev/null 2>&1
129 - done
130 -
131 - # Reconfigure the ethernet interface
132 - /sbin/e-smith/db configuration setprop InternalInterface Name $ETH_IF
133 - /sbin/ifconfig $ETH_IF $ETH_IP netmask $ETH_MASK up -promisc >/dev/null 2>&1
134 -
135 - # Push the routes
136 - routes
137 -
138 - # restart the firewall
139 - firewall
140 -
141 - # and dhcp
142 - dhcpd
143 -}
144 -
145 -case "$1" in
146 - start)
147 - echo -n $"Starting Bridge Service: "
148 - start
149 - RETVAL=$?
150 - ;;
151 - stop)
152 - echo -n $"Stoping Bridge Service: "
153 - stop
154 - RETVAL=$?
155 - ;;
156 - restart)
157 - echo -n $"Restarting Bridge Service: "
158 - stop && start
159 - RETVAL=$?
160 - ;;
161 - adjust)
162 - echo -n $"Restarting Bridge Service: "
163 - stop && start
164 - RETVAL=$?
165 - ;;
166 - *)
167 - echo "Usage: $0 start|stop|restart"
168 - ;;
169 -esac
170 -
171 -if [ $RETVAL -eq 0 ]; then
172 - echo_success
173 -else
174 - echo_failure
175 -fi
176 -echo
177 -
178 -exit $RETVAL
179 -
180 diff -urN smeserver-bridge-interface-0.2.old/root/usr/lib/systemd/system/bridge-interface.service smeserver-bridge-interface-0.2/root/usr/lib/systemd/system/bridge-interface.service
181 --- smeserver-bridge-interface-0.2.old/root/usr/lib/systemd/system/bridge-interface.service 1970-01-01 01:00:00.000000000 +0100
182 +++ smeserver-bridge-interface-0.2/root/usr/lib/systemd/system/bridge-interface.service 2021-01-22 06:44:05.543729313 +0000
183 @@ -0,0 +1,9 @@
184 +[Unit]
185 +Description=Bridge Interface for VPN use.
186 +After=network.target
187 +[Service]
188 +Type=forking
189 +ExecStart=/usr/sbin/bridge-interface start
190 +ExecStop=/usr/sbin/bridge-interface stop
191 +[Install]
192 +WantedBy=sme-server.target
193 diff -urN smeserver-bridge-interface-0.2.old/root/usr/sbin/bridge-interface smeserver-bridge-interface-0.2/root/usr/sbin/bridge-interface
194 --- smeserver-bridge-interface-0.2.old/root/usr/sbin/bridge-interface 1970-01-01 01:00:00.000000000 +0100
195 +++ smeserver-bridge-interface-0.2/root/usr/sbin/bridge-interface 2021-01-21 18:29:24.609405670 +0000
196 @@ -0,0 +1,178 @@
197 +#!/bin/bash
198 +# Bridge service on SME
199 +# This service will configure a bridge interface on your server
200 +# allowing each enslaved interfaces to act as a switch port.
201 +
202 +# Source function library.
203 +. /etc/rc.d/init.d/functions
204 +
205 +# Bridge Interface
206 +BRIDGE_IF=$(/sbin/e-smith/db configuration getprop bridge bridgeInterface)
207 +BRIDGE_PROMISC=$(/sbin/e-smith/db configuration getprop bridge Promiscuous)
208 +
209 +# Define list of TAP interfaces to be bridged,
210 +# for example tap="tap0 tap1 tap2".
211 +# Defaults is tap0
212 +TAP_IF=$(/sbin/e-smith/db configuration getprop bridge tapInterface)
213 +# Replace ; and , with spaces
214 +TAP_IF=$(echo $TAP_IF | sed -e "s/[,;]/ /g")
215 +
216 +# Define physical ethernet interface to be bridged
217 +# with TAP interface(s) above.
218 +ETH_IF=$(/sbin/e-smith/db configuration getprop bridge ethernetInterface)
219 +ETH_MAC=$(/sbin/e-smith/db configuration getprop InternalInterface HWAddress)
220 +ETH_IP=$(/sbin/e-smith/db configuration get LocalIP)
221 +ETH_MASK=$(/sbin/e-smith/db configuration getprop InternalInterface Netmask)
222 +
223 +# System mode: serveronly, server&gateway ...
224 +MODE=$(/sbin/e-smith/db configuration get SystemMode)
225 +
226 +# Path of openvpn binary
227 +openvpn=""
228 +openvpn_locations="/usr/sbin/openvpn /usr/local/sbin/openvpn"
229 +for location in $openvpn_locations
230 +do
231 + if [ -f "$location" ]
232 + then
233 + openvpn=$location
234 + fi
235 +done
236 +
237 +# Check that binary exists
238 +if ! [ -f $openvpn ]
239 +then
240 + echo "openvpn binary not found"
241 + exit 0
242 +fi
243 +
244 +
245 +
246 +# Sub to reconfigure the firewall
247 +firewall(){
248 + /sbin/e-smith/expand-template /etc/rc.d/init.d/masq >/dev/null 2>&1
249 + #/sbin/service masq restart >/dev/null 2>&1
250 + systemctl restart masq >/dev/null 2>&1
251 +
252 +}
253 +
254 +# Sub to restart dhcpd
255 +dhcpd(){
256 + #/usr/bin/sv t dhcpd
257 + systemctl restart dhcpd
258 +}
259 +
260 +# Sub to reconfigures routes and defaults gateway
261 +routes(){
262 + # We need to push all the routes of local networks as the interface has changed
263 + for NET in $(/sbin/e-smith/db networks keys); do
264 + SYSTEM=$(/sbin/e-smith/db networks getprop $NET SystemLocalNetwork)
265 + if (! test $SYSTEM); then
266 + NETMASK=$(/sbin/e-smith/db networks getprop $NET Mask)
267 + ROUTER=$(/sbin/e-smith/db networks getprop $NET Router)
268 + /sbin/route add -net $NET netmask $NETMASK gw $ROUTER >/dev/null 2>&1
269 + fi
270 + done
271 +
272 + # If the server runs in serveronly, we need to reconfigure the default gateway:
273 + if [ $MODE == 'serveronly' ]; then
274 + GW=$(/sbin/e-smith/db configuration get GatewayIP)
275 + /sbin/route add default gw $GW >/dev/null 2>&1
276 + fi
277 +}
278 +
279 +start(){
280 + # First, create the bridge interface
281 + /usr/sbin/brctl addbr $BRIDGE_IF
282 +
283 + # Then, create the tap interface(s) and enslave it in the bridge one
284 + for t in $TAP_IF; do
285 + $openvpn --mktun --dev $t >/dev/null 2>&1
286 + /sbin/ifconfig $t 0.0.0.0 promisc up >/dev/null 2>&1
287 + /usr/sbin/brctl addif $BRIDGE_IF $t >/dev/null 2>&1
288 + done
289 +
290 + # Now make the real ethernet interface promiscuous
291 + /sbin/ifconfig $ETH_IF 0.0.0.0 promisc up >/dev/null 2>&1
292 + sleep 1
293 +
294 + # And add it to the bridge
295 + /usr/sbin/brctl addif $BRIDGE_IF $ETH_IF >/dev/null 2>&1
296 +
297 + [ -n "$ETH_MAC" ] && /sbin/ifconfig $BRIDGE_IF hw ether $ETH_MAC
298 +
299 + [ "$BRIDGE_PROMISC" == "yes" ] && /sbin/ifconfig $BRIDGE_IF promisc
300 +
301 + # Now configure the LocalIP on the bridge interface
302 + /sbin/e-smith/db configuration setprop InternalInterface Name $BRIDGE_IF
303 + /sbin/ifconfig $BRIDGE_IF $ETH_IP netmask $ETH_MASK >/dev/null 2>&1
304 +
305 + # Push the routes for the new interface
306 + routes
307 +
308 + # Now we have to reconfigure the firewall
309 + firewall
310 +
311 + # And dhcpd (the configuration file is expanded each time the service starts
312 + # so no need to do it manually
313 + dhcpd
314 +}
315 +
316 +stop(){
317 + # Shutdown the bridge and remove it
318 + /sbin/ifconfig $BRIDGE_IF down >/dev/null 2>&1
319 + /usr/sbin/brctl delbr $BRIDGE_IF >/dev/null 2>&1
320 +
321 + # Then delete each tap interfaces
322 + for t in $TAP_IF; do
323 + $openvpn --rmtun --dev $t >/dev/null 2>&1
324 + done
325 +
326 + # Reconfigure the ethernet interface
327 + /sbin/e-smith/db configuration setprop InternalInterface Name $ETH_IF
328 + /sbin/ifconfig $ETH_IF $ETH_IP netmask $ETH_MASK up -promisc >/dev/null 2>&1
329 +
330 + # Push the routes
331 + routes
332 +
333 + # restart the firewall
334 + firewall
335 +
336 + # and dhcp
337 + dhcpd
338 +}
339 +
340 +case "$1" in
341 + start)
342 + echo -n $"Starting Bridge Service: "
343 + start
344 + RETVAL=$?
345 + ;;
346 + stop)
347 + echo -n $"Stoping Bridge Service: "
348 + stop
349 + RETVAL=$?
350 + ;;
351 + restart)
352 + echo -n $"Restarting Bridge Service: "
353 + stop && start
354 + RETVAL=$?
355 + ;;
356 + adjust)
357 + echo -n $"Restarting Bridge Service: "
358 + stop && start
359 + RETVAL=$?
360 + ;;
361 + *)
362 + echo "Usage: $0 start|stop|restart"
363 + ;;
364 +esac
365 +
366 +if [ $RETVAL -eq 0 ]; then
367 + echo_success
368 +else
369 + echo_failure
370 +fi
371 +echo
372 +
373 +exit $RETVAL
374 +

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed