INSTALL ENTWARE ON WD MY CLOUD HOME (SSH ACCESS, NFS SERVER, OPKG install packages)

Nice bit of smart code there @Western1. You’ve sneaked up on it with a scalpel and made a neat incision. I strode up to it with a bloody great hammer and bludgeoned it into submission. :innocent: I’m never going to get time to make a proper job of documenting it, so I’ll just pass on some notes here.

Firstly, the MCH uses Android which is designed for phones and tablets, not NAS. It’s lightweight and robust and no doubt WD chose it over a Debian distro to maximise performance and make it hard to hack. Android ‘unpacks’ itself on boot, so some startup files you can’t get at, unless you hack the image rather than the live system. Too much trouble!

I read through the startup rc files in the root directory /init*.rc and this was most instructive, although as stated previously, I knew I wasn’t going to mod them. My goal was to stop Android in its tracks and I found that way down the end of the startup sequence it starts up netatalk. This is an Apple protocol to allow IOS devices to connect, and I have none of those. So, I modded /system/bin/netatalk_daemon.sh to subvert Android and then exit. Users of netatalk can probably use the same technique but just remove the exit 0 from the following script. If netatalk fails for any reason it won’t get restarted, though.

The script does this:

  • stops a whole layer of processes that make Android special. Bizarrely, the simple command “stop” does this. For example, there’s one process called SurfaceFlinger which manages touchscreen displays. It has no place I can think of on a NAS!
  • Brings up the ethernet interface and grabs a DHCP address
  • Stops lots of processes I don’t need at the service management level (ie. doesn’t just kill the process but stops it from being started again by the service manager). e.g.
    ** otaclient is an over-the-air updater which would probably overwrite my changes so that had to go!
    ** appmgr starts the native samba so as it’s cut I can use the ENTWARE one instead
    ** restsdk-server communicates with the WD mothership. I don’t want the WD MyCloud functionality
  • Then I start ENTWARE, and because I’ve installed their samba, ntp, cron, dropbear and whatever else I choose to install later, it becomes more like a Debian system.
  • Final thing is to stop the netatalk service management so it doesn’t restart the script.

Paths caused as issue, particularly where ENTWARE startup scripts used busybox commands, so I had to make sure /system/bin was in things like rc.unslung - Something I need to refine a bit when I get chance.

This all gets around the cron issue you describe @Western1 as we are no longer using it to break in.

Here’s the modified /system/bin/netatalk_daemon.sh script:

** EDIT Apr 2020 - commented out the stop of led-server as it’s needed by some system scripts

#! /system/bin/sh

# DO NOT USE THIS SCRIPT UNLESS YOU HAVE A CONSOLE CONNECTED
# AND UNDERSTAND WHAT THE SCRIPT IS ABOUT TO DO TO YOUR NICE
# SHINY MCH. EVEN THEN, THINK HARD ABOUT DOING IT AND IF YOU DECIDE
# TO GO AHEAD DON'T BLAME ME IF IT ALL TURNS TO RATS**T - Kryten

# Hijacked this script to configure system from my own purposes.
# It's called late in the boot process and we don't want appletalk anyway

# Stop the android processes that are only there for phones & tablets

stop

# Bring up the eth0 and get an address

ifconfig eth0 up
dhcpcd eth0

# Stop other android processes I don't need

stop avahi
stop otaclient
stop appmgr
stop installd
#stop led-server
sleep 1
stop restsdk-server
stop media

# Start the ENTWARE environment to make it more like a proper linux system

entware.sh start
sleep 40        
             
# Should now be safe to stop this service so it doesn't repeat
stop netatalk 
exit 0
-----------------------------------------------------------------------------
remainder of original netatalk_daemon.sh

It’s a good idea to watch the startup on the console to see how the startup runs as normal and then kills off all the stuff we don’t need.

2 Likes