vortex-5 / ddwrt-bwmon

An Individual Bandwidth Monitor For DD-WRT
171 stars 37 forks source link

Feature: Support for OpenWRT 15.05.1 #29

Closed euphoria360 closed 7 years ago

euphoria360 commented 8 years ago

It would be great if you can make this script compatible with new OpenWRT version, since they are very similar.

Today I tried your great work on my fresh OpenWRT 15.05.1 and it didn't work out of the box. But by looking into the scripts I was able to run it successfully by changing few things. I tried to change your scripts as less as possible. So Only 3 changes in your scripts. I also used "/opt/bwmon" for your script location.

As far as I figured These things are different in OpenWRT:

  1. OpenWRT no longer uses "nvram" (it's not even included), instead it uses "uci".
  2. There is no need for "jffs" on OpenWRT since it leaves few megabytes of free space.

Things I changed in your script (or added) in order to make it compatible with OpenWRT:

  1. in "bwmon.sh" line 27: WAN_IFACE=$(nvram get wan_ifname) changed to WAN_IFACE=$(uci get network.wan.ifname)
  2. in "start.sh" line 30: ln -s /tmp/dnsmasq.conf /tmp/www/dnsmasq-conf.js changed to ln -s /etc/dnsmasq.conf /tmp/www/dnsmasq-conf.js
  3. in "start.sh" line 31: ln -s /tmp/dnsmasq.leases /tmp/www/dnsmasq-leases.js changed to ln -s /tmp/dhcp.leases /tmp/www/dnsmasq-leases.js
  4. Since there is no /tmp/www folder, I created one: mkdir /tmp/www
  5. OpenWRT uses a very lighweight http server named uhttpd. and its public www folder is located at /www/. So I linked your created folder to there: ln -s /tmp/www /www/bwmon
  6. In order to make things a bit easier, I symlinked bwmon.html to index.html (this one is optional) ln -s /tmp/www/bwmon.html /tmp/www/index.html

at the end, I was able to successfully open stats in http://[router address]/bwmon

Do you think it is possible to merge these with your script? you can use "nvram" and "uci" to detect if it is DD-WRT or OpenWRT.

vortex-5 commented 8 years ago

So I'm reluctant to add official support for OpenWRT because I lack the hardware to test it on. Nor can I write instructions in the Readme.md to give OpenWRT users a proper guide as to how to install it since I lack the hardware to test it on and keep up with changes.

It is possible to incorporate the changes you have stated however they will probably not be tested when new changes are made so it will be up to the community to provide fixes for OpenWRT support.

yes most likely to check for the existance of the commands I'll be doing a which nvram and which uci to detect the existance of each they are non null when the command is present.

  1. This is fine and can be done relatively easily I don't see a problem incorporating this.
  2. a fallback can be used when the /tmp/dnsmasq.leases is not found
  3. same as 2 we can change the place.
  4. I didn't check for this since it's always there by default on DDWRT but I can create this if it doesn't exist since /tmp is on ramdisk there's no point to do a cleanup so the folder can live on after the script is stopped.
  5. Most likely this needs a nvram / uci detection since DDWRT versions don't have a /www directory.
  6. This most likely won't be done the reason we do not add a index.html is to allow users to have another page as default if they wish so true this is an optional step and won't be in the actual script install routines.

DDWRT also uses uhttpd however it uses that to run it's native configuration UI so it's pretty locked down configuration wise.

Again unless I have another maintainer testing all the time OpenWRT support will probably remain in beta the whole time since I lack the hardware to test it on and derive a fix.

That said however I don't see a problem in having unofficial support for OpenWRT with the changes you have described so I should be able to merge those changes. I've had about 3 requests to show the speeds in MB/s and Mbps toggle-able so that may be implemented first before this. FYI

euphoria360 commented 8 years ago

So glad to see your kind reply. Thanks. I will look forward to your merge. Also as a user of your script, as long as im on openwrt, ill try to inform you of changes needed.

akacross commented 8 years ago

@euphoria360 Yeah i gonna give this a try, do you have steam in case i have issues? lol

shadww commented 8 years ago

Nicely done. Will keep a close eye on this one.

vortex-5 commented 8 years ago

Debating right now if a fork would be better than an integrated one solution fits all. I'd imagine there are other differences as well in OpenWRT does anyone know about this area?

shadww commented 8 years ago

Unfortunately I am not that well aware of it. On the other hand, you might be able to emulate openwrt on VM, https://wiki.openwrt.org/doc/howto/virtualbox http://ediy.com.my/blog/item/31-openwrt-in-virtualbox

akacross commented 8 years ago

I can vouch for the Virtual Machine method, from https://wiki.openwrt.org/doc/howto/virtualbox, i made windows 7 VM and OpenWRT in another VM, they were both in an Internal Network, so i could access everything via 192.168.1.1 and SHH etc..

But the current issue i have is when i run this with euphoria360's changes, seems as if my DHCP leases break on restart and i have to either wait for them to renew or manually reset the machines.

EDIT: it appears that the DHCP Leases Issue is just a bug in 15.05.1 https://dev.openwrt.org/ticket/20853

vortex-5 commented 7 years ago

No plans to implement this in the near future so I'm closing this issue.