This repository has been archived by the owner on May 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
168 lines (139 loc) · 4.91 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#
# Copyright (C) 2022-2023 muink
#
# This is free software, licensed under the GNU General Public License v3.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=natter
PKG_VERSION=0.9
PKG_RELEASE:=20230828
PKG_MAINTAINER:=muink <hukk1996@gmail.com>
PKG_LICENSE:=GPL-3
PKG_LICENSE_FILES:=LICENSE
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/MikeWang000000/Natter.git
PKG_SOURCE_VERSION:=b84622e39ea9a5247e772078a8aaaf3be0e667d7
PKG_MIRROR_HASH:=209038ad15c63e7481e71215e6be9fd0afabb3045e214252d77a514f9c1741ac
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_BUILD_PARALLEL:=1
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
SECTION:=net
CATEGORY:=Network
TITLE:=Open Port under FullCone NAT (NAT 1)
URL:=https://github.com/MikeWang000000/Natter
DEPENDS:=+python3-light +bash +coreutils-base64 +curl +jsonfilter \
+$(PKG_NAME)-notify-script-telegram \
+$(PKG_NAME)-ddns-script-cloudflare
PKGARCH:=all
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/$(PKG_NAME)/conffiles
/etc/config/$(PKG_NAME)
/etc/config/$(PKG_NAME)-plugins
/etc/$(PKG_NAME)/custom-script.sh
endef
define Package/$(PKG_NAME)/postinst
#!/bin/sh
if [ -n "$${IPKG_INSTROOT}" ]; then
[ -f "$${IPKG_INSTROOT}/usr/sbin/nft" ] && FW='fw4' || FW='fw3'
sed -i "\$$a\\\n\
config include '$(PKG_NAME)'\n\
\toption type 'script'\n\
\toption path '/usr/share/$(PKG_NAME)/$$FW.include'\
" "$${IPKG_INSTROOT}/etc/config/firewall"
if [ "$$FW" == "fw3" ]; then
sed -i "\$$a\\
\toption family 'any'\n\
\toption reload '1'\
" "$${IPKG_INSTROOT}/etc/config/firewall"
fi
else
[ -x "$$(command -v nft)" ] && FW='fw4' || FW='fw3'
uci -q batch <<-EOF
delete firewall.$(PKG_NAME)
set firewall.$(PKG_NAME)=include
set firewall.$(PKG_NAME).type=script
set firewall.$(PKG_NAME).path=/usr/share/$(PKG_NAME)/$$FW.include
commit firewall
EOF
if [ "$$FW" == "fw3" ]; then
uci -q batch <<-EOF
set firewall.$(PKG_NAME).family=any
set firewall.$(PKG_NAME).reload=1
commit firewall
EOF
fi
fi
endef
define Package/$(PKG_NAME)/prerm
#!/bin/sh
uci delete firewall.$(PKG_NAME)
uci commit firewall
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) ./natter $(1)/usr/sbin/natter
$(INSTALL_DIR) $(1)/usr/share/$(PKG_NAME)
$(INSTALL_BIN) $(PKG_BUILD_DIR)/natter-hook.sh $(1)/usr/share/$(PKG_NAME)/natter-hook.sh
$(INSTALL_DATA) $(PKG_BUILD_DIR)/natter.py $(1)/usr/share/$(PKG_NAME)/natter.py
$(INSTALL_DATA) $(PKG_BUILD_DIR)/natter-config.template.json $(1)/usr/share/$(PKG_NAME)/natter-config.template.json
$(INSTALL_DATA) ./files/fw3.include $(1)/usr/share/$(PKG_NAME)/fw3.include
$(INSTALL_DATA) ./files/fw4.include $(1)/usr/share/$(PKG_NAME)/fw4.include
$(INSTALL_BIN) ./files/plugins.sh $(1)/usr/share/$(PKG_NAME)/plugins.sh
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/natter.init $(1)/etc/init.d/$(PKG_NAME)
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/natter.config $(1)/etc/config/$(PKG_NAME)
$(INSTALL_CONF) ./files/natter-plugins.config $(1)/etc/config/$(PKG_NAME)-plugins
$(INSTALL_DIR) $(1)/usr/libexec/$(PKG_NAME)
$(INSTALL_BIN) ./files/natcheck.sh $(1)/usr/libexec/$(PKG_NAME)/natcheck.sh
$(INSTALL_DIR) $(1)/etc/hotplug.d/iface
$(INSTALL_DATA) ./files/natter.hotplug $(1)/etc/hotplug.d/iface/70-$(PKG_NAME)
$(INSTALL_DIR) $(1)/usr/share/nftables.d
$(CP) ./files/nftables.d/* $(1)/usr/share/nftables.d/
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/uci-defaults $(1)/etc/uci-defaults/70_$(PKG_NAME)
endef
define Package/$(PKG_NAME)-scripts/Default
SECTION:=net
CATEGORY:=Network
TITLE:=Natter $(1) scripts ($(2))
DEPENDS:=+natter
PROVIDES:=natter-$(1)-scripts
PKGARCH:=all
endef
define Package/$(PKG_NAME)-notify-script-telegram
$(call Package/$(PKG_NAME)-scripts/Default,notify,telegram)
DEPENDS+:=
endef
define Package/$(PKG_NAME)-notify-script-pushbullet
$(call Package/$(PKG_NAME)-scripts/Default,notify,pushbullet)
DEPENDS+:=
endef
define Package/$(PKG_NAME)-ddns-script-cloudflare
$(call Package/$(PKG_NAME)-scripts/Default,ddns,cloudflare)
DEPENDS+:=
endef
define Package/$(PKG_NAME)-scripts/install/Default
$(INSTALL_DIR) $(1)/etc/$(PKG_NAME)/$(2)
$(INSTALL_BIN) ./files/$(2)/$(3).sh $(1)/etc/$(PKG_NAME)/$(2)/
endef
define Package/$(PKG_NAME)-notify-script-telegram/install
$(call Package/$(PKG_NAME)-scripts/install/Default,$(1),notify,telegram)
endef
define Package/$(PKG_NAME)-notify-script-pushbullet/install
$(call Package/$(PKG_NAME)-scripts/install/Default,$(1),notify,pushbullet)
endef
define Package/$(PKG_NAME)-ddns-script-cloudflare/install
$(call Package/$(PKG_NAME)-scripts/install/Default,$(1),ddns,cloudflare)
endef
$(eval $(call BuildPackage,$(PKG_NAME)))
$(eval $(call BuildPackage,$(PKG_NAME)-notify-script-telegram))
$(eval $(call BuildPackage,$(PKG_NAME)-notify-script-pushbullet))
$(eval $(call BuildPackage,$(PKG_NAME)-ddns-script-cloudflare))