52 lines
1.1 KiB
Plaintext
Executable File
52 lines
1.1 KiB
Plaintext
Executable File
#!/bin/env nu
|
|
|
|
def main [] {
|
|
print "Usage: imapsync.nu [show_data|test_creds|synchronize] example.yaml"
|
|
}
|
|
|
|
def "main show_data" [conffile] {
|
|
|
|
(open $conffile |
|
|
|
|
each {|u|
|
|
|
|
print $"host1: ($u.host1), user1: ($u.user1),"
|
|
print $" host2: ($u.host2), user2: ($u.user2)\n"
|
|
}
|
|
)
|
|
""
|
|
}
|
|
|
|
def "main test_creds" [conffile] {
|
|
|
|
(open $conffile |
|
|
|
|
each {|u|
|
|
|
|
print "Testing credentials for:"
|
|
print $" host1: ($u.host1), user1: ($u.user1),"
|
|
print $" host2: ($u.host2), user2: ($u.user2)\n"
|
|
|
|
imapsync --justlogin --host1 $u.host1 --user1 $u.user1 --password1 $u.password1 --host2 $u.host2 --user2 $u.user2 --password2 $u.password2 | grep -P "^Host[12]:? (failure|success)" | print
|
|
print " "
|
|
}
|
|
)
|
|
""
|
|
}
|
|
|
|
def "main synchronize" [conffile] {
|
|
|
|
(open $conffile |
|
|
|
|
each {|u|
|
|
|
|
print "Synchronizing:"
|
|
print $" host1: ($u.host1), user1: ($u.user1),"
|
|
print $" host2: ($u.host2), user2: ($u.user2)\n"
|
|
|
|
imapsync --syncinternaldates --addheader --host1 $u.host1 --user1 $u.user1 --password1 $u.password1 --host2 $u.host2 --user2 $u.user2 --password2 $u.password2 | print
|
|
}
|
|
)
|
|
""
|
|
}
|