What's new

Using Entware\Optware on stock firmware

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

ryzhov_al

Very Senior Member
It's related to any modern ASUS router with USB port: RT-N10U, RT-N13U, RT-N15U, RT-N16, RT-N56U, RT-N65U, RT-N66U, RT-AC66U. All those routers uses a stock firmware partially based on TomatoUSB code, so we may use a custom start/stop scripts to ignite external services from USB drive!

1. Start/Stop scripts.
There is a two script, which can be saved right into NVRAM:
  • one will be executed right after mounting every partition on boot,
  • another will be executed right before dismounting partition before reboot.
Take a look:
$ cat ./nvram.sh
#!/bin/sh

cat << EOF > /tmp/script_usbmount.tmp
if [ \$1 = "/tmp/mnt/MYPART" ]
then
ln -sf \$1 /tmp/opt
/opt/etc/init.d/rc.unslung start
fi
EOF
nvram set script_usbmount="`cat /tmp/script_usbmount.tmp`"

cat << EOF > /tmp/script_usbumount.tmp
if [ \$1 = "/tmp/mnt/MYPART" ]
then
/opt/etc/init.d/rc.unslung stop
fi
EOF
nvram set script_usbumount="`cat /tmp/script_usbumount.tmp`"

nvram commit
If you'll run it once a two scripts will be saved: one — to start Entware/Optware services form USB HDD partition labeled MYPART, second — to shutdown it gracefully. Both scripts may survive reboot. All you have to do is to choose a partition to store Entware/Optware content and format it with MYPART label, for example:
$ mkfs.ext3 -j -L MYPART /dev/sda1
Please note: a stock firmware limits execution time for this script up to 3 seconds. If you need more time, I can show how to do it later.

2. Post-firewall rules.
Some services like a torrent client or SSH server needs an open port, so we need a script that will be executed after every applying of current firewall rules (e.g. in case of internet reconnection). A stock firmware got some limitation here but there is a way to open a port range:
$ nvram set apps_dl_share=1
$ nvram set apps_dl_share_port_from=51413
$ nvram set apps_dl_share_port_to=51414
$ nvram commit
It will be equal to following firewall rules:
iptables -I INPUT -p udp --dport 6881 -j ACCEPT
iptables -I INPUT -p udp --dport 51413:51414 -j ACCEPT
iptables -I INPUT -p tcp --dport 51413:51414 -j ACCEPT
6881 UPD port will be opened in any case along with desired port range.

3. USB hotplug script.
When firmware can't recognize an attached USB device, it may run a custom script to handle a new device. This my be useful to those who attaches a USB printer. I did not test this feature, but it looks good. Just save your usbplug-script to script_usbhotplug NVRAM variable, just like in #1.
 
Last edited:
Problems with RT-N10U B1

It's related to any modern ASUS router with USB port: RT-N10U,...
[*]one will be executed right after mounting every partition on boot,

I have RT-N10U B1, with latest firmware based on asuswrt - 3.0.0.4.260
Its not executed for every partition, only for usb. Also, I was unable to turn on jffs:
nvram set jffs2_on=1
nvram set jffs2_format=1
nvram commit
Rebooted it several times and still no jffs in /etc/mtab
Also, there are no /etc/init.d scripts :(

How its possible to make startup/shutdown scripts for boot, mount everything(but not usb), wan up, wan down, lan up?
 
There is no JFFS support in the original Asus firmware.
 
There is no JFFS support in the original Asus firmware.

Ok Merlin I understand this, but is there any way to turn on JFFS on Asus firmware :confused:. Right now I have 2 router, first is RT-N66U and second is DSL-N55U. On 66u everything works just fine @ 3.0.0.4.246.20 but right now I have to use some scripts on DSL so i'm desperately looking for a method to turn on JFFS.
Ps. On DLS optware wors great (transmission + nano).
Right now looking for JFFS and cron for DLS... please help. :)

PSPS.
ryzhov_al said:
iptables -I INPUT -p udp --dport 6881 -j ACCEPT
iptables -I INPUT -p udp --dport 51413:51414 -j ACCEPT
iptables -I INPUT -p tcp --dport 51413:51414 -j ACCEPT
Works great... thx.
 
Ok Merlin I understand this, but is there any way to turn on JFFS on Asus firmware :confused:.
darius456, leonid.b, JFFS support is switched off at compile time. There is nothing we can do with stock firmware.

Right now looking for JFFS and cron for DLS... please help. :)
AFAIK, crond is enabled by default in any 3.0.x.x firmware, take a look at
/usr/sbin/crond. Please note, it's not a Vixie's cron, remove username field from crontab file.

Works great... thx.
Thanks.
 
Crond is compiled in Asus's firmware, but it doesn't get launched at boot time (unless they changed that at some point).
 
AFAIK, crond is enabled by default in any 3.0.x.x firmware, take a look at
/usr/sbin/crond. Please note, it's not a Vixie's cron, remove username field from crontab file.

Should I put my cron tasks in /var/spool/cron/crontabs/ like in RT-N66U??
If so, what will happen if i reboot router... all my cron task will disappear. Where i can put some script to add cron jobs after reboot?

Crond is compiled in Asus's firmware, but it doesn't get launched at boot time (unless they changed that at some point).
Ooo, so how can I turn it on? Simply crond on telnet or something more sophisticated?
 
Ps. On DLS optware wors great (transmission + nano).
Should I put my cron tasks in /var/spool/cron/crontabs/ like in RT-N66U??
If so, what will happen if i reboot router... all my cron task will disappear. Where i can put some script to add cron jobs after reboot?
If you are using Optware, why don't you run crond with /opt/etc/init.d start script?

You may place custom crontab file to /var/spool/cron/crontabs/ in start script.
 
If you are using Optware, why don't you run crond with /opt/etc/init.d start script?

You may place custom crontab file to /var/spool/cron/crontabs/ in start script.

I'm quite newbie on optware/entware and all that stuff. So could you explain. If i put any script on init.d it will be executed on reboot? Any name of sh file or like in rt-n66u jffs/script i should use some specific file name?
 
While you are using Optware or Entware, /opt/etc/init.d is a place for start/stop scripts. This folder is not related to firmware directly, but it's a common place to ignite any external service.

A start/stop scripts named as S10samba, S15vsftpd, S50downloadmaster and so on. A two digits number after "S" determines the start/stop order. In example:
  • start sequence: S10samba, S15vsftpd, S50downloadmaster,
  • stop sequence: S50downloadmaster, S15vsftpd, S10samba.
 
Last edited:
Before trying entware, i would like to have a look at the contents of the repository, but I haven't been able to find that link. Can you please provide it?

A second question, would the entware work after a firmware upgrade as downloadmaster does (ok, with mixed results...)?

Thanks

AndreaS
 
Is it possible to add a buildroot/gcc package to entware (also automake, autoconf, etc)?

Because with optware you have that and i compile small things on the router itself (is faster than crosscompiling and trasnferring everytime)!
 
Is it possible to add a buildroot/gcc package to entware (also automake, autoconf, etc)?
In fact, Entware is OpenWRT, so no native compilation is provided. Not for now, not in future.

A modern gcc eats too much memory for running on embedded devices. We may port it without any optimisations (-O2, -O3, -Os), but it will be useless.
 
Well that really sucks for me, because i was compiling oscam package (ipk) for the WL500gP Router on itself and with the normale optware from merlin-asuswrt, it is possible to compile it (as it has buildroot).

But merlin said, that you cannot have entware and optware at the same time or?
Or is it possible to have both at same time (with some tweaks and tricks - I have more than basic skills in linux and I am a software developer ;))?
 
Two more questions:
- needed dependencies are automatically installed?
- is it available a document describing the path of the installed files?

Thanks for the answers to my previous post.

AndreaS
 
Well that really sucks for me, because i was compiling oscam package (ipk) for the WL500gP Router on itself and with the normale optware from merlin-asuswrt, it is possible to compile it (as it has buildroot).

But merlin said, that you cannot have entware and optware at the same time or?
Or is it possible to have both at same time (with some tweaks and tricks - I have more than basic skills in linux and I am a software developer ;))?

You would probably need to install Optware in a separate directory, and have a script at boot time that takes care of mounting either the Entware repo or the Optware repo on top of /opt.
 
That could work, but i would also like to run php-5.4 for OwnCloud and that is just at entware available (as optware has just php 5.2 and 5.3 is needed for OwnCloud).
So my main problem is that i have to compile php >5.3 for optware...

So either i make a /optEntware and /optOptware and decide on boot, which i mount over /opt or i get >php5.3 on optware (shouldnt be to hard, as i can store a little key-value pair in the nvram for that).

Or: Is there anywhere a cross-compile HowTO for the asuswrt image? As i have some experiences with cross compiling, i know that i need a toolchain for the router, but dunno which one is supported for optware/merlin-asuswrt.
 

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top