パソコンとAndroid間で使っていたが便利すぎる.
同期するんなら「BitTorrent Sync」 がなんか良いよ
・高速
・速度制限なし
・容量制限なし
大容量ファイルが高速で同期できたり.
24時間稼働しているサーバと連携すればもっと便利になりそうなので
サーバにセットしてみた.
関係するファイル
/usr/local/bin/btsync
/usr/local/etc/btsync/sync.conf
/etc/init.d/btsync
/usr/local/bin/btsync
実行バイナリ.
ダウンロードして置くだけ.
WEB-GUI もこれに含まれている.
BitTorrent Sync - ダウンロード
置いたらヘルプをとりあえずみてみる.
btsync [--config <path>] [--nodaemon] [--generate-secret] [--dump-sample-config] [--help] [--get-ro-secret <secret>] [--log file]
--config - location and name of configuration file
--nodaemon - do not use daemon mode
--generate-secret - generate shared secret
--get-ro-secret - get read only secret for existing master secret
--dump-sample-config - dump sample config file
--log file - force logging to file in non-daemon mode
--help - print this message and exit
/usr/local/etc/btsync/sync.conf
JSONな設定ファイル.
サンプルを書き出して編集する.
# btsync --dump-sample-config > /usr/local/etc/btsync/sync.conf
デバイス名 (サーバ名) :
"device_name": “My Server”,
対象ディレクトリ・シークレットキー :
// use --generate-secret in command line to create new secret
"secret" : “XXXXXXXXXXXXXXXXXXXXXX", // * required field
"dir" : "/home/maochanz/sync_dir”, // * required field
キーは 該当ディレクトリでオプションを付けて叩く.
[sync_dir]# btsync --generate-secret
pid ファイルの位置 :
停止時になんか気持ち悪いので指定しておく.
// uncomment next line if you want to set location of pid file
"pid_file" : "/var/run/btsync/btsync.pid”
設定ファイルを編集したら以下でとりあえず起動・停止できる.
# btsync —config /usr/local/etc/btsync/sync.conf
How do I stop btsync in linux - Sync General Discussion - BitTorrent Forums
/etc/init.d/btsync
なんとなく終了が気持ち悪いので起動スクリプトを置いて自動サービス起動できるように.
A simple init script for BitTorrent Sync. Written and tested on CentOS 6.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash
BIN='/usr/local/bin/btsync'
CONF='/usr/local/etc/btsync/sync.conf'
PID='/var/run/btsync/btsync.pid'
PIDMATCH=true
SERVICE=$(basename $0)
test $(id -u) -ne 0 && echo "This is for root." >&2 && exit 1
main(){
case $1 in
start)
if begin
then
echo "$SERVICE successfully started"
exit 0
else
echo "Error starting $SERVICE." >&2
exit 1
fi
;;
stop)
if end
then
echo "$SERVICE successfully stopped"
exit 0
else
echo "Error stopping $SERVICE" >&2
exit 1
fi
;;
status)
query
exit $?
;;
*)
printUsage
exit 1
;;
esac
}
running(){
test ! -f $PID && return 1
listen=$(netstat -tnlp | grep btsync | awk '{print $NF}' | cut -d'/' -f1)
last=$(cat $PID)
test -z $listen && return 1
if [[ $listen -ne $last ]]
then
echo "Warning: PID of listening instance does not match PID in $PID" >&2
PIDMATCH=false
return 0
else
return 0
fi
}
begin(){
if running
then
echo "$SERVICE is already running." >&2
return 1
else
$BIN --config $CONF
fi
}
end(){
if running
then
if ! $PIDMATCH
then
echo "Error: Failed to stop $SERVICE: PID in $PID does not match PID of listening instance" >&2
return 1
fi
kill -15 $(cat $PID)
xstat=$?
rm $PID
return $xstat
else
echo "$SERVICE is not running."
return 1
fi
}
query(){
if running
then
echo "$SERVICE is running"
return 0
else
echo "$SERVICE is stopped"
return 0
fi
}
printUsage(){
echo "Usage: $0 [start|stop|status]"
}
main $*
CentOS init.d startup script for bittorrent sync btsync - kinggeek.co.uk
btsync 0:off 1:off 2:on 3:on 4:on 5:on 6:off
By using this application, you agree to our Privacy Policy and Terms.
http://www.bittorrent.com/legal/privacy
http://www.bittorrent.com/legal/terms-of-use
BitTorrent Sync forked to background. pid = 1588
btsync successfully started
btsync successfully stopped
By using this application, you agree to our Privacy Policy and Terms.
http://www.bittorrent.com/legal/privacy
http://www.bittorrent.com/legal/terms-of-use
BitTorrent Sync forked to background. pid = 1588
btsync successfully started
あとは, Androidアプリを入れてサーバで設定したキーを入力すればよい.
BitTorrent Sync - Google Play の Android アプリ
BitTorrent Sync - ダウンロード
大量な音楽, 動画ファイルがバンバン高速同期されてくる.
よすぎる.
同期してるということは, Andoroid 内のファイルを サーバ上で 編集できるということ.