浏览代码

gnunet: update source, read config from UCI, add defaults

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Daniel Golle 9 年前
父节点
当前提交
a9258527c3
共有 3 个文件被更改,包括 66 次插入26 次删除
  1. 3
    1
      net/gnunet/Makefile
  2. 40
    0
      net/gnunet/files/gnunet.defaults
  3. 23
    25
      net/gnunet/files/gnunet.init

+ 3
- 1
net/gnunet/Makefile 查看文件

@@ -8,7 +8,7 @@
8 8
 include $(TOPDIR)/rules.mk
9 9
 
10 10
 PKG_NAME:=gnunet
11
-PKG_SOURCE_VERSION:=36139
11
+PKG_SOURCE_VERSION:=36190
12 12
 PKG_VERSION:=0.10.1-svn$(PKG_SOURCE_VERSION)
13 13
 PKG_RELEASE:=1
14 14
 
@@ -167,6 +167,8 @@ define Package/gnunet/install
167 167
 	$(INSTALL_BIN) ./files/gnunet.init $(1)/etc/init.d/gnunet
168 168
 	$(INSTALL_DIR) $(1)/lib/upgrade/keep.d
169 169
 	$(INSTALL_DATA) ./files/gnunet.upgrade $(1)/lib/upgrade/keep.d/gnunet
170
+	$(INSTALL_DIR) $(1)/etc/uci-defaults
171
+	$(INSTALL_BIN) ./files/gnunet.defaults $(1)/etc/uci-defaults/gnunet
170 172
 endef
171 173
 
172 174
 define Build/InstallDev

+ 40
- 0
net/gnunet/files/gnunet.defaults 查看文件

@@ -0,0 +1,40 @@
1
+#!/bin/sh
2
+
3
+[ -e /etc/config/gnunet ] && exit 0
4
+
5
+touch /etc/config/gnunet
6
+
7
+uci set gnunet.datastore=gnunet-config
8
+uci set gnunet.datastore.DATABASE=heap
9
+uci set gnunet.datastore.QUOTA="4 MB"
10
+
11
+uci set gnunet.fs=gnunet-config
12
+uci set gnunet.fs.CONTENT_PUSHING=NO
13
+uci set gnunet.fs.CONTENT_CACHING=NO
14
+
15
+# limit dhtcache memory usage to 4 MB
16
+uci set gnunet.dhtcache=gnunet-config
17
+uci set gnunet.dhtcache.QUOTA="4 MB"
18
+
19
+# enable dns2gns
20
+uci set gnunet.dns2gns=gnunet-config
21
+uci set gnunet.dns2gns.AUTOSTART=YES
22
+uci set gnunet.dns2gns.FORCESTART=YES
23
+
24
+# enable v4/v6 protocol translation for EXIT/VPN
25
+uci set gnunet.pt=gnunet-config
26
+uci set gnunet.pt.FORCESTART=YES
27
+
28
+uci set gnunet.exit=gnunet-config
29
+uci set gnunet.exit.AUTOSTART=YES
30
+uci set gnunet.exit.FORCESTART=YES
31
+uci set gnunet.exit.EXIT_IPV4=YES
32
+uci set gnunet.exit.EXIT_RANGE_IPV4_POLICY="169.254.86.1:7;169.254.86.1:5201;"
33
+
34
+# iperf (TCP) and echo (UDP) for battlemesh
35
+uci set gnunet.iperf=gnunet-exit-service
36
+uci set gnunet.iperf.TCP_REDIRECTS="5201:169.254.86.1:5201"
37
+uci set gnunet.echo=gnunet-exit-service
38
+uci set gnunet.echo.UDP_REDIRECTS="7:169.254.86.1:7"
39
+
40
+uci commit gnunet

+ 23
- 25
net/gnunet/files/gnunet.init 查看文件

@@ -47,6 +47,8 @@ prepare_config() {
47 47
 		mkdir -p /etc/gnunet
48 48
 		chown gnunet:gnunet /etc/gnunet
49 49
 	}
50
+
51
+	# defaults paths
50 52
 	gnunet-config -c $CONFIGFILE -s PATHS -o GNUNET_CONFIG_HOME -V /etc/gnunet
51 53
 	gnunet-config -c $CONFIGFILE -s PEER -o PRIVATE_KEY -V /etc/gnunet/private_key.ecc
52 54
 	gnunet-config -c $CONFIGFILE -s identity -o EGODIR -V /etc/gnunet/identity/egos
@@ -54,19 +56,6 @@ prepare_config() {
54 56
 	gnunet-config -c $CONFIGFILE -s nse -o PROOFFILE -V /etc/gnunet/proof.dat
55 57
 	gnunet-config -c $CONFIGFILE -s namestore-sqlite -o FILENAME -V /etc/gnunet/namestore.sqlite
56 58
 
57
-	# minimal datastore (todo: make this configurable)
58
-	gnunet-config -c $CONFIGFILE -s datastore -o DATABASE -V heap
59
-	gnunet-config -c $CONFIGFILE -s datastore -o QUOTA -V "4 MB"
60
-	gnunet-config -c $CONFIGFILE -s fs -o CONTENT_PUSHING -V NO
61
-	gnunet-config -c $CONFIGFILE -s fs -o CONTENT_CACHING -V NO
62
-
63
-	# limit dhtcache memory usage to 4 MB
64
-	gnunet-config -c $CONFIGFILE -s dhtcache -o QUOTA -V "4 MB"
65
-
66
-	# enable dns2gns
67
-	gnunet-config -c $CONFIGFILE -s dns2gns -o AUTOSTART -V YES
68
-	gnunet-config -c $CONFIGFILE -s dns2gns -o FORCESTART -V YES
69
-
70 59
 	# enable all installed transport plugins
71 60
 	transport_plugins=$(gnunet-config -c $CONFIGFILE -s transport -o PLUGINS)
72 61
 	for transplug in /usr/lib/gnunet/libgnunet_plugin_transport_*.so; do
@@ -77,18 +66,27 @@ prepare_config() {
77 66
 	done
78 67
 	gnunet-config -c $CONFIGFILE -s transport -o PLUGINS -V "$transport_plugins"
79 68
 
80
-	gnunet-config -c $CONFIGFILE -s pt -o FORCESTART -V YES
81
-	gnunet-config -c $CONFIGFILE -s exit -o AUTOSTART -V YES
82
-	gnunet-config -c $CONFIGFILE -s exit -o FORCESTART -V YES
83
-	gnunet-config -c $CONFIGFILE -s exit -o EXIT_IPV4 -V YES
84
-	# ssh and www services
85
-#	gnunet-config -c $CONFIGFILE -s exit -o EXIT_RANGE_IPV4_POLICY -V "169.254.86.1:22;169.254.86.1:80;"
86
-#	gnunet-config -c $CONFIGFILE -s ssh.gnunet. -o TCP_REDIRECTS -V "22:169.254.86.1:22"
87
-#	gnunet-config -c $CONFIGFILE -s www.gnunet. -o TCP_REDIRECTS -V "80:169.254.86.1:80"
88
-	# iperf (TCP) and echo (UDP) for battlemesh
89
-	gnunet-config -c $CONFIGFILE -s exit -o EXIT_RANGE_IPV4_POLICY -V "169.254.86.1:7;169.254.86.1:5201;"
90
-	gnunet-config -c $CONFIGFILE -s iperf.gnunet. -o TCP_REDIRECTS -V "5201:169.254.86.1:5201"
91
-	gnunet-config -c $CONFIGFILE -s echo.gnunet. -o UDP_REDIRECTS -V "7:169.254.86.1:7"
69
+	# apply config from UCI
70
+	_gnunet_section=""
71
+	config_cb()
72
+	{
73
+		# $1    "Type"
74
+		# $2    "Name"
75
+		local __TYPE="$1"
76
+		local __NAME="$2"
77
+		[ "${__TYPE}" = "gnunet-config" ] && _gnunet_section="${__NAME}"
78
+		[ "${__TYPE}" = "gnunet-exit-service" ] && _gnunet_section="${__NAME}.gnunet."
79
+	}
80
+	option_cb() {
81
+		# $1    name of variable
82
+		# $2    value
83
+		local __OPT="$1"
84
+		local __VAL="$2"
85
+		gnunet-config -c $CONFIGFILE -s ${_gnunet_section} -o ${__OPT} -V "${__VAL}"
86
+	}
87
+	config_load gnunet
88
+
89
+	return 0
92 90
 }
93 91
 
94 92
 start_service() {