Skip to content

Commit

Permalink
Merge code to change the uplinks
Browse files Browse the repository at this point in the history
This combines all commits to change the uplink-preset for all 4 uplink-types
  • Loading branch information
SvenRoederer committed Dec 17, 2018
1 parent d5fc073 commit d332954
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 38 deletions.
4 changes: 2 additions & 2 deletions uplinks/freifunk-berlin-uplink-no-tunnel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=freifunk-berlin-uplink-notunnel-files
PKG_VERSION:=0.0.8
PKG_RELEASE:=1
PKG_RELEASE:=2

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

Expand All @@ -14,7 +14,7 @@ define Package/$(PKG_NAME)
CATEGORY:=freifunk-berlin
TITLE:=Freifunk Berlin no tunnel files
URL:=http://github.com/freifunk-berlin/packages_berlin
DEPENDS+=+freifunk-berlin-lib-guard +kmod-veth
DEPENDS+=+freifunk-berlin-lib-guard +kmod-veth +freifunk-berlin-network-defaults
PROVIDES:=freifunk-berlin-uplink
PKGARCH:=all
endef
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/bin/sh

. /lib/functions/freifunk-berlin-network.sh
. /lib/functions.sh

# always set correct masquerading, regardless of guard
uci set firewall.zone_ffuplink.masq=1
uci commit firewall

if [[ $(uci get ffberlin-uplink.preset.current) != "no-tunnel" ]]; then
uci rename ffberlin-uplink.preset.current=previous
# do not track preset when it was 'undefined', aka never configured
if [[ $(uci get ffberlin-uplink.preset.current) != 'undefined' ]]; then
logger -t "ffuplink" "uplink-preset has been changed."
uci set ffberlin-uplink.preset.previous=$(uci get ffberlin-uplink.preset.current)
create_ffuplink
fi
uci set ffberlin-uplink.preset.current="no-tunnel"
fi
# set set auth-type required for this uplink-type, e.g. for freifunk-wizard
Expand All @@ -17,7 +25,7 @@ uci commit ffberlin-uplink
. /lib/functions/guard.sh
guard "notunnel"

uci delete network.ffuplink_dev
uci -q delete network.ffuplink_dev
uci set network.ffuplink_dev=device
uci set network.ffuplink_dev.type=veth
uci set network.ffuplink_dev.name=ffuplink
Expand All @@ -29,18 +37,12 @@ for byte in 2 3 4 5 6; do
macaddr=$macaddr`dd if=/dev/urandom bs=1 count=1 2> /dev/null | hexdump -e '1/1 ":%02x"'`
done
uci set network.ffuplink_dev.macaddr=$macaddr

# add ffuplink_dev to br-wan
uci set network.wan.ifname="$(uci get network.wan.ifname) ffuplink_wan"
uci commit network.ffuplink_dev

uci delete network.ffuplink
uci set network.ffuplink=interface
uci set network.ffuplink.ifname=ffuplink
# add ffuplink_dev to br-wan if not there
ifnames=$(uci get network.wan.ifname)
list_contains ifnames ffuplink_wan || uci set network.wan.ifname="${ifnames} ffuplink_wan"
uci commit network.wan

uci set network.ffuplink.proto=dhcp
# Put the resulting routing information from the dhcp request in the ffuplink table
# instead of the default table. This prevents the dhcp request for the ffuplink
# interface from overwriting the routing table entries needed by br_wan.
uci set network.ffuplink.ip4table=ffuplink
uci set network.ffuplink.ip6table=ffuplink
uci commit network
uci commit network.ffuplink
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
#!/bin/sh

. /lib/functions/guard.sh

# always set correct masquerading, regardless of guard
uci set firewall.zone_ffuplink.masq=1
uci commit firewall

if [[ $(uci get ffberlin-uplink.preset.current) != "tunnelberlin_openvpn" ]]; then
uci rename ffberlin-uplink.preset.current=previous
# do not track preset when it was 'undefined', aka never configured
if [[ $(uci get ffberlin-uplink.preset.current) != 'undefined' ]]; then
logger -t "ffuplink" "uplink-preset has been changed."
uci set ffberlin-uplink.preset.previous=$(uci get ffberlin-uplink.preset.current)
fi
uci set ffberlin-uplink.preset.current="tunnelberlin_openvpn"
# call uci-default of package freifunk-berlin-openvpn-files again to recreate initial config
sh /rom/etc/uci-defaults/freifunk-berlin-z90_openvpn
fi
uci commit ffberlin-uplink

. /lib/functions/guard.sh
guard "tunnelberlin_openvpn"

uci set openvpn.ffuplink.proto=udp4
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include $(TOPDIR)/rules.mk

PKG_NAME:=freifunk-berlin-uplink-tunnelberlin-tunneldigger-files
PKG_VERSION:=0.0.5
PKG_RELEASE:=1
PKG_RELEASE:=2

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)

Expand All @@ -14,7 +14,7 @@ define Package/freifunk-berlin-uplink-tunnelberlin-tunneldigger-files
CATEGORY:=freifunk-berlin
TITLE:=Freifunk Berlin Networktunnel files
URL:=http://github.com/freifunk-berlin/firmware-packages
DEPENDS+= +freifunk-berlin-lib-guard +freifunk-berlin-tunneldigger
DEPENDS+= +freifunk-berlin-lib-guard +freifunk-berlin-tunneldigger +freifunk-berlin-network-defaults
PROVIDES:=freifunk-berlin-uplink
PKGARCH:=all
endef
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
#!/bin/sh

