aboutsummaryrefslogtreecommitdiff
path: root/ops/bridge_net
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-09-20 21:19:05 +0200
committerKarel Kočí <cynerd@email.cz>2017-09-20 21:22:36 +0200
commitf287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8 (patch)
tree5025b33a8c3d4c69ad2b62e1169b669c56f712f9 /ops/bridge_net
parent65f52ead41dc6df73671ddd3a8c6a2edecb6dfb3 (diff)
downloadmulticonfig-f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8.tar.gz
multiconfig-f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8.tar.bz2
multiconfig-f287ecedc78c0cc8fb485c5995b8d1cfae9f0fe8.zip
Commit current statecomplicated
Diffstat (limited to 'ops/bridge_net')
-rw-r--r--ops/bridge_net72
1 files changed, 72 insertions, 0 deletions
diff --git a/ops/bridge_net b/ops/bridge_net
new file mode 100644
index 0000000..bab94ad
--- /dev/null
+++ b/ops/bridge_net
@@ -0,0 +1,72 @@
+# vim:ft=sh:noexpandtab
+# Bridge with dhcpd
+# TODO FreeBSD
+
+BRIDGE_NET_BRIDGE="./files/bridge_net/bridge.service"
+BRIDGE_NET_SYSCTL="./files/bridge_net/sysctl.conf"
+BRIDGE_NET_DHCPD="./files/bridge_net/dhcpd.conf"
+BRIDGE_NET_BRIDGE_DHCP="./files/bridge_net/bridge-dhcp.service"
+
+bridge_net_check() {
+ ops_set_current bridge_net
+ if ! ( which dhcpd ) >/dev/null; then
+ echo_error "Bridge_net expects dhcpd to be installed"
+ return 0
+ fi
+ # TODO check that we are using openrc otherwise this doesn't work
+
+ # Setup bridge service
+ if do_diff "$BRIDGE_NET_BRIDGE" "/etc/init.d/bridge" \
+ "Bridge service changes"; then
+ ops_require bridge_service
+ fi
+ # Setup ipv4 forward
+ if do_diff "$BRIDGE_NET_SYSCTL" "/etc/sysctl.d/bridge_net.conf" \
+ "Sysctl changes"; then
+ ops_require sysctl
+ fi
+ # DHCPd service
+ if do_diff "$BRIDGE_NET_BRIDGE_DHCP" "/etc/init.d/bridge-dhcp" \
+ "Bridge dhcp service changes"; then
+ ops_require bridge_dhcp_service
+ fi
+ # DHCPd configuration
+ if do_diff "$BRIDGE_NET_DHCPD" "/etc/dhcp/bridge_dhcpd.conf" \
+ "DHCPD configuration changes"; then
+ ops_require dhcpd_conf
+ fi
+
+ # TODO enable bridge_dhcp and bridge service
+
+ ops_required_any "Bridge_net" # return 1 fall trough
+}
+
+bridge_net_prepare() {
+ local BRIDGE_RESTART=false
+
+ if ops_is_required bridge_service; then
+ echo_trace "Updating bridge service"
+ cp "$BRIDGE_NET_BRIDGE" "/etc/init.d/bridge"
+ BRIDGE_RESTART=true
+ fi
+ if ops_is_required sysctl; then
+ echo_trace "Updating sysctl configuration for bridge"
+ cp "$BRIDGE_NET_SYSCTL" "/etc/sysctl.d/bridge"
+ fi
+
+ if $BRIDGE_RESTART; then
+ service bridge restart
+ fi
+}
+
+bridge_net_apply() {
+ # We have nothing to do for apply
+ # TODO
+ true
+}
+
+bridge_net_clean() {
+ # We have nothing to do for clean
+ # TODO
+ true
+}