summaryrefslogtreecommitdiff
path: root/localsyncmail
blob: a6cd2f7eac4b247620980ef9ac798d741e85ac26 (plain)
  1. #!/bin/sh
  2. me=$(whoami)
  3. user=$1
  4. if [ -n "$user" ]; then
  5. host=$2
  6. if [ -n "$host" ]; then
  7. shift 2
  8. else
  9. host=localhost
  10. shift
  11. fi
  12. else
  13. user=$me
  14. fi
  15. localsync() {
  16. user=$1; shift
  17. pkill -u $user offlineimap || [ $? -lt 2 ]
  18. offlineimap $@
  19. }
  20. remotesync() {
  21. user=$1; shift
  22. host=$1; shift
  23. if [ "$host" = "localhost" ]; then
  24. ssh $user@$host pkill -u $user offlineimap || [ $? -lt 2 ]
  25. ssh -X -e none -tt $user@$host offlineimap $@
  26. else
  27. ssh -C $user@$host pkill -u $user offlineimap || [ $? -lt 2 ]
  28. ssh -C -X -e none -tt $user@$host offlineimap $@
  29. fi
  30. }
  31. if [ "$user" = "$me" ] && [ "$host" = "localhost" ]; then
  32. localsync $user $@
  33. else
  34. remotesync $user $host $@
  35. fi
  36. exit 0