mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
Noticed that we all have different styles of writing scripts :-). This PR adds linting to our shell scripts to standardize on formatting, catch common issues and/or possible security bugs. For editor setup: - Ensure [`shellcheck`](https://github.com/koalaman/shellcheck) and [`shfmt`](https://github.com/mvdan/sh) are in your `PATH` - Configure `shfmt` with indentation of `4`, otherwise it uses tabs by default. [Here](https://github.com/jamilbk/nvim/blob/master/init.vim#L159) is how you can do that with Vim and [here](https://marketplace.visualstudio.com/items?itemName=mkhl.shfmt) is how for VScode. --------- Signed-off-by: Jamil <jamilbk@users.noreply.github.com> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Reactor Scram <ReactorScram@users.noreply.github.com> Co-authored-by: Thomas Eizinger <thomas@eizinger.io> Co-authored-by: Brian Manifold <bmanifold@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrew Dryga <andrew@dryga.com> Co-authored-by: Gabi <gabrielalejandro7@gmail.com>
33 lines
1.8 KiB
Bash
Executable File
33 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
if [ "${FIREZONE_ENABLE_MASQUERADE}" = "1" ]; then
|
|
IFACE="tun-firezone"
|
|
# Enable masquerading for ethernet and wireless interfaces
|
|
iptables -C FORWARD -i $IFACE -j ACCEPT >/dev/null 2>&1 || iptables -A FORWARD -i $IFACE -j ACCEPT
|
|
iptables -C FORWARD -o $IFACE -j ACCEPT >/dev/null 2>&1 || iptables -A FORWARD -o $IFACE -j ACCEPT
|
|
iptables -t nat -C POSTROUTING -o e+ -j MASQUERADE >/dev/null 2>&1 || iptables -t nat -A POSTROUTING -o e+ -j MASQUERADE
|
|
iptables -t nat -C POSTROUTING -o w+ -j MASQUERADE >/dev/null 2>&1 || iptables -t nat -A POSTROUTING -o w+ -j MASQUERADE
|
|
ip6tables -C FORWARD -i $IFACE -j ACCEPT >/dev/null 2>&1 || ip6tables -A FORWARD -i $IFACE -j ACCEPT
|
|
ip6tables -C FORWARD -o $IFACE -j ACCEPT >/dev/null 2>&1 || ip6tables -A FORWARD -o $IFACE -j ACCEPT
|
|
ip6tables -t nat -C POSTROUTING -o e+ -j MASQUERADE >/dev/null 2>&1 || ip6tables -t nat -A POSTROUTING -o e+ -j MASQUERADE
|
|
ip6tables -t nat -C POSTROUTING -o w+ -j MASQUERADE >/dev/null 2>&1 || ip6tables -t nat -A POSTROUTING -o w+ -j MASQUERADE
|
|
fi
|
|
|
|
if [ "${LISTEN_ADDRESS_DISCOVERY_METHOD}" = "gce_metadata" ]; then
|
|
echo "Using GCE metadata to discover listen address"
|
|
|
|
if [ "${PUBLIC_IP4_ADDR}" = "" ]; then
|
|
public_ip4=$(curl "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/access-configs/0/external-ip" -H "Metadata-Flavor: Google" -s)
|
|
export PUBLIC_IP4_ADDR="${public_ip4}"
|
|
echo "Discovered PUBLIC_IP4_ADDR: ${PUBLIC_IP4_ADDR}"
|
|
fi
|
|
|
|
if [ "${PUBLIC_IP6_ADDR}" = "" ]; then
|
|
public_ip6=$(curl "http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ipv6s" -H "Metadata-Flavor: Google" -s)
|
|
export PUBLIC_IP6_ADDR="${public_ip6}"
|
|
echo "Discovered PUBLIC_IP6_ADDR: ${PUBLIC_IP6_ADDR}"
|
|
fi
|
|
fi
|
|
|
|
exec "$@"
|