Donec Facilisis Lacinia

That will only remove the symbolic link, wouldn’t you also need to remove /mnt/HD/HD_b2/Public as well ? I suspect that link in /shares will come back after a reboot of the unit.

An original alternative to /etc/init.d with some USB flash drive sauce.
It doesn’t touch the internal flash so it’s arguably better than the cron mods! :wink:

FYI

I looked at using this a while ago to try and get start up scripts to work and found that if I tried using it, there were some other key functions of the NAS that did not start right. I can’t remember the specifics but found it was not going to meet my needs as a result. So you might find if you go down the fun_plug route that some other key scripts and services are not started as a result.

I think you are doing great work on de-tangling the mess WD have left. Unfortunately life is getting in the way for me at the moment and not got the time I was hoping to have to contribute. :frowning:

Have you ever considered working on Github as an open source project?

did you by pass “chk_image”? Is there any side affects?

You are right about WD’s ownership.

I did the same once when I was experimenting, but reverted it to the original.

@dswv42,

Docker used to be WDs tool of choice for installing custom apps onto these NAS units. Then they came up with the new Framework which they released and is now driven from the “Apps” tab in the Dashboard. I personally have docker used on my NAS and run SoftEther VPN in a docker container. Definitely great to have it on there although the docker version installed is getting a bit dated now.

Cheers,

JediNite

Check out http://web.archive.org/web/20160706224806/http://developer.mycloud.com/MCDSDKindex.html

Here’s an strace (installed with entware) of fan_control in debug mode:

https://pastebin.com/By8jGJrt

It’s a loop with a countdown of 60 seconds and then prints temperature and fan info.
Might contain something of interest…

EDIT with more info:

fan_control 0 d

[fan_control.c:424] standby_flag=0
[fan_control.c:511] HD1 temperature 30
[fan_control.c:511] HD2 temperature 31
[fan_control.c:511] HD3 temperature 30
[fan_control.c:511] HD4 temperature 31
[fan_control.c:1939] current board temperature is 30
[fan_control.c:1940] current hdd temperature is 31
[fan_control.c:656] temperature=31
[fan_control.c:1438] current fan_rpm=510
[fan_control.c:776] uP cmd:up_send_ctl temperature 31 87
[fan_control.c:887] calculate temperature=31
[fan_control.c:890] WD daemon send alert
[fan_control.c:268] sleep duration is 60

Dig deeper to get any info on fan_rpm

strace fan_control -g 4
...
connect(6, {sa_family=AF_UNIX, sun_path="/var/run/wdtms.sock"}, 21) = 0
...
sendmsg(6, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="<?xml version=\"1.0\" encoding=\"ut"..., iov_len=202}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 202
...
recvmsg(6, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="<?xml version=\"1.0\" encoding=\"ut"..., iov_len=2048}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 253
...

This shows communication with the wdtms socket.

strace -e read=6 -e write=6 fan_control -g 4
...
SEND 
    <?xml version="1.0" encoding="utf-8"?>.
     <data_message>
       <internal_info>
         <version_int>1</version_int>
         <type_string>get_fan_rpm</type_string>
       </internal_info>
       <data>
         <index_int>0</index_int>
       </data>
     </data_message>
RECV
    <?xml version="1.0" encoding="utf-8"?>.
    <data_message>
      <internal_info>
        <version_int>1</version_int>
        <type_string>get_fan_rpm_response</type_string>
      </internal_info>
      <data>
        <fan_rpm_int>510</fan_rpm_int>
        <return_code_int>0</return_code_int>
      </data>
    </data_message>

Sure, have a look at the source code.
LINK

The install.sh script contains all you need.
When you have entware, just use

opkg install strace

A lot of info comes from running wdtms like this:

export LD_LIBRARY_PATH=/opt/wd/lib:/opt/wd/lib/boost
pkill wdtms
strace -f /opt/bin/wdtms -config=/etc/wd/BNFA-thermal.xml

I’m still going through, but you see commands passing by such as

i2cget -y 8 0x4c 0x10

This is polling the fractional byte of the temperature sensor… seems a bit useless to me but whatever.
More interesting is address 0x00 for the internal sensor and address 0x01 / 0x23 for the external sensors…

Digging deeper into the wdtms.

<?xml version="1.0" encoding="utf-8"?>.
<data_message>
  <internal_info>
    <version_int>1</version_int>
    <type_string>HWSetFanSpeed</type_string>
  </internal_info>
  <data>
    <handle_string>0x1eb92a0<handle_string>
    <fan_int>0</fan_int>
    <type_int>1</type_int>
    <speed_int>30</speed_int>
  </data>
</data_message>

And the response

<?xml version="1.0" encoding="utf-8"?>.
<data_message>
  <internal_info>
    <version_int>1</version_int>
    <type_string>HWSetFanSpeed_response</type_string>
  </internal_info>
  <data>
    <error_code_int>0</error_code_int>
    <HWStatus_int>0</HWStatus_int>
    <data_int>0</data_int>
  </data>
