diff --git a/.gitignore b/.gitignore index 6e32125..269846c 100755 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ # Test binary, build with `go test -c` *.test *.idea +*.DS_Store coverage.out coverage.html diff --git a/.gitmodules b/.gitmodules index 20b9731..6a4bbba 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ -[submodule "dist/resource/cert"] - path = dist/resource/cert +[submodule "dist/cert"] + path = dist/cert url = https://github.com/danieldin95/freecert.git branch = master diff --git a/Makefile b/Makefile index 238d508..baf3048 100755 --- a/Makefile +++ b/Makefile @@ -100,53 +100,20 @@ linux-gz: install ## build linux packages gzip -f $(BD)/$(LINUX_DIR).tar linux-bin: linux-gz ## build linux install binary - @cat $(SD)/dist/script/install.sh > $(BD)/$(LINUX_DIR).bin && \ + @cat $(SD)/dist/rootfs/var/openlan/script/install.sh > $(BD)/$(LINUX_DIR).bin && \ echo "__ARCHIVE_BELOW__:" >> $(BD)/$(LINUX_DIR).bin && \ cat $(BD)/$(LINUX_DIR).tar.gz >> $(BD)/$(LINUX_DIR).bin && \ chmod +x $(BD)/$(LINUX_DIR).bin install: env linux ## install packages - @mkdir -p $(LINUX_DIR)/etc/sysctl.d - @cp -rf $(SD)/dist/resource/90-openlan.conf $(LINUX_DIR)/etc/sysctl.d - @mkdir -p $(LINUX_DIR)/etc/openlan - @cp -rf $(SD)/dist/resource/point.json.example $(LINUX_DIR)/etc/openlan - @cp -rf $(SD)/dist/resource/proxy.json.example $(LINUX_DIR)/etc/openlan - @mkdir -p $(LINUX_DIR)/etc/openlan/switch - @cp -rf $(SD)/dist/resource/confd.schema.json $(LINUX_DIR)/etc/openlan/switch - @cp -rf $(SD)/dist/resource/switch.json.example $(LINUX_DIR)/etc/openlan/switch - @mkdir -p $(LINUX_DIR)/etc/openlan/switch/acl - @cp -rf $(SD)/dist/resource/acl-1.json.example $(LINUX_DIR)/etc/openlan/switch/acl - @mkdir -p $(LINUX_DIR)/etc/openlan/switch/network - @cp -rf $(SD)/dist/resource/default.json.example $(LINUX_DIR)/etc/openlan/switch/network - @cp -rf $(SD)/dist/resource/network.json.example $(LINUX_DIR)/etc/openlan/switch/network - @cp -rf $(SD)/dist/resource/ipsec.json.example $(LINUX_DIR)/etc/openlan/switch/network - @cp -rf $(SD)/dist/resource/v1024.json.example $(LINUX_DIR)/etc/openlan/switch/network - @cp -rf $(SD)/dist/resource/fabric.json.example $(LINUX_DIR)/etc/openlan/switch/network + @mkdir -p $(LINUX_DIR) + @cp -rf $(SD)/dist/rootfs/{etc,var,usr} $(LINUX_DIR) + @mkdir -p $(LINUX_DIR)/var/openlan/{cert,openvpn,point,l2tp,dhcp} + @cp -rf $(SD)/dist/cert/openlan/cert $(LINUX_DIR)/var/openlan + @cp -rf $(SD)/dist/cert/openlan/ca/ca.crt $(LINUX_DIR)/var/openlan/cert @mkdir -p $(LINUX_DIR)/usr/bin - @cp -rf $(BD)/openudp $(LINUX_DIR)/usr/bin - @cp -rf $(BD)/openlan $(LINUX_DIR)/usr/bin - @cp -rf $(BD)/openlan-proxy $(LINUX_DIR)/usr/bin - @cp -rf $(BD)/openlan-point $(LINUX_DIR)/usr/bin - @cp -rf $(BD)/openlan-switch $(LINUX_DIR)/usr/bin - @mkdir -p $(LINUX_DIR)/var/openlan - @cp -rf $(SD)/dist/resource/cert/openlan/cert $(LINUX_DIR)/var/openlan - @cp -rf $(SD)/dist/script $(LINUX_DIR)/var/openlan - @cp -rf $(SD)/pkg/public $(LINUX_DIR)/var/openlan - @cp -rf $(SD)/dist/resource/cert/openlan/ca/ca.crt $(LINUX_DIR)/var/openlan/cert - @mkdir -p $(LINUX_DIR)/var/openlan/point - @mkdir -p $(LINUX_DIR)/var/openlan/openvpn - @mkdir -p $(LINUX_DIR)/var/openlan/l2tp - @mkdir -p $(LINUX_DIR)/var/openlan/dhcp - @mkdir -p $(LINUX_DIR)/var/openlan/confd - @mkdir -p $(LINUX_DIR)/etc/sysconfig/openlan - @cp -rf $(SD)/dist/resource/point.cfg $(LINUX_DIR)/etc/sysconfig/openlan - @cp -rf $(SD)/dist/resource/proxy.cfg $(LINUX_DIR)/etc/sysconfig/openlan - @cp -rf $(SD)/dist/resource/switch.cfg $(LINUX_DIR)/etc/sysconfig/openlan - @mkdir -p $(LINUX_DIR)//usr/lib/systemd/system - @cp -rf $(SD)/dist/resource/openlan-point@.service $(LINUX_DIR)/usr/lib/systemd/system - @cp -rf $(SD)/dist/resource/openlan-proxy.service $(LINUX_DIR)/usr/lib/systemd/system - @cp -rf $(SD)/dist/resource/openlan-confd.service $(LINUX_DIR)/usr/lib/systemd/system - @cp -rf $(SD)/dist/resource/openlan-switch.service $(LINUX_DIR)/usr/lib/systemd/system + @cp -rf $(BD)/{openudp,openlan} $(LINUX_DIR)/usr/bin + @cp -rf $(BD)/{openlan-point,openlan-proxy,openlan-switch} $(LINUX_DIR)/usr/bin ## cross build for windows windows: windows-point ## build windows binary diff --git a/dist/cert b/dist/cert new file mode 160000 index 0000000..eacb320 --- /dev/null +++ b/dist/cert @@ -0,0 +1 @@ +Subproject commit eacb3208c32b022593f0e0d16adbe0c6bc75fdf6 diff --git a/dist/resource/cert b/dist/resource/cert deleted file mode 160000 index 0298f45..0000000 --- a/dist/resource/cert +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0298f45e58bfc27e3d4c65823687ca01bd992d9a diff --git a/dist/resource/donation.jpg b/dist/resource/donation.jpg deleted file mode 100755 index 8e1809e..0000000 Binary files a/dist/resource/donation.jpg and /dev/null differ diff --git a/dist/resource/modules.openlan.conf b/dist/rootfs/etc/modules-load.d/openlan.conf similarity index 100% rename from dist/resource/modules.openlan.conf rename to dist/rootfs/etc/modules-load.d/openlan.conf diff --git a/dist/resource/point.json.example b/dist/rootfs/etc/openlan/point.json.example similarity index 100% rename from dist/resource/point.json.example rename to dist/rootfs/etc/openlan/point.json.example diff --git a/dist/resource/point.json.full.example b/dist/rootfs/etc/openlan/point.json.full.example similarity index 100% rename from dist/resource/point.json.full.example rename to dist/rootfs/etc/openlan/point.json.full.example diff --git a/dist/resource/proxy.json.example b/dist/rootfs/etc/openlan/proxy.json.example similarity index 100% rename from dist/resource/proxy.json.example rename to dist/rootfs/etc/openlan/proxy.json.example diff --git a/dist/resource/acl-1.json.example b/dist/rootfs/etc/openlan/switch/acl/acl-1.json.example similarity index 100% rename from dist/resource/acl-1.json.example rename to dist/rootfs/etc/openlan/switch/acl/acl-1.json.example diff --git a/dist/resource/confd.schema.json b/dist/rootfs/etc/openlan/switch/confd.schema.json similarity index 100% rename from dist/resource/confd.schema.json rename to dist/rootfs/etc/openlan/switch/confd.schema.json diff --git a/dist/resource/l2tp-psk.conf b/dist/rootfs/etc/openlan/switch/l2tp-psk.conf similarity index 100% rename from dist/resource/l2tp-psk.conf rename to dist/rootfs/etc/openlan/switch/l2tp-psk.conf diff --git a/dist/resource/default.json.example b/dist/rootfs/etc/openlan/switch/network/default.json.example similarity index 100% rename from dist/resource/default.json.example rename to dist/rootfs/etc/openlan/switch/network/default.json.example diff --git a/dist/resource/fabric.json.example b/dist/rootfs/etc/openlan/switch/network/fabric.json.example similarity index 100% rename from dist/resource/fabric.json.example rename to dist/rootfs/etc/openlan/switch/network/fabric.json.example diff --git a/dist/rootfs/etc/openlan/switch/network/ipsec.json b/dist/rootfs/etc/openlan/switch/network/ipsec.json new file mode 100644 index 0000000..dd5851e --- /dev/null +++ b/dist/rootfs/etc/openlan/switch/network/ipsec.json @@ -0,0 +1,4 @@ +{ + "name": "ipsec", + "provider": "esp" +} diff --git a/dist/resource/ipsec.json.example b/dist/rootfs/etc/openlan/switch/network/ipsec.json.example similarity index 100% rename from dist/resource/ipsec.json.example rename to dist/rootfs/etc/openlan/switch/network/ipsec.json.example diff --git a/dist/resource/network.json.example b/dist/rootfs/etc/openlan/switch/network/network.json.example similarity index 100% rename from dist/resource/network.json.example rename to dist/rootfs/etc/openlan/switch/network/network.json.example diff --git a/dist/resource/network.yaml.example b/dist/rootfs/etc/openlan/switch/network/network.yaml.example similarity index 100% rename from dist/resource/network.yaml.example rename to dist/rootfs/etc/openlan/switch/network/network.yaml.example diff --git a/dist/resource/v1024.json.example b/dist/rootfs/etc/openlan/switch/network/v1024.json.example similarity index 100% rename from dist/resource/v1024.json.example rename to dist/rootfs/etc/openlan/switch/network/v1024.json.example diff --git a/dist/resource/password.example b/dist/rootfs/etc/openlan/switch/password.example similarity index 100% rename from dist/resource/password.example rename to dist/rootfs/etc/openlan/switch/password.example diff --git a/dist/rootfs/etc/openlan/switch/route/example.json b/dist/rootfs/etc/openlan/switch/route/example.json new file mode 100644 index 0000000..675dc26 --- /dev/null +++ b/dist/rootfs/etc/openlan/switch/route/example.json @@ -0,0 +1,4 @@ +[ + {"prefix": "172.18.22.0/24", "nexthop": "192.168.1.10"}, + {"prefix": "172.18.44.0/24", "nexthop": "192.168.1.10"} +] diff --git a/dist/resource/switch.json.example b/dist/rootfs/etc/openlan/switch/switch.json.example similarity index 100% rename from dist/resource/switch.json.example rename to dist/rootfs/etc/openlan/switch/switch.json.example diff --git a/dist/resource/switch.json.full.example b/dist/rootfs/etc/openlan/switch/switch.json.full.example similarity index 100% rename from dist/resource/switch.json.full.example rename to dist/rootfs/etc/openlan/switch/switch.json.full.example diff --git a/dist/resource/switch.yaml.example b/dist/rootfs/etc/openlan/switch/switch.yaml.example similarity index 100% rename from dist/resource/switch.yaml.example rename to dist/rootfs/etc/openlan/switch/switch.yaml.example diff --git a/dist/resource/point.cfg b/dist/rootfs/etc/sysconfig/openlan/point.cfg similarity index 100% rename from dist/resource/point.cfg rename to dist/rootfs/etc/sysconfig/openlan/point.cfg diff --git a/dist/resource/proxy.cfg b/dist/rootfs/etc/sysconfig/openlan/proxy.cfg similarity index 100% rename from dist/resource/proxy.cfg rename to dist/rootfs/etc/sysconfig/openlan/proxy.cfg diff --git a/dist/resource/switch.cfg b/dist/rootfs/etc/sysconfig/openlan/switch.cfg similarity index 100% rename from dist/resource/switch.cfg rename to dist/rootfs/etc/sysconfig/openlan/switch.cfg diff --git a/dist/resource/90-openlan.conf b/dist/rootfs/etc/sysctl.d/90-openlan.conf similarity index 100% rename from dist/resource/90-openlan.conf rename to dist/rootfs/etc/sysctl.d/90-openlan.conf diff --git a/dist/resource/openlan-confd.service b/dist/rootfs/usr/lib/systemd/system/openlan-confd.service similarity index 100% rename from dist/resource/openlan-confd.service rename to dist/rootfs/usr/lib/systemd/system/openlan-confd.service diff --git a/dist/resource/openlan-point@.service b/dist/rootfs/usr/lib/systemd/system/openlan-point@.service similarity index 100% rename from dist/resource/openlan-point@.service rename to dist/rootfs/usr/lib/systemd/system/openlan-point@.service diff --git a/dist/resource/openlan-proxy.service b/dist/rootfs/usr/lib/systemd/system/openlan-proxy.service similarity index 100% rename from dist/resource/openlan-proxy.service rename to dist/rootfs/usr/lib/systemd/system/openlan-proxy.service diff --git a/dist/resource/openlan-switch.service b/dist/rootfs/usr/lib/systemd/system/openlan-switch.service similarity index 100% rename from dist/resource/openlan-switch.service rename to dist/rootfs/usr/lib/systemd/system/openlan-switch.service diff --git a/dist/resource/example.ovpn b/dist/rootfs/var/openlan/openvpn/example.ovpn similarity index 100% rename from dist/resource/example.ovpn rename to dist/rootfs/var/openlan/openvpn/example.ovpn diff --git a/dist/resource/openvpn.md b/dist/rootfs/var/openlan/openvpn/openvpn.md similarity index 100% rename from dist/resource/openvpn.md rename to dist/rootfs/var/openlan/openvpn/openvpn.md diff --git a/dist/script/bridge b/dist/rootfs/var/openlan/script/bridge similarity index 100% rename from dist/script/bridge rename to dist/rootfs/var/openlan/script/bridge diff --git a/dist/script/confd.sh b/dist/rootfs/var/openlan/script/confd.sh similarity index 100% rename from dist/script/confd.sh rename to dist/rootfs/var/openlan/script/confd.sh diff --git a/dist/script/eth0.cfg b/dist/rootfs/var/openlan/script/eth0.cfg similarity index 100% rename from dist/script/eth0.cfg rename to dist/rootfs/var/openlan/script/eth0.cfg diff --git a/dist/script/ifcfg-veth0 b/dist/rootfs/var/openlan/script/ifcfg-veth0 similarity index 100% rename from dist/script/ifcfg-veth0 rename to dist/rootfs/var/openlan/script/ifcfg-veth0 diff --git a/dist/script/ifdown-veth b/dist/rootfs/var/openlan/script/ifdown-veth similarity index 100% rename from dist/script/ifdown-veth rename to dist/rootfs/var/openlan/script/ifdown-veth diff --git a/dist/script/ifup-veth b/dist/rootfs/var/openlan/script/ifup-veth similarity index 100% rename from dist/script/ifup-veth rename to dist/rootfs/var/openlan/script/ifup-veth diff --git a/dist/script/install.sh b/dist/rootfs/var/openlan/script/install.sh similarity index 100% rename from dist/script/install.sh rename to dist/rootfs/var/openlan/script/install.sh diff --git a/dist/script/ovs-vswitchd.sh b/dist/rootfs/var/openlan/script/ovs-vswitchd.sh similarity index 100% rename from dist/script/ovs-vswitchd.sh rename to dist/rootfs/var/openlan/script/ovs-vswitchd.sh diff --git a/dist/script/ovsdb-server.sh b/dist/rootfs/var/openlan/script/ovsdb-server.sh similarity index 100% rename from dist/script/ovsdb-server.sh rename to dist/rootfs/var/openlan/script/ovsdb-server.sh diff --git a/dist/script/prepare b/dist/rootfs/var/openlan/script/prepare similarity index 100% rename from dist/script/prepare rename to dist/rootfs/var/openlan/script/prepare diff --git a/dist/script/setup.sh b/dist/rootfs/var/openlan/script/setup.sh similarity index 100% rename from dist/script/setup.sh rename to dist/rootfs/var/openlan/script/setup.sh diff --git a/dist/script/switch.sh b/dist/rootfs/var/openlan/script/switch.sh similarity index 100% rename from dist/script/switch.sh rename to dist/rootfs/var/openlan/script/switch.sh diff --git a/dist/script/update.sh b/dist/rootfs/var/openlan/script/update.sh similarity index 100% rename from dist/script/update.sh rename to dist/rootfs/var/openlan/script/update.sh