Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add default domain and other cleanup #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2020 Deavon McCaffery, Tiffany Wang, and Contributors
Copyright (c) 2020-2021 Deavon McCaffery, Tiffany Wang, and Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
34 changes: 19 additions & 15 deletions bridge.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /usr/bin/env bash
#! /usr/bin/env sh
set -eu

# install all prerequisites
Expand All @@ -9,38 +9,42 @@ sudo apt-get install qemu-kvm libvirt-daemon-system \
# make sure libvirtd is enabled
sudo systemctl enable libvirtd

# get a list of active ethernet devices (deal with whitespace)
OLDIFS=$IFS
IFS=$'\n'
ACTIVE_CONNECTIONS=( $(nmcli -get-values NAME,DEVICE,TYPE connection show --active | grep ethernet | grep -v bridge | cut -d ':' -f 1,2) )
IFS=$OLDIFS

if [ -z "${ACTIVE_CONNECTIONS:-}" ]; then
echo
echo "no active connections to bridge..."
exit 1
fi

# delete and recreate the bridge
sudo nmcli connection delete br0 || true
sudo nmcli con add ifname br0 type bridge con-name br0 || true
sudo nmcli con modify br0 bridge.stp no

# disable netfilter for the bridge network to avoid issues with docker network configs
sudo cat << EOF > /etc/sysctl.d/bridge.conf
cat << EOF | sudo tee /etc/sysctl.d/bridge.conf
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
net.ipv4.ip_forward = 1
EOF

# activate the netfilter configuration for the bridge device
sudo cat << EOF > /etc/udev/rules.d/99-bridge.rules
cat << EOF | sudo tee /etc/udev/rules.d/99-bridge.rules
ACTION=="add", SUBSYSTEM=="module", KERNEL=="br_netfilter", RUN+="/sbin/sysctl -p /etc/sysctl.d/bridge.conf"
EOF

# update network configuration
sudo netplan apply

# wait for connections
sleep 15

# get a list of active ethernet devices (deal with whitespace)
OLDIFS=$IFS
IFS=$'\n'
ACTIVE_CONNECTIONS=( $(nmcli -get-values NAME,DEVICE,TYPE connection show --active | grep ethernet | grep -v bridge | cut -d ':' -f 1,2) )
IFS=$OLDIFS

if [ -z "${ACTIVE_CONNECTIONS:-}" ]; then
echo
echo "no active connections to bridge..."
exit 1
fi

# iterate over each device
for connection in "${ACTIVE_CONNECTIONS[@]}"; do

Expand Down
3 changes: 0 additions & 3 deletions cloud_init.cfg.template
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,3 @@ bootcmd:

runcmd:
- mkdir -p /home/kube-admin/.ssh || true
- curl https://github.com/GH_USER.keys | tee -a /home/kube-admin/.ssh/authorized_keys
- chmod -R u=rwX,g=rX,o= /home/kube-admin/.ssh
- chown -R kube-admin:kube-admin /home/kube-admin/.ssh
Loading