ssfs rev 84
ssfs: clean logs on sync and use \key
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Jun 19 23:10:11 2011 +0200 (2011-06-19) |
parents | a9f7789b353e |
children | f99275406656 |
files | ssfs |
line diff
1.1 --- a/ssfs Sun Jun 19 09:56:34 2011 +0100 1.2 +++ b/ssfs Sun Jun 19 23:10:11 2011 +0200 1.3 @@ -11,6 +11,7 @@ 1.4 pid=$HOME/.local/var/run/$app.pid 1.5 logdir=$HOME/.local/var/log/$app 1.6 config=$HOME/.config/$app/client.lua 1.7 +key=$HOME/.ssh/id_rsa 1.8 1.9 # Internationalization 1.10 . /usr/bin/gettext.sh 1.11 @@ -90,7 +91,7 @@ 1.12 info) 1.13 size=$(du -sh $HOME/Sync | awk '{print $1}') 1.14 echo "" && config_info && echo "" 1.15 - gettext "RSA key :"; echo " $HOME/.ssh/id_rsa" 1.16 + gettext "RSA key :"; echo " $key" 1.17 gettext "Sync size :"; echo " $size" 1.18 echo "" ;; 1.19 setup) 1.20 @@ -103,9 +104,9 @@ 1.21 mkdir -p $logdir $(dirname $pid) 1.22 1.23 # Configure passwordless login via RSA key. 1.24 - if [ ! -f "$HOME/.ssh/id_rsa" ]; then 1.25 - mkdir -p $HOME/.ssh 1.26 - ssh-keygen -b 2048 -f $HOME/.ssh/id_rsa -P '' 1.27 + if [ ! -f "$key" ]; then 1.28 + mkdir -p $(dirname $key) 1.29 + ssh-keygen -b 2048 -f $key -P '' 1.30 fi 1.31 echo "" 1.32 1.33 @@ -113,7 +114,7 @@ 1.34 gettext "Sending RSA secure key to:"; echo " $host" 1.35 gettext "Please enter your Ssfs password." 1.36 echo -e "\n" 1.37 - cat $HOME/.ssh/id_rsa.pub | \ 1.38 + cat $key.pub | \ 1.39 ssh $login@$host 'cat - >> ~/.ssh/authorized_keys' || exit 1 1.40 gettext "Client is setup you can now sync"; echo ;; 1.41 sync) 1.42 @@ -125,18 +126,22 @@ 1.43 login=${at%@*} 1.44 host=${at#*@} 1.45 echo "" && gettext "Syncing from:"; echo " $login@$host" 1.46 + 1.47 + # Clean logs. 1.48 + echo "" > $logdir/lsyncd.log 1.49 + echo "" > $logdir/rsync.log 1.50 1.51 - # First sync host with server. 1.52 + # First sync client with server. 1.53 rsync -r -a -v -h -z -u --delete \ 1.54 --log-file=$logdir/rsync.log \ 1.55 -e "ssh -l $login" $host:~/Sync/ ~/Sync/ | \ 1.56 sed -e "/^$/"d -e "/^.\/$/"d 1.57 1.58 - # Monitor local folder if not yet running. 1.59 + # Monitor local folder. 1.60 killall lsyncd 2>/dev/null 1.61 gettext "Starting lsyncd daemon..." 1.62 - lsyncd -pidfile $pid -log all -logfile $logdir/lsyncd.log $config 1.63 - echo "" ;; 1.64 + lsyncd -pidfile $pid -log scarce -logfile $logdir/lsyncd.log $config 1.65 + echo -e "\n" ;; 1.66 stop) 1.67 # Kill daemon and remove pidfile. 1.68 [ ! -s "$pid" ] && gettext "Daemon is not running" && \