Tuesday, December 15, 2015

Installing rsync in CH3HNAS

I had this cheap NAS laying around for a while. It lacks a really important feature, rsync.
I've seen fun_plug package for other models (CH3SNAS, CH3MNAS) but as Uli Wolf  told me, he hadn't any compiled binary for CH3HNAS, tough luck.
So, after a few Google searches and some luck I've scored a rsync binary for Android ARM, luckily for the same CPU. I'm too lazy to cross compile it :)
Here's a brief tutorial on how to install it:

/home/Public/funplug/ffp/var
/home/Public/funplug/ffp/etc
/home/Public/funplug/ffp/bin
/home/Public/funplug/ffp/start
/home/Public/funplug/ffp/var/run
/home/Public/funplug/ffp/var/log
  • Unzip the previous file to /home/Public/funplug/ffp/bin and rename it to rsync
  • Create dummy /home/Public/funplug/ffp/start/SERVERS.sh with the following:
#!/bin/sh
  • Create another dummy file /home/Public/funplug/ffp/start/LOGIN.sh with the same contents
  • Now create the startup script /home/Public/funplug/ffp/start/rsyncd.sh as following:
#!/bin/sh
# PROVIDE: rsyncd
# REQUIRE: LOGIN
# This script assumes that the rsync configuration includes
# pid file = /var/run/rsyncd.pid
conf_file=/ffp/etc/rsyncd.conf
pid_file=/ffp/var/run/rsyncd.pid
rsync_flags="--daemon --config=$conf_file"
rsyncd_start()
{
if [ ! -r "$conf_file" ]; then
echo "Error: Missing config file $conf_file"
exit 1
fi
x=$(grep '^pid file' $conf_file | cut -d= -f2)
if [ "$x" != "$pid_file" ]; then
echo "Error: Missing or wrong pid file in $conf_file (expected: $pid_file = $x)"
exit 1
fi
echo "Starting /ffp/bin/rsync $rsync_flags"
/ffp/bin/rsync $rsync_flags
}
rsyncd_stop()
{
if [ -r "$pid_file" ]; then
echo "Stopping rsyncd: $pid_file"
kill $(cat $pid_file) 2>/dev/null
fi
}
rsyncd_status()
{
if [ -r $pid_file ]; then
rsync_pid=$(cat $pid_file)
if pidof rsync | grep -wq $rsync_pid; then
echo "rsyncd running: $rsync_pid"
else
echo "rsync not running ($pid_file stale)"
fi
else
echo "rsyncd not running"
fi
}
case "$1" in
start)
rsyncd_start
;;
stop)
rsyncd_stop
;;
restart)
rsyncd_stop
sleep 1
rsyncd_start
;;
status)
rsyncd_status
;;
*)
echo "Usage: $(basename $0) start|stop|restart|status"
exit 1
;;
esac
  •  And finally /home/Public/funplug/ffp/etc/rsyncd.conf
Please note that this is only an example, you should adapt it to your current directory structure and set permissions as desired.
uid = 0
gid = 0
max connections = 4
pid file =/ffp/var/run/rsyncd.pid
log file =/ffp/var/log/rsyncd.log
[Photos]
path = /home/Disk_2
comment = My Photos
read only = no
list = yes
hosts allow = 192.168.10.200/255.255.255.0
[Music]
path = /home/Disk_1
comment = My Music
read only = no
list = yes
hosts allow = 192.168.10.200/255.255.255.0
  • Now try to run /ffp/start/rsyncd.sh if everything is good you should see the daemon starting.
  • Reboot just too make sure that it runs on startup.
Enjoy or try HFP by Henk-Jan's, it add more features to CH3HNAS.

No comments:

Post a Comment