diff options
-rwxr-xr-x | localsyncmail | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/localsyncmail b/localsyncmail index 03dc1d2..a6cd2f7 100755 --- a/localsyncmail +++ b/localsyncmail @@ -15,13 +15,30 @@ else user=$me fi -if [ "$user" = "$me" ] && [ "$host" = "localhost" ]; then +localsync() { + user=$1; shift + pkill -u $user offlineimap || [ $? -lt 2 ] offlineimap $@ +} + +remotesync() { + user=$1; shift + host=$1; shift + + if [ "$host" = "localhost" ]; then + ssh $user@$host pkill -u $user offlineimap || [ $? -lt 2 ] + ssh -X -e none -tt $user@$host offlineimap $@ + else + ssh -C $user@$host pkill -u $user offlineimap || [ $? -lt 2 ] + ssh -C -X -e none -tt $user@$host offlineimap $@ + fi +} + +if [ "$user" = "$me" ] && [ "$host" = "localhost" ]; then + localsync $user $@ else - ssh -C -X -e none $user@$host pkill -u $user offlineimap || [ $? -lt 2 ] - ssh -C -X -e none -tt $user@$host offlineimap $@ + remotesync $user $host $@ fi - exit 0 |