[prev in list] [next in list] [prev in thread] [next in thread]
List: squirrelmail-cvs
Subject: [SM-CVS] CVS: squirrelmail/contrib flat2sql.pl,1.4,1.5
From: Tomas Kuliavas <tokul () users ! sourceforge ! net>
Date: 2005-09-20 16:41:30
Message-ID: E1EHlBS-0008DX-Dh () sc8-pr-cvs1 ! sourceforge ! net
[Download RAW message or body]
Update of /cvsroot/squirrelmail/squirrelmail/contrib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31562
Modified Files:
flat2sql.pl
Log Message:
added more configuration controls
fixed address book deletes
fixed signature table
Index: flat2sql.pl
===================================================================
RCS file: /cvsroot/squirrelmail/squirrelmail/contrib/flat2sql.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -r1.4 -r1.5
--- flat2sql.pl 20 Sep 2005 11:47:10 -0000 1.4
+++ flat2sql.pl 20 Sep 2005 16:41:28 -0000 1.5
@@ -1,22 +1,26 @@
#!/usr/bin/perl
#
+# Converts file based preferences into SQL statements.
+#
+# WARNING: this script is experimental. Don't use it as
+# privileged user or backup your data directory before using it.
+#
# Copyright (c) 2002, Michael Blandford and Tal Yardeni
# Copyright (c) 2005, The SquirrelMail Project Team
#
# This script is licensed under GPL.
# $Id$
-##### Conf Section #####
+#
-$data_dir = "/var/local/squirrelmail/data";
+##### Default values #####
$db = "squirrelmail";
$abook_table = "address";
$pref_table = "userprefs";
-
##### ##### #####
use Getopt::Long;
-&GetOptions( \%opts, qw( abook data_dir:s delete h help pref sig user:s ) );
+&GetOptions( \%opts, qw( abook data_dir:s delete h help pref sig user:s db:s \
pref_table:s abook_table:s) );
&Usage if ( defined $opts{h} or defined $opts{help} );
@@ -26,8 +30,23 @@
$opts{sig}=TRUE;
}
-# Override the data directory if passed as an argument
-$data_dir = $opts{data_dir} if ( defined $opts{data_dir} );
+
+if ( defined $opts{db} and $opts{db} ) {
+ $db = $opts{db};
+}
+if ( defined $opts{pref_table} and $opts{pref_table} ) {
+ $pref_table = $opts{pref_table};
+}
+if ( defined $opts{abook_table} and $opts{abook_table}) {
+ $abook_table = $opts{abook_table};
+}
+
+# Get data directory option and display help if it is not defined
+if ( defined $opts{data_dir} and $opts{data_dir} ) {
+ $data_dir = $opts{data_dir};
+} else {
+ &Usage;
+}
# Are we looking for specific users or all users?
# There has to be a better way to do this - Below
@@ -62,7 +81,7 @@
# Process a user address file
sub abook {
- print "DELETE FROM $db.$abook_table WHERE owner = '$username;\n"
+ print "DELETE FROM $db.$abook_table WHERE owner = '$username';\n"
if ( defined $opts{delete} );
open(ABOOK, "<$data_dir/$filename") or
@@ -130,7 +149,7 @@
$prefkey .= "$1___";
}
- print "INSERT INTO $db.$sig_table (user,prefkey,prefval) "
+ print "INSERT INTO $db.$pref_table (user,prefkey,prefval) "
. "VALUES ('$username','$prefkey','".join("", @lines)."');\n";
}
@@ -141,10 +160,32 @@
$0 =~ /.*\/(.*)/;
$prog = $1;
print <<EOL;
-This program generates SQL statements to aid importing squirrelmail
+
+This program generates SQL statements to aid importing SquirrelMail
user config into a database.
-Usage: $prog [--delete] [--abook] [--pref] [--sig] [--data_dir=<>] \
[--user=<username0[,username1[,username2]...]] +WARNING: this script is experimental. \
Don't use it as +privileged user or backup your data directory before using it.
+
+Usage: $prog --data_dir=<data_dir> [--delete] [--abook] [--pref] [--sig]
+ [--user=<username0[,username1[,username2]...]]
+ [--db=<database>] [--pref_table=<userprefs>] [--abook_table=<address>]
+
+--data_dir option must define path to SquirrelMail data directory. If
+option is not defined, script displays this help message.
+
+--abook option is used to generate SQL with address books.
+--pref option is used to generate SQL with user preferences.
+--sig option is used to generate SQL with signatures.
+
+--db option can be used to set database name. Script defaults to
+'squirrelmail'.
+
+--pref_table option can be used to set preference table name. Script
+defaults to 'userprefs'.
+
+--abook_table option can be used to set address book table name. Script
+defaults to 'address'.
Prefs --abook, --pref, and --sig are assumed if none of them as passed
@@ -152,7 +193,7 @@
the database. This is useful to reimport users.
It respects --abook, --pref, and --sig.
-If --user is not specified, it will try to do all users.
+If --user is not specified, script extracts all user data.
EOL
exit 1;
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
--
squirrelmail-cvs mailing list
List Address: squirrelmail-cvs@lists.sourceforge.net
List Info: https://lists.sourceforge.net/lists/listinfo/squirrelmail-cvs
http://squirrelmail.org/cvs
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic