使用 Android NDK 为不同的移动架构构建 rsync 可执行文件
$ git clone https://github.com/daliujs/rsync-mobile
$ git submodule update --init --recursive
一次搞定的命令:
$ git clone --recurse-submodules https://github.com/daliujs/rsync-mobile
// for build rsync-<arch>
$ ./ndk_build.sh
// for test bin files
$ ./test.sh
- 需要放到 /system/bin 目录下
$ adb root
$ adb push rsync-<arch> /system/bin
- 修改owner & group 及执行权限 (注,如果需要的话)
$ adb shell
$ chown root:shell /system/bin/rsync-<arch>
$ chmod a+x /system/bin/rsync-<arch>
- 修改文件属性
$ chmod 755 /system/bin/rsync-<arch>
- Rsync Daemon配置文件
$ cat rsyncd.conf
address = 0.0.0.0
port = 873
uid = 1000
gid = 1000
strict modes = false
use chroot = false
auth users = wanba
secrets file = /<path-to>/rsync.pass
lock file = /<path-to>/rsync.lock
log file = /<path-to>/rsyncd.log
[sdcard_android_data]
path = /sdcard/Android/data/
comment = SD Android Data
list = true
read only = false
#write only = true
[sdcard_apks]
path = /sdcard/Apks/
comment = SD Apks
list = true
read only = false
#write only = true
- secrets 文件
$ cat rsync.pass
wanba:123456
- 需要把client端ip以及名称写入 /etc/hosts
$ cat /etc/hosts
127.0.0.1 localhost
10.1.7.180 bogon
- 启动 Rsync Daemon 服务
$ rsync-<arch> --daemon --verbose --config=/<path-to>/rsyncd.conf
- Password 文件
$ cat password
123456
- 客户端 upload 文件到 服务端
$ rsync-<arch> -rv --password-file=password ./* rsync://wanba@<server-ip>/sdcard_android_data
$ rsync-<arch> -rv --password-file=password ./* wanba@10.1.3.86::sdcard_apks