summaryrefslogtreecommitdiff
path: root/files/common/etc/fsm/inetable/common.sh
blob: 8238b9370b7cc3e78e4fd85f0deef1f741acf923 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
cloud_is_online () {
    # look for mac addrs in batman gateway list
    batctl gwl | tail -n-1 | egrep -q '([0-9a-f]{2}:){5}[0-9a-f]{2}'
}

## add/remove IPv4 address from mesh iface
# manual update to avoid full ifdown+ifup, but update uci state for
# other users (e.g. dnsmasq)
mesh_add_ipv4 () {
    ifconfig br-mesh $1 netmask $2
    echo "
set network.mesh.ipaddr=$1
set network.mesh.proto=static
set network.mesh.netmask=$2
" | uci batch
}

mesh_del_ipv4 () {
    ifconfig br-mesh 0.0.0.0
    echo "
delete network.mesh.ipaddr
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 link-local IPv6 addresses of br-mesh and br-lan and the lan-ip
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 \
	$(uci get network.lan.ipaddr):80; do
	uci add_list uhttpd.service.listen_http=$i
    done
}
contact: Jan Huwald // Impressum