mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-10-29 14:25:13 +08:00
🍓 Sync 2026-09-15 02:13:06
This commit is contained in:
1 parent
0e5393594c
commit
1dd96ac2bb
146 files changed
+26541
-508
No files matched your search
@@ -0,0 +1,89 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
#
|
||||
# Copyright (C) 2021 ImmortalWrt.org
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=cloudflared-next
|
||||
PKG_VERSION:=2026.9.1
|
||||
PKG_RELEASE:=1
|
||||
|
||||
# Architecture mapping for pre-built binaries
|
||||
ifeq ($(ARCH),x86_64)
|
||||
CF_ARCH:=amd64
|
||||
endif
|
||||
ifeq ($(ARCH),aarch64)
|
||||
CF_ARCH:=arm64
|
||||
endif
|
||||
ifeq ($(ARCH),arm64)
|
||||
CF_ARCH:=arm64
|
||||
endif
|
||||
ifeq ($(ARCH),armv8)
|
||||
CF_ARCH:=arm64
|
||||
endif
|
||||
ifeq ($(ARCH),arm)
|
||||
CF_ARCH:=arm
|
||||
endif
|
||||
ifeq ($(ARCH),armv7)
|
||||
CF_ARCH:=arm
|
||||
endif
|
||||
ifeq ($(ARCH),i386)
|
||||
CF_ARCH:=386
|
||||
endif
|
||||
|
||||
PKG_SOURCE:=cloudflared-linux-$(CF_ARCH)-$(PKG_VERSION)
|
||||
PKG_SOURCE_URL:=https://github.com/cloudflare/cloudflared/releases/download/$(PKG_VERSION)/cloudflared-linux-$(CF_ARCH)?
|
||||
PKG_HASH:=skip
|
||||
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
|
||||
PKG_LICENSE:=Apache-2.0
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/cloudflared-next
|
||||
SECTION:=net
|
||||
CATEGORY:=Network
|
||||
SUBMENU:=Web Servers/Proxies
|
||||
TITLE:=Cloudflare Tunnel client Next - Pre-built Binary
|
||||
URL:=https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/get-started/
|
||||
DEPENDS:=@(x86_64||aarch64||arm||i386) +ca-bundle
|
||||
PROVIDES:=cloudflared
|
||||
CONFLICTS:=cloudflared
|
||||
endef
|
||||
|
||||
define Package/cloudflared-next/description
|
||||
Contains the command-line client for Cloudflare Tunnel, a tunneling
|
||||
daemon that proxies traffic from the Cloudflare network to your origins.
|
||||
This package contains official pre-built static binaries.
|
||||
endef
|
||||
|
||||
define Package/cloudflared-next/conffiles
|
||||
/etc/config/cloudflared
|
||||
/etc/cloudflared/
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
mkdir -p $(PKG_BUILD_DIR)
|
||||
$(CP) $(DL_DIR)/$(PKG_SOURCE) $(PKG_BUILD_DIR)/cloudflared
|
||||
chmod 0755 $(PKG_BUILD_DIR)/cloudflared
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/cloudflared-next/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/cloudflared $(1)/usr/bin/cloudflared
|
||||
|
||||
$(INSTALL_DIR) $(1)/etc/cloudflared/
|
||||
$(INSTALL_CONF) $(CURDIR)/files/sample_config.yml $(1)/etc/cloudflared/config.yml
|
||||
$(INSTALL_DIR) $(1)/etc/config/
|
||||
$(INSTALL_CONF) $(CURDIR)/files/cloudflared.config $(1)/etc/config/cloudflared
|
||||
$(INSTALL_DIR) $(1)/etc/init.d/
|
||||
$(INSTALL_BIN) $(CURDIR)/files/cloudflared.init $(1)/etc/init.d/cloudflared
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,cloudflared-next))
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
config cloudflared 'config'
|
||||
option enabled '0'
|
||||
option token ''
|
||||
# option config '/etc/cloudflared/config.yml'
|
||||
# option origincert '/etc/cloudflared/cert.pem'
|
||||
option edge_bind_address ''
|
||||
option edge_ip_version ''
|
||||
option grace_period ''
|
||||
option protocol 'auto'
|
||||
option region ''
|
||||
option retries ''
|
||||
option tag ''
|
||||
option metrics ''
|
||||
option loglevel 'info'
|
||||
option logfile '/var/log/cloudflared.log'
|
||||
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2021 Tianling Shen <cnsztl@immortalwrt.org>
|
||||
|
||||
USE_PROCD=1
|
||||
START=99
|
||||
|
||||
CONF="cloudflared"
|
||||
PROG="/usr/bin/cloudflared"
|
||||
|
||||
append_param_arg() {
|
||||
local value
|
||||
|
||||
config_get value "config" "$1" $2
|
||||
[ -n "$value" ] && procd_append_param command "--${1//_/-}" "$value"
|
||||
}
|
||||
|
||||
start_service() {
|
||||
config_load "$CONF"
|
||||
|
||||
local enabled
|
||||
local token
|
||||
|
||||
config_get_bool enabled "config" "enabled"
|
||||
[ "$enabled" -eq "1" ] || return 1
|
||||
|
||||
procd_open_instance "$CONF"
|
||||
procd_set_param command "$PROG" "tunnel"
|
||||
procd_append_param command "--no-autoupdate"
|
||||
|
||||
append_param_arg "edge_bind_address"
|
||||
append_param_arg "edge_ip_version"
|
||||
append_param_arg "grace_period"
|
||||
append_param_arg "protocol"
|
||||
append_param_arg "region"
|
||||
append_param_arg "retries"
|
||||
append_param_arg "tag"
|
||||
append_param_arg "metrics"
|
||||
append_param_arg "loglevel"
|
||||
append_param_arg "logfile"
|
||||
|
||||
config_get token "config" "token"
|
||||
if [ -z "$token" ]; then
|
||||
# Locally-managed tunnels
|
||||
append_param_arg "config" "/etc/cloudflared/config.yml"
|
||||
append_param_arg "origincert" "/etc/cloudflared/cert.pem"
|
||||
fi
|
||||
|
||||
procd_append_param command "run"
|
||||
|
||||
if [ -n "$token" ]; then
|
||||
# Remotely-managed tunnel (recommended by Cloudflare)
|
||||
procd_append_param command "--token" "$token"
|
||||
fi
|
||||
|
||||
procd_set_param respawn
|
||||
procd_set_param stderr 1
|
||||
|
||||
procd_close_instance
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger "$CONF"
|
||||
procd_add_interface_trigger "interface.*.up" "wan" /etc/init.d/cloudflared restart
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
# https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/do-more-with-tunnels/local-management/configuration-file/
|
||||
|
||||
# NOTICE
|
||||
# Cloudflare recommends setting up a remotely-managed tunnel.
|
||||
# Remotely-managed configurations are stored on Cloudflare,
|
||||
# which allows you to manage the tunnel from any machine
|
||||
# using the dashboard, API, or Terraform.
|
||||
|
||||
#tunnel: <Tunnel-UUID>
|
||||
#credentials-file: /etc/cloudflared/<Tunnel-UUID>.json
|
||||
#
|
||||
#ingress:
|
||||
# - hostname: luci.example.com
|
||||
# service: http://localhost:80
|
||||
# - hostname: ssh.example.com
|
||||
# service: ssh://localhost:22
|
||||
# - service: http_status:404
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
cloudflared --version | grep "$PKG_VERSION"
|
||||
Executable
+78
@@ -0,0 +1,78 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 自动更新 OpenWrt cloudflared-next 包的版本和 Hash
|
||||
# 依赖: curl, grep, sed, sha256sum (或 shasum)
|
||||
|
||||
set -e
|
||||
|
||||
PKG_DIR=$(cd "$(dirname "$0")"; pwd)
|
||||
MAKEFILE="$PKG_DIR/Makefile"
|
||||
|
||||
if [ ! -f "$MAKEFILE" ]; then
|
||||
echo "错误: 找不到 Makefile 文件 ($MAKEFILE)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 1. 获取当前本地版本
|
||||
CURRENT_VERSION=$(grep 'PKG_VERSION:=' "$MAKEFILE" | cut -d'=' -f2 | tr -d ' ')
|
||||
echo "当前本地版本: $CURRENT_VERSION"
|
||||
|
||||
# 2. 获取 GitHub 上的最新版本号
|
||||
# 注意: cloudflared 的 tag 通常是 2024.x.y 这种格式,无需特殊处理
|
||||
LATEST_VERSION=$(curl -s https://api.github.com/repos/cloudflare/cloudflared/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' | sed 's/^v//')
|
||||
|
||||
if [ -z "$LATEST_VERSION" ]; then
|
||||
echo "错误: 无法从 GitHub 获取最新版本号。"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "GitHub 最新版本: $LATEST_VERSION"
|
||||
|
||||
# 3. 比较版本
|
||||
if [ "$CURRENT_VERSION" == "$LATEST_VERSION" ]; then
|
||||
echo "版本已经是最新,无需更新。"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "发现新版本! 正在准备更新..."
|
||||
|
||||
# 4. 下载新版本的源码包并计算 Hash
|
||||
SOURCE_URL="https://codeload.github.com/cloudflare/cloudflared/tar.gz/$LATEST_VERSION"
|
||||
echo "正在从 $SOURCE_URL 下载并计算 Hash..."
|
||||
|
||||
# 探测可用的哈希计算工具
|
||||
if command -v sha256sum >/dev/null 2>&1; then
|
||||
NEW_HASH=$(curl -sL "$SOURCE_URL" | sha256sum | cut -d' ' -f1)
|
||||
elif command -v shasum >/dev/null 2>&1; then
|
||||
NEW_HASH=$(curl -sL "$SOURCE_URL" | shasum -a 256 | cut -d' ' -f1)
|
||||
else
|
||||
echo "错误: 系统中未找到 sha256sum 或 shasum 命令。"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$NEW_HASH" ] || [ ${#NEW_HASH} -ne 64 ]; then
|
||||
echo "错误: 计算得到的 Hash 值无效: $NEW_HASH"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "新 Hash 值: $NEW_HASH"
|
||||
|
||||
# 5. 更新 Makefile
|
||||
# 使用特定的正则表达式确保精准替换
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' "s/PKG_VERSION:=.*/PKG_VERSION:=$LATEST_VERSION/" "$MAKEFILE"
|
||||
sed -i '' "s/PKG_HASH:=.*/PKG_HASH:=$NEW_HASH/" "$MAKEFILE"
|
||||
else
|
||||
sed -i "s/PKG_VERSION:=.*/PKG_VERSION:=$LATEST_VERSION/" "$MAKEFILE"
|
||||
sed -i "s/PKG_HASH:=.*/PKG_HASH:=$NEW_HASH/" "$MAKEFILE"
|
||||
fi
|
||||
|
||||
echo "Makefile 更新成功: $CURRENT_VERSION -> $LATEST_VERSION"
|
||||
|
||||
# 6. 可选: 提交更改 (如果是在 Git 仓库中且您希望自动提交)
|
||||
# cd "$PKG_DIR/.."
|
||||
# if [ -d ".git" ]; then
|
||||
# git add cloudflared-next/Makefile
|
||||
# git commit -m "cloudflared-next: update to version $LATEST_VERSION"
|
||||
# echo "已在本地 Git 仓库中提交更新。"
|
||||
# fi
|
||||
Reference in new issue
Block a user