. /lib/functions/system.sh
THIS_UPLINKNAME="tunnelberlin_tunnneldigger"

. /lib/functions/freifunk-berlin-network.sh
. /lib/functions.sh

# always set correct masquerading, regardless of guard
uci set firewall.zone_ffuplink.masq=1
uci commit firewall

uci -q get ffberlin-uplink || echo "" | uci import ffberlin-uplink
uci >/dev/null -q get ffberlin-uplink.preset || uci set ffberlin-uplink.preset=settings
uci >/dev/null -q get ffberlin-uplink.preset.current || uci set ffberlin-uplink.preset.current="tunnelberlin_tunneldigger"
if [ $(uci get ffberlin-uplink.preset.current) != "tunnelberlin_tunneldigger" ]; then
uci rename ffberlin-uplink.preset.current=previous
uci set ffberlin-uplink.preset.current="tunnelberlin_tunneldigger"
current_preset=$(uci get ffberlin-uplink.preset.current)
if [ ${current_preset} != ${THIS_UPLINKNAME} ]; then
if [ ${current_preset} != "undefined" ]; then
# when the uplink-preset has changed, recreate remember the preset we are coming from
# and prepare for reinit of the relevant settings via freifunk-berlin-ffuplink-defaults
# uci-defaults
logger -t "ffuplink" "uplink-preset has been changed."
uci set ffberlin-uplink.preset.previous=$(uci get ffberlin-uplink.preset.current)
create_ffuplink
fi
uci set ffberlin-uplink.preset.current=${THIS_UPLINKNAME}
fi
# set set auth-type required for this uplink-type, e.g. for freifunk-wizard
uci set ffberlin-uplink.uplink=settings
Expand All @@ -31,17 +39,10 @@ for byte in 2 3 4 5 6; do
macaddr=$macaddr`dd if=/dev/urandom bs=1 count=1 2> /dev/null | hexdump -e '1/1 ":%02x"'`
done
uci set network.ffuplink_dev.macaddr=$macaddr
uci commit network.ffuplink_dev

uci delete network.ffuplink
uci set network.ffuplink=interface
uci set network.ffuplink.ifname=ffuplink
uci set network.ffuplink.proto=dhcp
# Put the resulting routing information from the dhcp request in the ffuplink table
# instead of the default table. This prevents the dhcp request for the ffuplink
# interface from overwriting the routing table entries needed by br_wan.
uci set network.ffuplink.ip4table=ffuplink
uci set network.ffuplink.ip6table=ffuplink
uci commit network
uci commit network.ffuplink

# tunneldigger setup
UUID=$(uci -q get tunneldigger.ffuplink.uuid)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
#!/bin/sh

. /lib/functions/guard.sh

# always set correct masquerading, regardless of guard
uci set firewall.zone_ffuplink.masq=0
uci commit firewall

if [[ $(uci get ffberlin-uplink.preset.current) != "vpn03_openvpn" ]]; then
uci rename ffberlin-uplink.preset.current=previous
# do not track preset when it was 'undefined', aka never configured
if [[ $(uci get ffberlin-uplink.preset.current) != 'undefined' ]]; then
logger -t "ffuplink" "uplink-preset has been changed."
uci set ffberlin-uplink.preset.previous=$(uci get ffberlin-uplink.preset.current)
fi
uci set ffberlin-uplink.preset.current="vpn03_openvpn"
# call uci-default of package freifunk-berlin-openvpn-files again to recreate initial config
sh /rom/etc/uci-defaults/freifunk-berlin-z90_openvpn
fi
uci commit ffberlin-uplink

. /lib/functions/guard.sh
guard "vpn03_openvpn"

uci set openvpn.ffuplink.proto=udp4
Expand Down

5 comments on commit d332954

@SvenRoederer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tested with:

  • upgrade Hedy-1.0.1-VPN03 to Hedy-1.0.2-vpn03
  • upgrade Hedy-1.0.1-VPN03 to Hedy-1.0.2-tunnel-berlin
  • upgrade Hedy-1.0.1-VPN03 to Hedy-1.0.2-notunnel
  • switch Hedy-1.0.2-notunnel to Hedy-1.0.2-tunnel-berlin

@pmelange
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test successfully with:

  • 1.0.2 Fresh install tunnel-berlin
  • 1.0.2 Change to tunnel-berlin-tunneldigger
  • 1.0.2 Change to default
  • 1.0.2 Change to tunnel-berlin, upload crt and key via webinterface

A small note, when uploading the crt and key via the web interface, the files are stored by default in /etc/luci-uploads

We definitely need a howto page for changing to any of the openvpn based images. This process is surely something that my grandma would not be able to figure out without help.

The following issues, I feel, still need to be addressed:
freifunk-berlin/firmware#640
freifunk-berlin/firmware#642

Test device: WDR4900

@SvenRoederer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A small note, when uploading the crt and key via the web interface, the files are stored by default in /etc/luci-uploads

did you use the wizard?

@pmelange
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went to the OpenVPN menu item. I had to add the fiels crt and key, upload the files, and it worked. The files are stored in /etc/luci-uploads. Everything works this way too. The crt and key files stay in /etc/luci-uploads also after sysupgrade.

@SvenRoederer
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/etc/luci-uploads is the default location when using the default luci-app-openvpn. Our wizard is using the /etc/openvpn directory. This I mentioned in https://lists.berlin.freifunk.net/pipermail/berlin/2018-December/038569.html

Please sign in to comment.