Closed lynxthecat closed 3 months ago
@lynxthecat I still need to change the shebang to bash, besides that it seems to work.
@LiveWire1968 does the launcher and suggested lines to post-mount work? I have updated the guidance now to:
"asuswrt")
printf '%s\n' "Launch script on boot with:"
printf '%s\n\n' " echo ${SCRIPT_PREFIX}/launcher.sh >> /jffs/scripts/post-mount"
;;
Regarding the shebang, why isn't: #!/bin/sh
correct? Does Asus Merlin not include /bin/sh?
Regarding the shebang, why isn't:
#!/bin/sh
correct? Does Asus Merlin not include /bin/sh?
It's correct but the busybox version they ship is old and has bugs. You could see one of the bug fixes I made with the set -e; . /etc/os-release; set +e
trickery I had to do.
@lynxthecat rany said its a bug with busybox sh, I thought i saw he had did a change on it, but i cant find it again. echo /jffs/scripts/launcher.sh >> /jffs/scripts/post-mount needs changed to echo /jffs/scripts/cake-autorate/launcher.sh >> /jffs/scripts/post-mount . and launcher.sh needs chmod +x
Regarding the shebang, why isn't:
#!/bin/sh
correct? Does Asus Merlin not include /bin/sh?It's correct but the busybox version they ship is old and has bugs. You could see one of the bug fixes I made with the
set -e; . /etc/os-release; set +e
trickery I had to do.
@rany2 the set -e doesnt seem to work
@LiveWire1968 it's the opposite, should be set +e; . /etc/os-release; set -e
admin@RT-AX86U-D7D0:/tmp/home/root# sh -x setup.sh
Doesnt go farther
@LiveWire1968 replace the .
with source
maybe?
@LiveWire1968 replace the
.
withsource
maybe?
there is no /etc/os-release
I know but it shouldn't be a fatal error, but I presume that you tried to use source
instead and it didn't work either
I know but it shouldn't be a fatal error, but I presume that you tried to use
source
instead and it didn't work either
weird bash works even with the error
yeah it's another busybox sh bug, i guess it might be worth it to just guard that with a test -a
check
I'm curious does AsusWRT-Merlin ship with another sh? Does /usr/bin/env sh ./setup.sh
behave differently?
I'm curious does AsusWRT-Merlin ship with another sh? Does
/usr/bin/env sh ./setup.sh
behave differently?
env sh is still the same busybox, so this doesnt work either, there is no other sh
yeah it's another busybox sh bug, i guess it might be worth it to just guard that with a
test -a
check
@lynxthecat just do that then
test -a
seems to be bash specific.
Perhaps this would work:
33 # Check if OS is OpenWRT or derivative
34 unset ID_LIKE
35
36 [ -f "/etc/os-release" ] && . /etc/os-release
@lynxthecat use -e
instead, some OpenWRT versions have os-release with executable bit set
@LiveWire1968 could you test again and verify all is working (including the revised post-mount guidance)?
@LiveWire1968 could you test again and verify all is working (including the revised post-mount guidance)?
@lynxthecat this seems to work now, the echo looks correct. Launcher.sh still needs to be excutable.
Hopefully works now (we now set executable bit)?
For the record the only reason why the previous PR took time is because I wanted to make a proper entware service for cake-autorate NOT this hack in post-mount
For the record the only reason why the previous PR took time is because I wanted to make a proper entware service for cake-autorate NOT this hack in post-mount
I guess this is the Asus Merlin way though:
https://github.com/RMerl/asuswrt-merlin.ng/wiki/User-scripts
For the record the only reason why the previous PR took time is because I wanted to make a proper entware service for cake-autorate NOT this hack in post-mount
I guess this is the Asus Merlin way though:
https://github.com/RMerl/asuswrt-merlin.ng/wiki/User-scripts
It's not proper though, take a look at https://github.com/RMerl/asuswrt-merlin.ng/blob/master/release/src-rt-5.02axhnd/targets/fs.src/rom/etc/init.d/mount-fs.sh. The issue with our init.d right now is that it's sourcing rc.common, we need to make it work for both or create a different ASUSWRT variant. I can't find another link atm but there is another package that does this properly too..
@RMerl any thoughts on how we are doing things here? It seems that we've got something that pretty much works now in terms of getting cake-autorate to work in Asus Merlin.
By way of a brief introduction, cake-autorate was developed with help from a couple of the cake developers to adjust the bandwidth for cake on the fly based on transfer rate monitoring and latency measurements. It is in a pretty mature state now in that it is very tried and tested on many different connections (data, plots and detailed discussion can be seen on the OpenWrt forum threads - see e.g. here) and it generally just works.
For a quick visual demonstration, see the graphics on this page here:
https://github.com/lynxthecat/cake-autorate/blob/master/ANALYSIS.md
IMO the URL you linked to is meant for trivial one-liner scripts, not cake-autorate :)
IMO the URL you linked to is meant for trivial one-liner scripts, not cake-autorate :) @rany there are some fairly complicated asus-merlin script packages, they all get started out of one of the startup scripts in /jffs/scripts never init.d
there are some fairly complicated asus-merlin script packages, they all get started out of one of the startup scripts in /jffs/scripts never init.d
how would you restart them/handle failure? you need some kind of process monitor at a minimum, it seems shortsighted/too simple to just fork from that file and call it a day but I guess given that this is the norm at AsusWRT-Merlin you could just do this too...
Why not use qos-start? That script gets called whenever QoS is initialized. That means you will be able to have it only configure things if QoS is starting with Cake actually enabled as the scheduler.
Could you elaborate? What does qos-start look like these days?
Could you elaborate? What does
qos-start
look like these days?
It doesn't look like anything. It's a script that a user can create to launch tasks whenever QoS gets initialized.
https://github.com/RMerl/asuswrt-merlin.ng/wiki/User-scripts#qos-start
@lynxthecat it's the same exact thing but the conditions are different, instead of running on post-mount
it runs at qos-start
:)
I was thinking of:
https://www.snbforums.com/threads/cake-test-cake-experiments-for-386-2-beta.71271/#post-674445
But if I'm understanding correctly, then we can give this guidance:
"asuswrt")
printf '%s\n' "Launch script on boot with:"
printf '%s\n\n' " echo ${SCRIPT_PREFIX}/launcher.sh >> /jffs/scripts/qos-start"
;;
@RMerl Personally, I would have preferred a regular service file as I want cake-autorate to be monitored and for cake-autorate to be restartable for when it's updated, etc. It's a bit strange that this is just not encouraged in AsusWRT-Merlin but I guess it's a simplicity vs robustness trade-off. Just forking will always be more straightforward !
I agree with you @rany2, but perhaps this is OK for now and can be revisited later.
@LiveWire1968 / @RMerl have we missed anything else? Hopefully this is good now?
Could you elaborate? What does
qos-start
look like these days?It doesn't look like anything. It's a script that a user can create to launch tasks whenever QoS gets initialized.
https://github.com/RMerl/asuswrt-merlin.ng/wiki/User-scripts#qos-start
It needs entware, why i recommended post-mount
@RMerl Personally, I would have preferred a regular service file as I want cake-autorate to be monitored and for cake-autorate to be restartable for when it's updated, etc. It's a bit strange that this is just not encouraged in AsusWRT-Merlin but I guess it's a simplicity vs robustness trade-off. Just forking will always be more straightforward !
Asuswrt is simply not designed around a SysV init system, the entire operating system is monolithic. Having hooks like these scripts is the only way to interface with it.
@RMerl Personally, I would have preferred a regular service file as I want cake-autorate to be monitored and for cake-autorate to be restartable for when it's updated, etc. It's a bit strange that this is just not encouraged in AsusWRT-Merlin but I guess it's a simplicity vs robustness trade-off. Just forking will always be more straightforward !
Asuswrt is simply not designed around a SysV init system, the entire operating system is monolithic. Having hooks like these scripts is the only way to interface with it.
Oh, I thought that I could adapt my init script to not call rc.common as a workaround to have it work on Asuswrt. I didn't know that this was just not possible. It's a shame.
@LiveWire1968 do the installation instructions for Asus Merlin look OK to you?
@lynxthecat I was testing this again this morning. I cannot get the latest cake-autorate.sh or launcher.sh to start from qos-start or post-mount, cant get any log of it when booting the router.
What is working
echo /jffs/scripts/cake-autorate/launcher.sh >/opt/etc/init.d/S99cake-autorate chmod +x /opt/etc/init.d/S99cake-autorate
Then everything starts up fine....
Permissions issue? Could you maybe come on #asuswrt?
@lynxthecat most likely, read https://github.com/RMerl/asuswrt-merlin.ng/wiki/User-scripts#creating-scripts
So just need to add suggestion to chmod +x at:
@LiveWire1968 would simple chmod +x there fix it?
@lynxthecat they specifically suggest chmod a+rx
most likely because of a default restrictive umask, so he should try that not chmod +x
So just need to add suggestion to chmod +x at:
@LiveWire1968 would simple chmod +x there fix it?
no, i had it set excutable, i put a test in qos-start, its working fine
and fyi, its not working from post-mount either, which is where entware and other scripts startup.. Id guess another environment problem, but i havent figured it out
Did you try the chmod a+rx?
Could you also try adding inside qos-start or post-mount the line:
env > /tmp/env_output.txt
And paste the output from that?
For a certain OpenWrt startup script I needed:
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
admin@RT-AX86U-D7D0:/tmp# cat env_output.txt router=100.64.0.1 subnet=255.192.0.0 USER=root staticroutes=192.168.100.1/32 0.0.0.0 34.120.255.244/32 0.0.0.0 0.0.0.0/0 100.64.0.1 SHLVL=1 LD_LIBRARY_PATH=/lib:/usr/lib:/lib/aarch64 HOME=/ ENV=/etc/profile interface=eth0 dns=1.1.1.1 8.8.8.8 siaddr=10.10.10.10 serverid=100.64.0.1 TERM=vt100 mtu=1500 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/opt/sbin:/opt/bin ip=100.74.88.2 lease=300 mask=10 SHELL=/bin/sh PWD=/tmp/bwdpi opt53=05 TZ=GMT5 TMOUT=0
And you definitely tried chmod a+rx?
Any other thoughts @rany2?
@RMerl I wonder whether you can advise here?
@LiveWire1968 any chance you could test the latest code on this asus-merlin branch and we'll add any necessary remaining fixes?
I think(?) the installation instructions should be something like:
Make sure these are installed: entware; bash; iputils-ping; and fping.
And then run:
And then edit the config file to specify the correct interfaces:
and bandwidths (change according to your connection specifics):
And also enable logging:
And then try running manually:
Does it work?