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