mirror of
https://github.com/SunBK201/UA3F.git
synced 2025-12-16 08:44:29 +00:00
feat: support openwrt make build
This commit is contained in:
parent
b4c5b9bc4c
commit
a8df6f359d
2
build.sh
2
build.sh
@ -2,7 +2,7 @@
|
||||
|
||||
project_name="ua3f"
|
||||
release_version="0.5.1"
|
||||
target=main.go
|
||||
target=src/main.go
|
||||
dist=./dist
|
||||
release_dir=./bin
|
||||
|
||||
|
||||
148
install.sh
148
install.sh
@ -17,86 +17,104 @@ ckcmd() {
|
||||
command -v sh >/dev/null 2>&1 && command -v $1 >/dev/null 2>&1 || type $1 >/dev/null 2>&1
|
||||
}
|
||||
|
||||
chmod_clash() {
|
||||
if id -u shellclash >/dev/null 2>&1; then
|
||||
chmod o+w /etc/clash >/dev/null 2>&1
|
||||
fi
|
||||
if id -u shellcrash >/dev/null 2>&1; then
|
||||
chmod o+w /etc/clash >/dev/null 2>&1
|
||||
fi
|
||||
}
|
||||
|
||||
ck_ua3f_log() {
|
||||
chmod ugo+w /var/log
|
||||
if [ -f "/var/log/ua3f.log" ]; then
|
||||
rm "/var/log/ua3f.log"
|
||||
fi
|
||||
touch /var/log/ua3f.log && chmod 666 /var/log/ua3f.log
|
||||
}
|
||||
|
||||
dl_ua3f() {
|
||||
wget https://blog.sunbk201.site/cdn/bin/$ua3f_tar
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Download UA3F Failed, Please Retry."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
wget https://blog.sunbk201.site/cdn/ua3f.init
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Download ua3f.init Failed, Please Retry."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
wget https://blog.sunbk201.site/cdn/ua3f.uci
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Download ua3f.uci Failed, Please Retry."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
wget https://blog.sunbk201.site/cdn/cbi.lua
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Download cbi.lua Failed, Please Retry."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
wget https://blog.sunbk201.site/cdn/controller.lua
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Download controller.lua Failed, Please Retry."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
clean_ua3f() {
|
||||
if [ -f "/etc/init.d/ua3f.init" ]; then
|
||||
rm "/etc/init.d/ua3f.init"
|
||||
fi
|
||||
if [ -f "/etc/init.d/ua3f" ]; then
|
||||
rm "/etc/init.d/ua3f"
|
||||
fi
|
||||
if [ -f "/etc/config/ua3f" ]; then
|
||||
rm "/etc/config/ua3f"
|
||||
fi
|
||||
if [ -f "/usr/lib/lua/luci/model/cbi/ua3f.lua" ]; then
|
||||
rm "/usr/lib/lua/luci/model/cbi/ua3f.lua"
|
||||
fi
|
||||
if [ -f "/usr/lib/lua/luci/controller/ua3f.lua" ]; then
|
||||
rm "/usr/lib/lua/luci/controller/ua3f.lua"
|
||||
fi
|
||||
}
|
||||
|
||||
install_ua3f() {
|
||||
tar zxf $ua3f_tar && rm -f $ua3f_tar
|
||||
mv ua3f /usr/bin/ua3f && chmod +x /usr/bin/ua3f
|
||||
mv ua3f.uci /etc/config/ua3f && chmod +x /etc/config/ua3f
|
||||
mv ua3f.init /etc/init.d/ua3f && chmod +x /etc/init.d/ua3f
|
||||
mkdir -p /usr/lib/lua/luci/model/cbi
|
||||
mkdir -p /usr/lib/lua/luci/controller
|
||||
mv cbi.lua /usr/lib/lua/luci/model/cbi/ua3f.lua
|
||||
mv controller.lua /usr/lib/lua/luci/controller/ua3f.lua
|
||||
}
|
||||
|
||||
cd /root
|
||||
getcpucore
|
||||
|
||||
version=0.5.1
|
||||
ua3f_tar=ua3f-$version-$cpucore.tar.gz
|
||||
|
||||
if id -u shellclash >/dev/null 2>&1; then
|
||||
chmod o+w /etc/clash >/dev/null 2>&1
|
||||
fi
|
||||
if id -u shellcrash >/dev/null 2>&1; then
|
||||
chmod o+w /etc/clash >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
if [ -f "ua3f" ]; then
|
||||
rm "ua3f"
|
||||
killall ua3f >/dev/null 2>&1
|
||||
fi
|
||||
chmod_clash
|
||||
|
||||
if ! command -v sudo >/dev/null 2>&1; then
|
||||
opkg update >/dev/null 2>&1 && opkg install sudo >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
chmod ugo+w /var/log
|
||||
if [ -f "/var/log/ua3f.log" ]; then
|
||||
rm "/var/log/ua3f.log"
|
||||
fi
|
||||
touch /var/log/ua3f.log && chmod 666 /var/log/ua3f.log
|
||||
|
||||
ck_ua3f_log
|
||||
if [ -f "$ua3f_tar" ]; then
|
||||
rm "$ua3f_tar"
|
||||
fi
|
||||
|
||||
wget https://blog.sunbk201.site/cdn/bin/$ua3f_tar
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Download UA3F Failed, Please Retry."
|
||||
exit 1
|
||||
fi
|
||||
tar zxf $ua3f_tar && rm -f $ua3f_tar
|
||||
mv ua3f /usr/bin/ua3f
|
||||
chmod +x /usr/bin/ua3f
|
||||
|
||||
if [ -f "/etc/init.d/ua3f.init" ]; then
|
||||
rm "/etc/init.d/ua3f.init"
|
||||
fi
|
||||
if [ -f "/etc/init.d/ua3f" ]; then
|
||||
rm "/etc/init.d/ua3f"
|
||||
fi
|
||||
wget https://blog.sunbk201.site/cdn/ua3f.init
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Download ua3f.init Failed, Please Retry."
|
||||
exit 1
|
||||
fi
|
||||
mv ua3f.init /etc/init.d/ua3f && chmod +x /etc/init.d/ua3f
|
||||
dl_ua3f
|
||||
clean_ua3f
|
||||
install_ua3f
|
||||
/etc/init.d/ua3f enable
|
||||
|
||||
wget https://blog.sunbk201.site/cdn/ua3f.uci
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Download ua3f.uci Failed, Please Retry."
|
||||
exit 1
|
||||
fi
|
||||
mv ua3f.uci /etc/config/ua3f
|
||||
|
||||
wget https://blog.sunbk201.site/cdn/cbi.lua
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Download cbi.lua Failed, Please Retry."
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p /usr/lib/lua/luci/model/cbi
|
||||
mv cbi.lua /usr/lib/lua/luci/model/cbi/ua3f.lua
|
||||
|
||||
wget https://blog.sunbk201.site/cdn/controller.lua
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Download controller.lua Failed, Please Retry."
|
||||
exit 1
|
||||
fi
|
||||
mkdir -p /usr/lib/lua/luci/controller
|
||||
mv controller.lua /usr/lib/lua/luci/controller/ua3f.lua
|
||||
|
||||
chmod +x /etc/config/ua3f >/dev/null 2>&1
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "Install UA3F Success."
|
||||
fi
|
||||
|
||||
59
openwrt/Makefile
Normal file
59
openwrt/Makefile
Normal file
@ -0,0 +1,59 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=UA3F
|
||||
PKG_VERSION:=0.5.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
# PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
|
||||
# PKG_SOURCE_URL:=https://codeload.github.com/SunBK201/UA3F/tar.gz/v$(PKG_VERSION)
|
||||
# PKG_HASH:=7d9164e31170e5a54fd83fa31785eaad5fb6ffff36a3336060ae32b7cdda9895
|
||||
|
||||
PKG_MAINTAINER:=SunBK201 <sunbk201gm@gmail.com>
|
||||
PKG_LICENSE:=GPL-3.0-only
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
|
||||
PKG_BUILD_DEPENDS:=golang/host
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
PKG_BUILD_FLAGS:=no-mips16
|
||||
|
||||
GO_PKG:=github.com/sunbk201/ua3f
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
|
||||
|
||||
define Package/ua3f
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Web Servers/Proxies
|
||||
TITLE:=A SOCKS5 Server for Change User-Agent
|
||||
URL:=https://github.com/SunBK201/UA3F
|
||||
DEPENDS:=$(GO_ARCH_DEPENDS) +luci-compat
|
||||
endef
|
||||
|
||||
define Package/ua3f/description
|
||||
Implementation of the next generation of HTTP User-Agent modification methodology.
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(CP) ../src/* $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
define Package/ua3f/install
|
||||
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
|
||||
|
||||
$(INSTALL_DIR) $(1)/usr/bin/
|
||||
# $(INSTALL_BIN) $(GO_PKG_BUILD_BIN_DIR)/ua3f $(1)/usr/bin/
|
||||
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ua3f $(1)/usr/bin/
|
||||
$(INSTALL_DIR) $(1)/etc/init.d/
|
||||
$(INSTALL_BIN) ./files/ua3f.init $(1)/etc/init.d/ua3f
|
||||
$(INSTALL_DIR) $(1)/etc/config/
|
||||
$(INSTALL_CONF) ./files/ua3f.uci $(1)/etc/config/ua3f
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi/
|
||||
$(INSTALL_CONF) ./files/luci/cbi.lua $(1)/usr/lib/lua/luci/model/cbi/ua3f.lua
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller/
|
||||
$(INSTALL_CONF) ./files/luci/controller.lua $(1)/usr/lib/lua/luci/controller/ua3f.lua
|
||||
|
||||
endef
|
||||
|
||||
$(eval $(call GoBinPackage,ua3f))
|
||||
$(eval $(call BuildPackage,ua3f))
|
||||
Loading…
Reference in New Issue
Block a user