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.

98 lines
2.7 KiB

  1. # Copyright (c) 2017 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:=vpnbypass
  5. PKG_VERSION:=1.3.1
  6. PKG_RELEASE:=1
  7. PKG_LICENSE:=GPL-3.0+
  8. PKG_MAINTAINER:=Stan Grishin <stangri@melmac.net>
  9. include $(INCLUDE_DIR)/package.mk
  10. define Package/vpnbypass
  11. SECTION:=net
  12. CATEGORY:=Network
  13. DEPENDS:=+ipset +iptables
  14. CONFLICTS:=vpn-policy-routing
  15. TITLE:=VPN Bypass Service
  16. PKGARCH:=all
  17. endef
  18. define Package/vpnbypass/description
  19. This service can be used to enable simple VPN split tunnelling.
  20. Supports accessing domains, IP ranges outside of your VPN tunnel.
  21. Also supports dedicating local ports/IP ranges for direct
  22. internet access (outside of your VPN tunnel).
  23. Please see the README for further information.
  24. endef
  25. define Package/vpnbypass/conffiles
  26. /etc/config/vpnbypass
  27. endef
  28. define Build/Prepare
  29. mkdir -p $(PKG_BUILD_DIR)/files/
  30. $(CP) ./files/vpnbypass.init $(PKG_BUILD_DIR)/files/vpnbypass.init
  31. sed -i "s|^\(PKG_VERSION\).*|\1='$(PKG_VERSION)-$(PKG_RELEASE)'|" $(PKG_BUILD_DIR)/files/vpnbypass.init
  32. endef
  33. define Build/Configure
  34. endef
  35. define Build/Compile
  36. endef
  37. define Package/vpnbypass/install
  38. $(INSTALL_DIR) $(1)/etc/init.d
  39. $(INSTALL_BIN) $(PKG_BUILD_DIR)/files/vpnbypass.init $(1)/etc/init.d/vpnbypass
  40. $(INSTALL_DIR) $(1)/etc/config
  41. $(INSTALL_CONF) ./files/vpnbypass.conf $(1)/etc/config/vpnbypass
  42. $(INSTALL_DIR) $(1)/etc/hotplug.d/firewall
  43. $(INSTALL_DATA) ./files/vpnbypass.hotplug $(1)/etc/hotplug.d/firewall/94-vpnbypass
  44. endef
  45. define Package/$(PKG_NAME)/postinst
  46. #!/bin/sh
  47. # check if we are on real system
  48. if [ -z "$${IPKG_INSTROOT}" ]; then
  49. while [ ! -z "$(uci -q get ucitrack.@vpnbypass[-1] 2>/dev/null)" ] ; do
  50. uci -q delete ucitrack.@vpnbypass[-1]
  51. done
  52. while [ ! -z "$(uci -q get ucitrack.@firewall[-1].affects 2>/dev/null | awk '/vpnbypass/')" ] ; do
  53. uci -q del_list ucitrack.@firewall[-1].affects='vpnbypass'
  54. done
  55. uci -q batch <<-EOF >/dev/null
  56. add ucitrack vpnbypass
  57. set ucitrack.@vpnbypass[-1].init='vpnbypass'
  58. add_list ucitrack.@firewall[-1].affects='vpnbypass'
  59. commit ucitrack
  60. EOF
  61. fi
  62. exit 0
  63. endef
  64. define Package/$(PKG_NAME)/prerm
  65. #!/bin/sh
  66. # check if we are on real system
  67. if [ -z "$${IPKG_INSTROOT}" ]; then
  68. echo "Stopping service and removing rc.d symlink for vpnbypass"
  69. /etc/init.d/vpnbypass stop || true
  70. /etc/init.d/vpnbypass disable
  71. while [ ! -z "$(uci -q get ucitrack.@vpnbypass[-1] 2>/dev/null)" ] ; do
  72. uci -q delete ucitrack.@vpnbypass[-1]
  73. done
  74. while [ ! -z "$(uci -q get ucitrack.@firewall[-1].affects 2>/dev/null | awk '/vpnbypass/')" ] ; do
  75. uci -q del_list ucitrack.@firewall[-1].affects='vpnbypass'
  76. done
  77. fi
  78. exit 0
  79. endef
  80. $(eval $(call BuildPackage,vpnbypass))