A reader named Aaron figured out that the Bitdefender subsystem (when was that added? I don’t think I remember it being there when I first began poking around in my Orbi) exists on a read-write partition and, thus, can be co-opted to give us a method of customizing the Orbi that doesn’t use the clumsy hack I’ve been using up until now.

The Bitdefender subsystem resides in /mnt/bitdefender. Following the example Aaron gave me, let’s log in to the Orbi via the telnet interface, and then

root@RBR50: cd /mnt/bitdefender/bin root@RBR50:~/mnt/bitdefender/patches/base/bin# mv bdcrashd bdcrashd.bin root@RBR50:~/mnt/bitdefender/patches/base/bin# vi bdcrashd

Copy the following into the file you’re editing:

#!/bin/sh /tmp/mnt/bitdefender/bin/bdcrashd.bin $@ & until [ -e /mnt/circle/localinit/00-null ]; do sleep 2 done find /mnt/circle/localinit/ -type f -exec sh -c "( {} & )" \;

…and make it executable:

root@RBR50:~/mnt/bitdefender/patches/base/bin# chmod a+x bdcrashd

What’s happening:

The script is being called in place of ‘bcrashd’ (whatever that does) …so we gotta run the original ‘bcrashd’, which we had renamed to bcrashd.bin earlier (and we fork it into the background with the ‘&’ ) The stuff I’m going to construct, I’m going to put in /mnt/circle. Through trial-and-error, it seems like /mnt/circle isn’t mounted when the startup scripts start bcrashd. So, we have to wait until we’re sure that a program we know is supposed to be there becomes visible. That’s the until-done loop. We call the ‘find’ utility to identify all of the scripts in the /mnt/circle/localinit directory, and execute them, forking them into the background so that a long-running script won’t hang the whole shebang. Note that making the script executable with chmod is, in fact, superfluous, since everything on the read-write partition will be be given permissions of -rwxrwxrwt next reboot (side note: you’re killing me NetGear).

Ok, let’s flip over to /mnt/circle.

root@RBR50:~/mnt/bitdefender/patches/base/bin# cd /mnt/circle/ root@RBR50:~/mnt/circle# mkdir localinit/ root@RBR50:~/mnt/circle# cd localinit/ root@RBR50:~/mnt/circle/localinit# vi 00-null

’00-null’ will be a placeholder file:

#!/bin/sh exit

Running telnet is better than nothing, but not that much better. Let’s install a ssh server.

Dropbear is a ssh server and client optimized for small systems. We have a conveniently optimized prebuilt package for our Orbi at https://github.com/whiteskin/openwrt-imagebuilder-ipq806x/raw/master/packages/base/dropbear_2015.67-1_ipq806x.ipk.

root@RBR50:~/mnt/circle/localinit# cd /mnt/circle root@RBR50:~/mnt/circle# mkdir dropbear root@RBR50:~/mnt/circle# cd dropbear root@RBR50:~/mnt/circle/dropbear# wget --no-check-certificate https://github.com/whiteskin/openwrt-imagebuilder-ipq806x/raw/master/packages/base/dropbear_2015.67-1_ipq806x.ipk root@RBR50:~/mnt/circle/dropbear# tar xvfz dropbear_2015.67-1_ipq806x.ipk root@RBR50:~/mnt/circle/dropbear# tar xvfz data.tar.gz root@RBR50:~/mnt/circle/dropbear# rm data.tar.gz control.tar.gz debian-binary

Change directory back to /mnt/circle/localinit and create the file start_dropbear.sh

#!/bin/sh DEVICE=br0 COUNT=0 until ( ethtool br0 | grep yes > /dev/null ); do COUNT=$((COUNT+1)) if ( [ $COUNT -gt 10 ] ); then echo $DEVICE isn\'t becoming active: exiting fi sleep 5 COUNT=$((COUNT+1)) done if [ -d /etc/dropbear ]; then echo /etc/dropbear already exists else cp -a /mnt/circle/dropbear/etc/* /etc fi ln -s /mnt/circle/dropbear/usr/sbin/dropbear /usr/sbin/dropbear ln -s /mnt/circle/dropbear/usr/sbin/dropbear /usr/bin/ssh #rm /etc/banner if ( pidof dropbear > /dev/null ); then echo dropbear is running else /usr/sbin/dropbear fi

This should work. When you reboot the Orbi, you should be able to ssh in. You’ll need to be user root instead of admin (e.g. ‘ssh root@192.168.1.1’).

If you want to be logging in as a different user, you can create one using ‘adduser’, see what was added in /etc/passwd and /etc/shadow, and then putting in a stanza in the above script that inserts the appropriate lines in the appropriate files:

if ( grep USER /etc/passwd > /dev/null ); then echo USERalready in /etc/passwd else echo USER:x:501:501:Linux User,,,:/:/bin/ash >> /etc/passwd fi if ( grep USER /etc/shadow > /dev/null ); then echo USER already in /etc/shadow else echo 'USER:/:17478:0:99999:7:::' >> /etc/shadow fi

Replace the goofed up lines with whatever you created in the files with adduser.

This has worked for me at least once, so…time to ship it, right?

Ta dah! Thanks to Aaron’s bright brilliant idea, we now have a way to make the Orbi just work the way we want it to, as if it was a real computer system.

A word of caution, though: Since we will now have custom code running automatically, we’re starting to fly without a safety net. When we get to the point where we might be running iptables code at startup, we could completely bork the device. Nothing a hard reset won’t fix…I’d hope.

Quick update:

Don’t like the default banner when you log in? Change it with a script in /mnt/circle/localinit. Here’s mine, called banner.sh:

#!/bin/sh cat <<EOF > /etc/banner Orbi(s) non sufficit EOF

Actually, mine has a cool ASCII art lightning bolt, but WordPress seems to want to nuke spaces and I’m not particularly interested in trying to figure out that issue right now.

Next up: getting the Orbi to resolve names on your network.