Mr Johnson’s listing of the code that writes a boot-cmds.sh had a long sleep in it. I don’t know what I’m talking about here but I wonder if that difference between his code and my boot-cmds.sh might be significant somehow, as mine just runs straight through with no delays. Wild speculation: if something else running in parallel were somehow changing the state of the system quite late, but my actions took place too early, before certain precursor conditions are met, then that would be an explanation. I know that’s woolly and half-baked.
Yes, you are quite correct, some delay will be necessary, the boot-commands.sh script is called from /etc/profile before the main zyxel program that sets everything up.
wl0: Broadcom BCM435f 802.11 Wireless Controller 6.30.102.7.cpe4.12L06B.0
dgasp: kerSysRegisterDyingGaspHandler: wl0 registered
p8021ag: p8021ag_init entry
Broadcom 802.1Q VLAN Interface, v0.1
/data/./boot-cmds.sh: line 3: can't create /etc/resolv.conf: nonexistent directory
/data/./boot-cmds.sh: line 4: can't create /etc/resolv.conf: nonexistent directory
/data/./boot-cmds.sh: line 5: can't create /etc/resolv.conf: nonexistent directory
/data/./boot-cmds.sh: line 6: can't create /etc/resolv.conf: nonexistent directory
route: SIOCADDRT: No such device
===== Release Version 4.12L.06B (build timestamp 190611_1842) =====
You could just add the 45 second sleep previously included (I arrived at that as a rough 'good enough' value to have the modem in a state to accept xdslctl commands):
...
echo '#!/bin/sh' >/data/boot-cmds.sh
echo '' >>/data/boot-cmds.sh
echo 'sleep 45' >>/data/boot-cmds.sh
echo '' >>/data/boot-cmds.sh
echo 'echo domain torr-gorm.cecilward.com >/etc/resolv.conf' >>/data/boot-cmds.sh
...
Or maybe get a bit more complicated and test for existence of the file that /etc/resolv.conf is symlinked to:
...
echo '#!/bin/sh' >/data/boot-cmds.sh
echo '' >>/data/boot-cmds.sh
echo 'while [ ! -f /var/fyi/sys/dns ];' >>/data/boot-cmds.sh
echo 'do' >>/data/boot-cmds.sh
echo 'sleep 1' >>/data/boot-cmds.sh
echo 'done' >>/data/boot-cmds.sh
echo '' >>/data/boot-cmds.sh
echo 'echo domain torr-gorm.cecilward.com >/etc/resolv.conf' >>/data/boot-cmds.sh
...
And the the interface br0:
...
echo '' >>/data/boot-cmds.sh
echo 'while [ ! -f /sys/devices/virtual/net/br0/address ];' >>/data/boot-cmds.sh
echo 'do' >>/data/boot-cmds.sh
echo 'sleep 1' >>/data/boot-cmds.sh
echo 'done' >>/data/boot-cmds.sh
echo '' >>/data/boot-cmds.sh
echo "route add default gw $FBIPv4 br0" >>/data/boot-cmds.sh
...
But doing things like this is pretty hard to debug without a serial terminal to watch the boot process. I guess I should find a candidate for the best file or program running to signify a complete boot.
The init system as it is is busybox reading /etc/inittab, running /etc/init.d/rcS which mounts /proc, fstab etc, then a login shell on /dev/console which invokes /etc/profile, which is where all the zyxel stuff is loaded the last of which is
smd. This zyxel daemon does basically everything, binds to all the ports and launches sshd httpd etc as and when, sets up the switch with vlans and the bridge, populates all the symlinked files in ram like /etc/passwd, it runs and stays attached to the first login shell from /etc/profile.
I put the running of /data/boot-cmds.sh and the starting of the stats-server in /etc/profile before
smd as that has to be last. So we need to wait until smd has done its stuff before doing things like setting the default route and updating config files that it creates.