Coovachilli + local ip

Hi.
I'm tinkering with my nanopi neo2 and finally managed to build OpenWrt from source.
It's so much lighter than Armbian, and hopefully I could build the WiringNP on it.

I have basic coovachilli setup and still figuring out settings, it seems to be working.
My nanopi is setup as dhcp client, with an old Asus USB n-13 wifi dongle (I have it for a long time but never works untill now).

I'd like to know how I can pass local ip address of eth0 after it get it's address from the router
to chilli configuration.

I looked at /etc/init.d/chilli. I could almost understand what's going on there...but not really :blush:
I'm thinking that I could do something like this in the startup script:

. /lib/functions/network.sh
local ip
network_get_ipaddr ip "$2"
echo "uamserver=http://\"$ip\"/hotspot/hotspotlogin.php" >> "$chilli_conf"

That above is an imagined function, knowing very little about scripting and imitated from chilli startup script.

Check if you can use localhost or 127.0.0.1, otherwise:

. /lib/functions/network.sh
network_flush_cache
network_find_wan NET_IF
network_get_ipaddr NET_ADDR "${NET_IF}"
uci set chilli.@chilli[0].uamserver="http://${NET_ADDR}/..."
/etc/init.d/chilli restart 

And invoke it via hotplug:
https://openwrt.org/docs/guide-user/base-system/hotplug

1 Like

Thanks..looks like a plan, just have to digest the hotplug and hopefully good to go.
I just tried this on the console:

root@OpenWrt:/# source /lib/functions/network.sh
root@OpenWrt:/# network_find_wan NET_IF
root@OpenWrt:/# network_get_ipaddr NET_ADDR "${NET_IF}"
root@OpenWrt:/# echo ${NET_ADDR}
192.168.1.101
root@OpenWrt:/#

It works :smile:

#!/bin/sh
source /lib/functions/network.sh

[ "$ACTION" == "ifup" ] || exit 0

[ "$INTERFACE" = "wan" ] && {

network_find_wan NET_IF
network_get_ipaddr NET_ADDR "${NET_IF}"
uci set chilli.@chilli[0].uamserver="http://${NET_ADDR}/hotspot/login.php"
/etc/init.d/chilli restart

}

I added it to file 30-chilli I found in hotplug.d/iface
I think I could also add a chilli directory in the hotplug.d
If I'm understanding this (snippets from init.d/chilli )correctly:

service_triggers() {
procd_add_reload_trigger "chilli"
}

but it works now.
Thanks.

P.S.
BTW localhost/127.0.0.1 didn't work.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.