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/sbin/e-smith/systemd/bridge-run smeserver-bridge-interface-0.2/root/sbin/e-smith/systemd/bridge-run |
181 |
--- smeserver-bridge-interface-0.2.old/root/sbin/e-smith/systemd/bridge-run 1970-01-01 01:00:00.000000000 +0100 |
182 |
+++ smeserver-bridge-interface-0.2/root/sbin/e-smith/systemd/bridge-run 2021-01-23 06:48:41.138127943 +0000 |
183 |
@@ -0,0 +1,178 @@ |
184 |
+#!/bin/bash |
185 |
+# Bridge service on SME |
186 |
+# This service will configure a bridge interface on your server |
187 |
+# allowing each enslaved interfaces to act as a switch port. |
188 |
+ |
189 |
+# Source function library. |
190 |
+. /etc/rc.d/init.d/functions |
191 |
+ |
192 |
+# Bridge Interface |
193 |
+BRIDGE_IF=$(/sbin/e-smith/db configuration getprop bridge bridgeInterface) |
194 |
+BRIDGE_PROMISC=$(/sbin/e-smith/db configuration getprop bridge Promiscuous) |
195 |
+ |
196 |
+# Define list of TAP interfaces to be bridged, |
197 |
+# for example tap="tap0 tap1 tap2". |
198 |
+# Defaults is tap0 |
199 |
+TAP_IF=$(/sbin/e-smith/db configuration getprop bridge tapInterface) |
200 |
+# Replace ; and , with spaces |
201 |
+TAP_IF=$(echo $TAP_IF | sed -e "s/[,;]/ /g") |
202 |
+ |
203 |
+# Define physical ethernet interface to be bridged |
204 |
+# with TAP interface(s) above. |
205 |
+ETH_IF=$(/sbin/e-smith/db configuration getprop bridge ethernetInterface) |
206 |
+ETH_MAC=$(/sbin/e-smith/db configuration getprop InternalInterface HWAddress) |
207 |
+ETH_IP=$(/sbin/e-smith/db configuration get LocalIP) |
208 |
+ETH_MASK=$(/sbin/e-smith/db configuration getprop InternalInterface Netmask) |
209 |
+ |
210 |
+# System mode: serveronly, server&gateway ... |
211 |
+MODE=$(/sbin/e-smith/db configuration get SystemMode) |
212 |
+ |
213 |
+# Path of openvpn binary |
214 |
+openvpn="" |
215 |
+openvpn_locations="/usr/sbin/openvpn /usr/local/sbin/openvpn" |
216 |
+for location in $openvpn_locations |
217 |
+do |
218 |
+ if [ -f "$location" ] |
219 |
+ then |
220 |
+ openvpn=$location |
221 |
+ fi |
222 |
+done |
223 |
+ |
224 |
+# Check that binary exists |
225 |
+if ! [ -f $openvpn ] |
226 |
+then |
227 |
+ echo "openvpn binary not found" |
228 |
+ exit 0 |
229 |
+fi |
230 |
+ |
231 |
+ |
232 |
+ |
233 |
+# Sub to reconfigure the firewall |
234 |
+firewall(){ |
235 |
+ /sbin/e-smith/expand-template /etc/rc.d/init.d/masq >/dev/null 2>&1 |
236 |
+ #/sbin/service masq restart >/dev/null 2>&1 |
237 |
+ /usr/bin/systemctl try-restart masq.service >/dev/null 2>&1 |
238 |
+ |
239 |
+} |
240 |
+ |
241 |
+# Sub to restart dhcpd |
242 |
+dhcpd(){ |
243 |
+ #/usr/bin/sv t dhcpd |
244 |
+ /usr/bin/systemctl try-restart dhcpd.service >/dev/null 2>&1 |
245 |
+} |
246 |
+ |
247 |
+# Sub to reconfigures routes and defaults gateway |
248 |
+routes(){ |
249 |
+ # We need to push all the routes of local networks as the interface has changed |
250 |
+ for NET in $(/sbin/e-smith/db networks keys); do |
251 |
+ SYSTEM=$(/sbin/e-smith/db networks getprop $NET SystemLocalNetwork) |
252 |
+ if (! test $SYSTEM); then |
253 |
+ NETMASK=$(/sbin/e-smith/db networks getprop $NET Mask) |
254 |
+ ROUTER=$(/sbin/e-smith/db networks getprop $NET Router) |
255 |
+ /sbin/route add -net $NET netmask $NETMASK gw $ROUTER >/dev/null 2>&1 |
256 |
+ fi |
257 |
+ done |
258 |
+ |
259 |
+ # If the server runs in serveronly, we need to reconfigure the default gateway: |
260 |
+ if [ $MODE == 'serveronly' ]; then |
261 |
+ GW=$(/sbin/e-smith/db configuration get GatewayIP) |
262 |
+ /sbin/route add default gw $GW >/dev/null 2>&1 |
263 |
+ fi |
264 |
+} |
265 |
+ |
266 |
+start(){ |
267 |
+ # First, create the bridge interface |
268 |
+ /usr/sbin/brctl addbr $BRIDGE_IF |
269 |
+ |
270 |
+ # Then, create the tap interface(s) and enslave it in the bridge one |
271 |
+ for t in $TAP_IF; do |
272 |
+ $openvpn --mktun --dev $t >/dev/null 2>&1 |
273 |
+ /sbin/ifconfig $t 0.0.0.0 promisc up >/dev/null 2>&1 |
274 |
+ /usr/sbin/brctl addif $BRIDGE_IF $t >/dev/null 2>&1 |
275 |
+ done |
276 |
+ |
277 |
+ # Now make the real ethernet interface promiscuous |
278 |
+ /sbin/ifconfig $ETH_IF 0.0.0.0 promisc up >/dev/null 2>&1 |
279 |
+ sleep 1 |
280 |
+ |
281 |
+ # And add it to the bridge |
282 |
+ /usr/sbin/brctl addif $BRIDGE_IF $ETH_IF >/dev/null 2>&1 |
283 |
+ |
284 |
+ [ -n "$ETH_MAC" ] && /sbin/ifconfig $BRIDGE_IF hw ether $ETH_MAC |
285 |
+ |
286 |
+ [ "$BRIDGE_PROMISC" == "yes" ] && /sbin/ifconfig $BRIDGE_IF promisc |
287 |
+ |
288 |
+ # Now configure the LocalIP on the bridge interface |
289 |
+ /sbin/e-smith/db configuration setprop InternalInterface Name $BRIDGE_IF |
290 |
+ /sbin/ifconfig $BRIDGE_IF $ETH_IP netmask $ETH_MASK >/dev/null 2>&1 |
291 |
+ |
292 |
+ # Push the routes for the new interface |
293 |
+ routes |
294 |
+ |
295 |
+ # Now we have to reconfigure the firewall |
296 |
+ firewall |
297 |
+ |
298 |
+ # And dhcpd (the configuration file is expanded each time the service starts |
299 |
+ # so no need to do it manually |
300 |
+ dhcpd |
301 |
+} |
302 |
+ |
303 |
+stop(){ |
304 |
+ # Shutdown the bridge and remove it |
305 |
+ /sbin/ifconfig $BRIDGE_IF down >/dev/null 2>&1 |
306 |
+ /usr/sbin/brctl delbr $BRIDGE_IF >/dev/null 2>&1 |
307 |
+ |
308 |
+ # Then delete each tap interfaces |
309 |
+ for t in $TAP_IF; do |
310 |
+ $openvpn --rmtun --dev $t >/dev/null 2>&1 |
311 |
+ done |
312 |
+ |
313 |
+ # Reconfigure the ethernet interface |
314 |
+ /sbin/e-smith/db configuration setprop InternalInterface Name $ETH_IF |
315 |
+ /sbin/ifconfig $ETH_IF $ETH_IP netmask $ETH_MASK up -promisc >/dev/null 2>&1 |
316 |
+ |
317 |
+ # Push the routes |
318 |
+ routes |
319 |
+ |
320 |
+ # restart the firewall |
321 |
+ firewall |
322 |
+ |
323 |
+ # and dhcp |
324 |
+ dhcpd |
325 |
+} |
326 |
+ |
327 |
+case "$1" in |
328 |
+ start) |
329 |
+ echo -n $"Starting Bridge Service: " |
330 |
+ start |
331 |
+ RETVAL=$? |
332 |
+ ;; |
333 |
+ stop) |
334 |
+ echo -n $"Stoping Bridge Service: " |
335 |
+ stop |
336 |
+ RETVAL=$? |
337 |
+ ;; |
338 |
+ restart) |
339 |
+ echo -n $"Restarting Bridge Service: " |
340 |
+ stop && start |
341 |
+ RETVAL=$? |
342 |
+ ;; |
343 |
+ adjust) |
344 |
+ echo -n $"Restarting Bridge Service: " |
345 |
+ stop && start |
346 |
+ RETVAL=$? |
347 |
+ ;; |
348 |
+ *) |
349 |
+ echo "Usage: $0 start|stop|restart" |
350 |
+ ;; |
351 |
+esac |
352 |
+ |
353 |
+if [ $RETVAL -eq 0 ]; then |
354 |
+ echo_success |
355 |
+else |
356 |
+ echo_failure |
357 |
+fi |
358 |
+echo |
359 |
+ |
360 |
+exit $RETVAL |
361 |
+ |
362 |
diff -urN smeserver-bridge-interface-0.2.old/root/usr/lib/systemd/system/bridge.service smeserver-bridge-interface-0.2/root/usr/lib/systemd/system/bridge.service |
363 |
--- smeserver-bridge-interface-0.2.old/root/usr/lib/systemd/system/bridge.service 1970-01-01 01:00:00.000000000 +0100 |
364 |
+++ smeserver-bridge-interface-0.2/root/usr/lib/systemd/system/bridge.service 2021-01-22 14:35:26.710394872 +0000 |
365 |
@@ -0,0 +1,9 @@ |
366 |
+[Unit] |
367 |
+Description=Bridge Interface for VPN use. |
368 |
+After=network.target |
369 |
+[Service] |
370 |
+Type=forking |
371 |
+ExecStart=/sbin/e-smith/systemd/bridge-run start |
372 |
+ExecStop=/sbin/e-smith/systemd/bridge-run stop |
373 |
+[Install] |
374 |
+WantedBy=sme-server.target |