Starting your own init script in Ericsson W25

Update: In the SW version 1.3 you can simply put your init scripts to /rw/etc/init.d/rc.local and do not need this complicated method.


If we want our extra changes remain after restarting the Ericsson W25 we need to reapply them after restarting the router again. Normally this is done by a custom init script which makes the necessary changes for us.

In the W25 we need to do some special tricks to be able to start our own script as most of the /etc directory and the complete /etc/init.d is in a read only filesystem. However we are clever guys and we notice that the /etc/ppp/peers directory is in the rw filesystem and we know that for the pppd we can give a dialer program as a parameter. Let's use this for starting our own init script, when the unit first tries to connect to the 3G network.

We have to change the following line in /etc/ppp/peers/3g:

connect "/usr/sbin/chat -V -f /etc/ppp/chat/3g-connect"

to the following:

connect "/root/lchat -V -f /etc/ppp/chat/3g-connect"

This will call /root/lchat (our secret agent) instead of the standard chat program. After this we have to create the /root/lchat script, which is actually a wrapper for /usr/sbin/chat, but on the first run, it starts the /root/custominit script as well.

/root/lchat should look like this:

#!/bin/sh
if [ ! -e /var/tmp/customboot.tmp ] ; then
touch /var/tmp/customboot.tmp ;
/root/custominit > /dev/null
fi;
/usr/sbin/chat $*

The /var/tmp directory is cleared on every reboot, so this way we can assure that the init script is runing once and only once.

We are done with this, next time we will continue with setting up Dynamic DNS for our box.

Comments

Anonymous said…
Hi,
I've now used this approach to get around a fault in ip_conntrack in the current firmware. Connections are not being dropped correctly so the conntrack table fills then refuses new connections. You can monitor the table with
st nat
even if NAT is not in use.
I put:
sysctl -w net.ipv4.netfilter.ip_conntrack_max=8192
sysctl -w net.ipv4.netfilter.ip_conntrack_tcp_timeout_established=3600
in my custominit so entries are timed out after 1 hour of no use, and the table is bigger.

Thanks!
Unknown said…
Hello again..
This doesn't work on W35 running firmware R12C. /etc/ppp/peers/3g is now in an read-only file system.
Any ideas?
Lacó said…
In the newer versions of the FW you don't need this trick, you can simply add your extra commands to /etc/init.d/rc.local .
Unknown said…
Greetings All, I was wondering if anyone know the root login for the w35, if not maybe the w25. I would like to make use of the underlying linux OS on my router.
Unknown said…
Greetings All, Sorry I am late to the party anyone have the root logins for the W35 (or maybe the W25 will work for me). I wish to make use of the underlying linux OS, as I no longer use this for 3G at the moment.

Popular posts from this blog

Setting ethernet interface speed in /etc/network/interfaces