</data_message>

And using strace on wdhws gives a lot more info.

Fan control probably works over the serial bus at /dev/ttyS2, with params B9600 -opost -isig -icanon -echo.
Set the fan speed to 30 RPM as follows

{iov_base="FAN=1E\r", iov_len=7}

/opt/bin/opkg if you don’t update your path :slight_smile:

In the init.sh I copy some handy aliases to /etc/profile and I set the path as follows.

export PATH=/opt/bin:/opt/sbin:$PATH

I didn’t apply this to the interactive shell only yet… it’s on my TODO list :slight_smile:

I got a lot of info with this command:

strace -f -e read=7 -e write=7 -e read=3 -e write=3 -e write 15 -o wdhws_out /opt/wd/bin/wdhws -config=/etc/wd/sprite-wdhw.xml

Use the -f flag to catch all the forks, -o to write to a file and -e to capture all file access for the corresponding pointers.
I’ll now try to make a python replacement for these services that can be used on plain debian.

With strace, you can save the output to a file.
You’ll see that sockets are opened from wdtms to the wdhws.socket. This uses a file pointer (a number).
To get all data on that socket, capture the writes and the reads on that number.
Then I cleaned up the hex data to get the xml text.

A sample of the output when you listen to file pointer 3

first it reads a lot of library headers, until
...
open("/var/run/wdhws.pid", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
...
4147  recvmsg(3,  <unfinished ...>                                                                                                                
4151  <... futex resumed> )             = 0                                                                                                       
4147  <... recvmsg resumed> {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="<?xml version=\"1.0\" encoding=\"ut"..., iov_len=2048}], msg_iovlen
 * 217 bytes in buffer 0                                                                                                                          
 | 00000  3c 3f 78 6d 6c 20 76 65  72 73 69 6f 6e 3d 22 31  <?xml version="1 |                                                                    
 | 00010  2e 30 22 20 65 6e 63 6f  64 69 6e 67 3d 22 75 74  .0" encoding="ut |                                                                    
 | 00020  66 2d 38 22 3f 3e 0a 3c  64 61 74 61 5f 6d 65 73  f-8"?>.<data_mes |                                                                    
 | 00030  73 61 67 65 3e 3c 69 6e  74 65 72 6e 61 6c 5f 69  sage><internal_i |                                                                    
 | 00040  6e 66 6f 3e 3c 76 65 72  73 69 6f 6e 5f 69 6e 74  nfo><version_int |                                                                    
 | 00050  3e 31 3c 2f 76 65 72 73  69 6f 6e 5f 69 6e 74 3e  >1</version_int> |                                                                    
 | 00060  3c 74 79 70 65 5f 73 74  72 69 6e 67 3e 48 57 47  <type_string>HWG |                                                                    
 | 00070  65 74 53 74 61 74 75 73  3c 2f 74 79 70 65 5f 73  etStatus</type_s |                                                                    
 | 00080  74 72 69 6e 67 3e 3c 2f  69 6e 74 65 72 6e 61 6c  tring></internal |                                                                    
 | 00090  5f 69 6e 66 6f 3e 3c 64  61 74 61 3e 3c 68 61 6e  _info><data><han |                                                                    
 | 000a0  64 6c 65 5f 73 74 72 69  6e 67 3e 30 78 62 31 38  dle_string>0xb18 |                                                                    
 | 000b0  38 32 30 3c 2f 68 61 6e  64 6c 65 5f 73 74 72 69  820</handle_stri |                                                                    
 | 000c0  6e 67 3e 3c 2f 64 61 74  61 3e 3c 2f 64 61 74 61  ng></data></data |                                                                    
 | 000d0  5f 6d 65 73 73 61 67 65  3e                       _message>        |                                                                    
4151  futex(0x7f8430002620, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>

It’s my first experience with strace as well :slight_smile:
I suggest you start with strace on fan_control as follows

strace fan_control

It shows you can add args

strace fan_control -g 4

Still not enough info… it spawns extra processes and we’re not logging them yet.

strace -f fan_control -g 4

At the end of the output, you see the std output, fan rpm = 510.
A few lines earlier, you see that /tmp/msg_info.txt is opened and it writes some data.
And I see a message to the LCD screen:

msgsnd(0, {2672, "\f\372\4\203\0\006510rpm\373"}, 13, 0)

It helps to log to a file, use -o.
With vi you can jump fast to keywords. Use / and type ‘open’, then press n / N to jump between them.

When you’ve done this rather easy debugging, you can tackle wdtms and wdhws…

Good luck :slight_smile:

Entware is good. I’ve been using it for a while to run some python based apps like Sickrage…

The nice thing about entware is that it’s native and can be really powerful. But the limitations in some packages will cause frustration … Some projects can be really hard to setup, e.g. virtualenvs with python and openssl. Some tools are broken, e.g. the e2fsprogs.
Native debian would be a blessing.