Advertisement
Guest User

Frank

a guest
Nov 1st, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.65 KB | None | 0 0
  1. GENERATING THE LISTS
  2. #!/bin/bash
  3. #findbox.sh 0.1   takes the below 3 parameters, required
  4. set timeout 10
  5. set hostName [lindex $argv 0]
  6. set userName [lindex $argv 1]
  7. set password  [lindex $argv 2]
  8.  
  9. #Find all folders with mbox files in them
  10. find . -name 'mbox' | while read LINE; do echo$LINE” ; done |  sed 's/ /\\ /g' > /tmp/dirlist
  11. echo A nice escaped list of paths is now in /tmp/dirlist
  12. #Make the inboxes on destination, dashes for spaces,
  13. cat /tmp/dirlist | sed 's/ /\-/g' | while read mlabel; do /tmp/makebox.sh $hostName $userName $password $mlabel ;done
  14. #EOF
  15.  
  16.  
  17.  
  18.  
  19. MAKING THE TARGET BOXES
  20. #!/usr/bin/expect
  21. #makebox.sh 0.1
  22.  
  23. set timeout 10
  24. set hostName [lindex $argv 0]
  25. set userName [lindex $argv 1]
  26. set password  [lindex $argv 2]
  27. set title           [lindex $argv 3]
  28.  
  29.  spawn telnet $hostName imap
  30. expect -exact “Dovecot ready”
  31. send “A1 LOGIN $userName $password\r”
  32. expect -exact “Logged in
  33. send “A1 CREATE INBOX.$title\r”
  34. expect -exact “Create completed.”
  35. send “A1 LOGOUT”
  36.  
  37. #EOF
  38.  
  39.  
  40. UPLOAD THE MAILBOXES
  41. #!/bin/bash
  42. #Uploader 0.1 /tmp/upload.sh
  43. set hostName [lindex $argv 0]
  44. set userName [lindex $argv 1]
  45. set password  [lindex $argv 2]
  46.  
  47. oIFS=$IFS  #save original IFS, must be restored!!
  48. IFS$`\n'   #hack for displaying escaped spaced since python is picky
  49. #Upload mailboxes but replace spaces with dashes at the end, cut command might need a column set properly
  50. find . -name 'mbox' | while read -r i; do python /PATH/TO/IMAP_UPLOAD.py –user $userName –password $password “$i” imaps://$hostName/INBOX.`echo $i | cut -d/ -f2 | sed 's/ /\\-/g'`;done
  51.  
  52. IFS=$oIFS #restore original IFS
  53. #EOF
  54. #Comein22
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement