summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatze Miau <miaukatzemiau@priveasy.de>2011-12-11 15:54:48 (GMT)
committerKatze Miau <miaukatzemiau@priveasy.de>2011-12-11 15:54:48 (GMT)
commitee91359463ae23b2ebe5cb235c7e11d362be81c8 (patch)
tree2b618dbf99d44a3b66baf70aacec2eff3bb26dd2
parent9809a97ce4ac8f5b374c7b1d91b5d4571dbf6392 (diff)
fsm inetable: add uhttpd state helpers, enable service httpd at boot
Add function to enable/disable/change the uhttpd uci config state. Use these functions to start the service httpd, listening on the link-local IPv6 addresses of br-lan and br-mesh.
-rw-r--r--files/common/etc/fsm/inetable/common.sh26
-rwxr-xr-xfiles/common/etc/fsm/inetable/trans/boot.leave7
2 files changed, 33 insertions, 0 deletions
diff --git a/files/common/etc/fsm/inetable/common.sh b/files/common/etc/fsm/inetable/common.sh
index 148c369..3625caa 100644
--- a/files/common/etc/fsm/inetable/common.sh
+++ b/files/common/etc/fsm/inetable/common.sh
@@ -23,3 +23,29 @@ delete network.mesh.proto
delete network.mesh.netmask
" | uci batch
}
+
+# enable/disable uhttpd instance in uci config; the parameters are
+# 1. instance name
+# 2. addresses to listen on (white-space delimted list)
+enable_httpd () {
+ uci set uhttpd.$1=uhttpd
+ for i in $2; do
+ uci add_list uhttpd.$1.listen_http=$i
+ done
+}
+
+disable_httpd () {
+ uci set uhttpd.$1=disabled
+ uci delete uhttp.$1.listen_http &>/dev/null || true
+}
+
+# change the interfaces the service httpd is listening on;
+# automatically adds linklocal IPv6 addresses of br-mesh and br-lan
+change_service_httpd_listen () {
+ uci delete uhttp.service.listen_http &>/dev/null || true
+ for i in $1 \
+ [$(ifconfig br-mesh | egrep -o 'fe80[:0-9a-f]*')%br-mesh]:80 \
+ [$(ifconfig br-lan | egrep -o 'fe80[:0-9a-f]*')%br-lan]:80; do
+ uci add_list uhttpd.service.listen_http=$i
+ done
+}
diff --git a/files/common/etc/fsm/inetable/trans/boot.leave b/files/common/etc/fsm/inetable/trans/boot.leave
index 233ef9e..431c0b8 100755
--- a/files/common/etc/fsm/inetable/trans/boot.leave
+++ b/files/common/etc/fsm/inetable/trans/boot.leave
@@ -1,4 +1,5 @@
#!/bin/sh -e
+. ../common.sh
# init gwid table by merging it with a hand-crafted table in which all
# available IPs are stored as free with version zero. This guarantees
@@ -9,3 +10,9 @@ done > /tmp/gwip-init
p2ptbl init /tmp/p2ptbl/gwip
p2ptbl merge /tmp/p2ptbl/gwip /tmp/gwip-init
rm /tmp/gwip-init
+
+# start service httpd, listening on the link-local addrs of mesh and
+# lan
+enable_httpd service
+change_service_httpd_listen
+/etc/init.d/uhttpd restart
contact: Jan Huwald // Impressum