You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
2.7 KiB

  1. # Copyright 2017-2018 Stan Grishin (stangri@melmac.net)
  2. # This is free software, licensed under the GNU General Public License v3.
  3. include $(TOPDIR)/rules.mk
  4. PKG_NAME:=vpn-policy-routing
  5. PKG_VERSION:=0.2.1
  6. PKG_RELEASE:=3
  7. PKG_LICENSE:=GPL-3.0-or-later
  8. PKG_MAINTAINER:=Stan Grishin <stangri@melmac.net>
  9. include $(INCLUDE_DIR)/package.mk
  10. define Package/vpn-policy-routing
  11. SECTION:=net
  12. CATEGORY:=Network
  13. TITLE:=VPN Policy-Based Routing Service
  14. DEPENDS:=+ipset +iptables +resolveip +kmod-ipt-ipset +iptables-mod-ipopt +!BUSYBOX_CONFIG_IP:ip-full
  15. PKGARCH:=all
  16. endef
  17. define Package/vpn-policy-routing/description
  18. This service allows policy-based routing for L2TP, Openconnect, OpenVPN, PPTP and Wireguard tunnels and WAN interface.
  19. Policies can specify domains, local IPs/subnets and ports, as well as remote IPs/subnets and ports.
  20. endef
  21. define Package/vpn-policy-routing/conffiles
  22. /etc/config/vpn-policy-routing
  23. endef
  24. define Build/Prepare
  25. mkdir -p $(PKG_BUILD_DIR)/files/
  26. $(CP) ./files/vpn-policy-routing.init $(PKG_BUILD_DIR)/files/vpn-policy-routing.init
  27. sed -i "s|^\(PKG_VERSION\).*|\1='$(PKG_VERSION)-$(PKG_RELEASE)'|" $(PKG_BUILD_DIR)/files/vpn-policy-routing.init
  28. endef
  29. define Build/Configure
  30. endef
  31. define Build/Compile
  32. endef
  33. define Package/vpn-policy-routing/install
  34. $(INSTALL_DIR) $(1)/etc/init.d
  35. $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/vpn-policy-routing.init $(1)/etc/init.d/vpn-policy-routing
  36. $(INSTALL_DIR) $(1)/etc/config
  37. $(INSTALL_CONF) ./files/vpn-policy-routing.conf $(1)/etc/config/vpn-policy-routing
  38. $(INSTALL_DIR) $(1)/etc/hotplug.d/firewall
  39. $(INSTALL_DATA) ./files/vpn-policy-routing.firewall.hotplug $(1)/etc/hotplug.d/firewall/99-vpn-policy-routing
  40. $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
  41. $(INSTALL_DATA) ./files/vpn-policy-routing.iface.hotplug $(1)/etc/hotplug.d/iface/70-vpn-policy-routing
  42. $(INSTALL_DIR) $(1)/etc/
  43. $(INSTALL_DATA) ./files/vpn-policy-routing.aws.user $(1)/etc/vpn-policy-routing.aws.user
  44. $(INSTALL_DIR) $(1)/etc/
  45. $(INSTALL_DATA) ./files/vpn-policy-routing.netflix.user $(1)/etc/vpn-policy-routing.netflix.user
  46. endef
  47. define Package/vpn-policy-routing/postinst
  48. #!/bin/sh
  49. # check if we are on real system
  50. if [ -z "$${IPKG_INSTROOT}" ]; then
  51. /etc/init.d/vpn-policy-routing enable
  52. if ! /bin/ubus -S call system board | /bin/grep 'Turris' | /bin/grep -q '15.05' ; then
  53. rm -rf /etc/hotplug.d/iface/70-vpn-policy-routing
  54. fi
  55. fi
  56. exit 0
  57. endef
  58. define Package/vpn-policy-routing/prerm
  59. #!/bin/sh
  60. # check if we are on real system
  61. if [ -z "$${IPKG_INSTROOT}" ]; then
  62. echo "Stopping service and removing rc.d symlink for vpn-policy-routing"
  63. /etc/init.d/vpn-policy-routing stop || true
  64. /etc/init.d/vpn-policy-routing disable || true
  65. fi
  66. exit 0
  67. endef
  68. $(eval $(call BuildPackage,vpn-policy-routing))