frpc: add anonymous proxy config support
authorVan Waholtz <vanwaholtz@gmail.com>
Sat, 29 Jan 2022 01:39:33 +0000 (09:39 +0800)
committerRosen Penev <rosenp@gmail.com>
Thu, 24 Feb 2022 06:31:45 +0000 (22:31 -0800)
Signed-off-by: Van Waholtz <vanwaholtz@gmail.com>
net/frp/Makefile
net/frp/files/frpc.init
net/frp/files/frpc.uci-defaults [new file with mode: 0644]

index 915d6f735da02326bdf19550b4f2517b47b715ae..5becdb9626209eae705a4cfc863dada9a16dde67 100644 (file)
@@ -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
index 96208d8f14dbf8acc65d86a191c4286aadac4b03..dc6dac222e100d676a45505276c98e5895cd37a2 100644 (file)
@@ -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 (file)
index 0000000..4883a2d
--- /dev/null
@@ -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