rename script
Peter Clark
clarkp at mtmary.edu
Wed Oct 26 15:22:40 EDT 2005
Hello,
I have a Cyrus 2.1.16 install running on a FreeBSD 5.1 machine and I
would like to use the rename script described in the managing IMPAP book
chap 9 (example 9-2). I have tried to run this scrip as root, cyrus and
logged in to cyradm and end up with a cryptic error message:
%./rename lm.out zzzzz zzzzzy
set: Variable name must begin with a letter.
# more lm.out
user.zzzzz.more (\HasNoChildren)
user.zzzzz.stuff (\HasNoChildren)
user.zzzzz.Trash (\HasNoChildren)
here is the script:
(the "set adminpw" is set correctly to my password)
# more rename
#!/usr/local/bin/cyradm -file
#
# Usage: rename filename olduser newuser
#
set inputfile [lindex $argv 0]
set oldmb [lindex $argv 1]
set newmb [lindex $argv 2]
#set mailstore "/var/spool/imap/user"
set mailstore "/data/mail/var/spool/imap/user"
eval cyradm connect cyr_conn localhost 143
puts stdout "Connected to IMAP server. Authenticating..."
if [catch {eval cyr_conn authenticate -pwcommand {{
set hostname "localhost"
set adminid "cyrus"
set adminpw "xxxxx"
list $adminid $adminpw
}} } result ] {
puts stderr "$result (cleartext)"
return -code error $result
} else {
puts "Authentication successful."
}
##
## Open the file containing mailbox names, and create the
## top-level mailbox.
##
if [catch {open $inputfile r} fileId] {
puts stderr "Error: cannot open $inputfile"
} else {
## Create the toplevel mailbox
if [catch {cyr_conn createmailbox user.$newmb} result] {
puts stderr $result
} else {
puts "Created mailbox user.$newmb"
}
while {[gets $fileId line] >= 0} {
## Build the new mailbox name from the old one
set newf [join [lreplace [split $line .] 1 1 $newmb] . ]
## Create the mailbox
if [catch {cyr_conn createmailbox $newf} result] {
puts stderr $result
} else {
puts "Created sub-mailbox $newf"
}
}
# file delete -force /var/spool/cyrus/user/$newmb
file delete -force /data/mail/var/spool/cyrus/user/$newmb
file copy $mailstore/$oldmb $mailstore/$newmb
{exec /usr/bin/chown -R cyrus:mail $mailstore/$newmb}
## Delete the old account
if [catch {cyr_conn setaclmailbox user.$oldmb cyrusadm d} \
result] {
puts stderr $result
} else {
puts "setaclmailbox user.$oldmb cyrusadm d"
}
if [catch {cyr_conn deletemailbox user.$oldmb} result] {
puts stderr $result
} else {
puts "Deleted mailbox user.$oldmb"
}
}
puts "Please run \'reconstruct user.$newmb\' as cyrus."
I definately am handicapped in scripting. I am at a loss and any help
would be appreciated.
Peter Clark
More information about the Info-cyrus
mailing list