From 30d8431b71178ab187c0e3d5065b230955c1de0c Mon Sep 17 00:00:00 2001 From: Van Waholtz Date: Sat, 29 Jan 2022 09:39:33 +0800 Subject: [PATCH] frpc: add anonymous proxy config support Signed-off-by: Van Waholtz --- net/frp/Makefile | 5 +++++ net/frp/files/frpc.init | 4 +++- net/frp/files/frpc.uci-defaults | 19 +++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 net/frp/files/frpc.uci-defaults diff --git a/net/frp/Makefile b/net/frp/Makefile index 915d6f735d..5becdb9626 100644 --- a/net/frp/Makefile +++ b/net/frp/Makefile @@ -33,6 +33,11 @@ define Package/frp/install $(INSTALL_CONF) ./files/$(2).config $(1)/etc/config/$(2) $(INSTALL_DIR) $(1)/etc/init.d/ $(INSTALL_BIN) ./files/$(2).init $(1)/etc/init.d/$(2) + + if [ -r ./files/$(2).uci-defaults ]; then \ + $(INSTALL_DIR) $(1)/etc/uci-defaults; \ + $(INSTALL_DATA) ./files/$(2).uci-defaults $(1)/etc/uci-defaults/$(2); \ + fi endef define Package/frp/template diff --git a/net/frp/files/frpc.init b/net/frp/files/frpc.init index 96208d8f14..dc6dac222e 100644 --- a/net/frp/files/frpc.init +++ b/net/frp/files/frpc.init @@ -21,7 +21,9 @@ config_cb() { option_cb() { local option="$1" local value="$2" - echo "$option = $value" >> "$conf_file" + [ "$option" = "name" ] && \ + sed -i "s/$CONFIG_SECTION/$value/g" "$conf_file" || \ + echo "$option = $value" >> "$conf_file"; } list_cb() { local name="$1" diff --git a/net/frp/files/frpc.uci-defaults b/net/frp/files/frpc.uci-defaults new file mode 100644 index 0000000000..4883a2d8c6 --- /dev/null +++ b/net/frp/files/frpc.uci-defaults @@ -0,0 +1,19 @@ +#!/bin/sh + +. /lib/functions.sh + +upgrade() { + local section=$1 + local name + [ "$section" != "common" ] || return 0 + config_get name $section name + if [ -z "$name" ]; then + uci_set frpc "$section" name "$section" + uci_commit frpc + fi +} + +config_load frpc +config_foreach upgrade conf + +exit 0 -- 2.30.2