NAS - Syncthing

Disclaimer added due to request.

**Please note that anytime you SSH into your device you can cause an issue**

With out further ado, the WD My Cloud is running a variant of Debain linux.  Meaning that you can run su commands that may update packages or configurations, and or delete / modify important files.  Nothing that a dd can’t fix however.

With that said.  This guide will not do any of those things, unless you of course choose to downgrade the firmware.  Again not a big deal if you are careful.  This guide is like telling a standalone program to run at boot.

More details:

https://discourse.syncthing.net/t/nas-wd-my-cloud/884/4

This is a simple guide to get syncthing to startup as a service and run at boot:

http://syncthing.net/

Must be on firmware < 4.00??  Maybe not running on latest firmware.

http://www.scramworks.net/hacking-mycloud.html#mc1

Step 1:
I created a share on the My Cloud Shares called Tools
You can set this up via the web page UI. Navigate in the browser to the WD’s ip address.
Enable SSH in settings

Step 2:
First you need to have the ARM7 binary file saved on the WD Drive.
Download file  https://github.com/syncthing/syncthing/releases
Extract the file twice (I used 7zip) you are looking for the file named syncthing
I saved the file to /shares/Tools/ (copy to folder via windows)

Step 3:
Using putty SSH login to WD
user: root
password: welc0me

Step 4:

cd /shares/Tools

chmod +x sycthing./syncthing

Step 5:

./syncthing

Wait for Syncthing to setup.

cd /root/.config/syncthing

Step 6:

nano config.xml

Modify the config file

gui enabled="true" tls="false"
        address 192.168.1.25:8080 address

Or what ever IP you are using to connect to the WD UI.
I have set my device up to be a static IP at 192.168.1.25

Step 7:
Press Ctrl + x
Y to save
And Enter to save the file as named

Step 8:
You will need to move the file to the /etc/usr/local/bin

mv /shares/Tools/syncthing /etc/usr/local/bin

Step 9:

nano /etc/init.d/syncthing

Step 10:
Paste this script into the file : 
https://discourse.syncthing.net/t/keeping-syncthing-running-systemd-regular-etc-init-d/402

#!/bin/sh
### BEGIN INIT INFO
# Provides: syncthing
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Multi-user daemonized version of syncthing.
# Description: Starts the syncthing daemon for all registered users.
### END INIT INFO

# Replace with users you want to run syncthing clients for
syncthing_USERS=""
DAEMON=/usr/local/bin/syncthing

startd() {
  for stuser in $syncthing_USERS; do
    HOMEDIR=$(getent passwd $stuser | awk -F: '{print $6}')
    if [-f $config]; then
      echo "Starting syncthiing for $stuser"
      start-stop-daemon -b -o -c $stuser -S -u $stuser -x $DAEMON
    else
      echo "Couldn't start syncthing for $stuser (no $config found)"
    fi
  done
}

stopd() {
  for stuser in $syncthing_USERS; do
    dbpid=$(pgrep -fu $stuser $DAEMON)
    if [! -z "$dbpid"]; then
      echo "Stopping syncthing for $stuser"
      start-stop-daemon -o -c $stuser -K -u $stuser -x $DAEMON
    fi
  done
}

status() {
  for stuser in $syncthing_USERS; do
    dbpid=$(pgrep -fu $stuser $DAEMON)
    if [-z "$dbpid"]; then
      echo "syncthing for USER $stuser: not running."
    else
      echo "syncthing for USER $stuser: running (pid $dbpid)"
    fi
  done
}

case "$1" in
  start) startd
    ;;
  stop) stopd
    ;;
  restart|reload|force-reload) stopd && startd
    ;;
  status) status
    ;;
  *) echo "Usage: /etc/init.d/syncthing {start|stop|reload|force-reload|restart|status}"
     exit 1
   ;;
esac

exit 0

Step 11:
ctrl + x – to exit
y – to save
enter – confirm file name

Step 12:

nano /etc/init.d/mystartup.sh

Step 13:
Copy and paste like before in the previous step

#! /bin/sh
# /etc/init.d/mystartup.sh
#
 
/etc/init.d/syncthing restart &
 
exit 0

Step 13:
ctrl + x – to exit
y – to save
enter – confirm file name

Step 14:

sudo chmod 755 /etc/init.d/mystartup.sh

Step 15:

sudo chmod 755 /etc/init.d/syncthing

Step 16:

sudo update-rc.d mystartup.sh defaults

Step 17:
I like to use reboot command in terminal, but it has caused a few issues. The better way is to reboot the device via the WD UI.

Hello,

Thanks for sharing this with the Community. 

Make sure to add a disclaimer for future guides, something like this;

Warning to all users, these are not  supported procedures. If you proceed with this guide will be at your own risk

i have two questions:

  • i see that the program looks for file changes every 60 seconds… does this mean that the device never enters sleep mode?

  • if my device has 1tb of data and i add it all to the repository, dos it mean that when i add my tabletpc as a node, to see those files, it actually downloads them all?

thanks.

Not sure if anyone is still interested in this but I managed to get this working on my mycloud 3tb with the v4 firmware.

I am in the process of redoing the installation because I have some minor OCD and I want the install files to go in certain places from default.  

tha’s great!

i have the feeling (it can’t be otherwise) that WD will soon come up with their own synchronization tool for their devices… but in the meantime, it would be nice to fiddle with some other software.

@nicolapizza

I intend on making a thread to document the steps I went through.  The thing is it is using a binary that was compiled for the 64k page alignment. 

I am also looking into creating my own go environment to update syncthing binary.

In a nutshell the information in this thread is still relevant with minor changes I had to discover and make along the way.

So syncthing is working and just like dropbox it requires the clients on each machine but it is free and works better than others I have tried so far (acronis, goodsync etc.).

I’m also hoping I can get the inotify module to work along with it but that’s down the road.