Scripts d'aides pour Kopano
This commit is contained in:
commit
e6fda335f9
24
kopano/active_imap.sh
Executable file
24
kopano/active_imap.sh
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
CSV_FILE="$1"
|
||||||
|
|
||||||
|
if [ -z "$CSV_FILE" ] ; then
|
||||||
|
echo No CSV file supplied... Exiting
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat $CSV_FILE | grep -v '^#' | while read line ; do
|
||||||
|
MAIL=`echo $line | awk -F';' '{ print $1 }'`
|
||||||
|
USERNAME="$MAIL"
|
||||||
|
|
||||||
|
|
||||||
|
if kopano-cli --user=$USERNAME > /dev/null 2>&1 ; then
|
||||||
|
if kopano-cli --user=$USERNAME | awk '/^Features/' | grep imap > /dev/null 2>&1 ; then
|
||||||
|
echo imap already activated for $USERNAME
|
||||||
|
else
|
||||||
|
echo Activating imap for $USERNAME
|
||||||
|
/usr/sbin/kopano-cli --user $USERNAME --add-feature imap
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo $USERNAME does not exist
|
||||||
|
fi
|
||||||
|
done
|
23
kopano/addvirtual.sh
Executable file
23
kopano/addvirtual.sh
Executable file
@ -0,0 +1,23 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
CSV_FILE="$1"
|
||||||
|
|
||||||
|
if [ -z "$CSV_FILE" ] ; then
|
||||||
|
echo No CSV file supplied... Exiting
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat $CSV_FILE | grep -v '^#' | while read line ; do
|
||||||
|
MAIL=`echo $line | awk -F';' '{ print $1 }'`
|
||||||
|
USERNAME="$MAIL"
|
||||||
|
PASSWORD=`echo $line | awk -F';' '{ print $3 }'`
|
||||||
|
FULL_NAME=`echo $line | awk -F';' '{ print $2 }'`
|
||||||
|
|
||||||
|
if grep "^$MAIL" /etc/aliases > /dev/null 2>&1 ; then
|
||||||
|
echo $MAIL already exist
|
||||||
|
else
|
||||||
|
echo Adding $MAIL account
|
||||||
|
echo -e "$MAIL:\t$MAIL" >> /etc/aliases
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
#postmap /etc/postfix/virtual
|
||||||
|
newaliases
|
1
kopano/create_mailbox.csv
Normal file
1
kopano/create_mailbox.csv
Normal file
@ -0,0 +1 @@
|
|||||||
|
# email;Full Name;password
|
|
33
kopano/create_mailbox.sh
Executable file
33
kopano/create_mailbox.sh
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
CSV_FILE="$1"
|
||||||
|
|
||||||
|
if [ -z "$CSV_FILE" ] ; then
|
||||||
|
echo No CSV file supplied... Exiting
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat $CSV_FILE | grep -v '^#' | while read line ; do
|
||||||
|
MAIL=`echo $line | awk -F';' '{ print $1 }'`
|
||||||
|
USERNAME="$MAIL"
|
||||||
|
PASSWORD=`echo $line | awk -F';' '{ print $3 }'`
|
||||||
|
FULL_NAME=`echo $line | awk -F';' '{ print $2 }'`
|
||||||
|
|
||||||
|
|
||||||
|
if kopano-cli --user=$USERNAME > /dev/null 2>&1 ; then
|
||||||
|
echo $USERNAME already exist
|
||||||
|
else
|
||||||
|
TEMP_SH=`mktemp /tmp/create_mailbox.XXXX`
|
||||||
|
cat > $TEMP_SH << EOF
|
||||||
|
#!/bin/sh
|
||||||
|
echo creating $USERNAME
|
||||||
|
/usr/sbin/kopano-cli --create \
|
||||||
|
--user '$USERNAME' \
|
||||||
|
--password '$PASSWORD' \
|
||||||
|
--email '$MAIL' \
|
||||||
|
--fullname '$FULL_NAME' \
|
||||||
|
--admin-level 0 \
|
||||||
|
--lang '$LANG'
|
||||||
|
EOF
|
||||||
|
sh $TEMP_SH && rm $TEMP_SH
|
||||||
|
fi
|
||||||
|
done
|
32
kopano/kopano_db.sh
Executable file
32
kopano/kopano_db.sh
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
PASS_LENGH="14"
|
||||||
|
DB_NAME="kopano"
|
||||||
|
DB_USER="kopano"
|
||||||
|
DB_HOST="localhost"
|
||||||
|
DB_PORT="3306"
|
||||||
|
DB_PASS=`openssl rand -base64 $PASS_LENGH`
|
||||||
|
|
||||||
|
cat > /etc/kopano/db.cfg << EOF
|
||||||
|
database_engine = mysql
|
||||||
|
mysql_host = $DB_HOST
|
||||||
|
mysql_port = $DB_PORT
|
||||||
|
mysql_user = $DB_USER
|
||||||
|
mysql_password = $DB_PASS
|
||||||
|
mysql_database = $DB_NAME
|
||||||
|
EOF
|
||||||
|
|
||||||
|
GRANT_SH=`mktemp /tmp/GRANT_DB.XXXX`
|
||||||
|
cat > $GRANT_SH << EOF
|
||||||
|
#!/bin/sh
|
||||||
|
mysql -e "grant all privileges on $DB_NAME.* to '$DB_USER'@'localhost' identified by '$DB_PASS';"
|
||||||
|
EOF
|
||||||
|
sh $GRANT_SH && rm $GRANT_SH
|
||||||
|
|
||||||
|
if grep '^!include /etc/kopano/db.cfg' /etc/kopano/server.cfg 2>&1 > /dev/null ; then
|
||||||
|
echo /etc/kopano/db.cfg already include in /etc/kopano/server.cfg
|
||||||
|
else
|
||||||
|
echo Including /etc/kopano/db.cfg in /etc/kopano/server.cfg
|
||||||
|
echo '!include /etc/kopano/db.cfg' >> /etc/kopano/server.cfg
|
||||||
|
fi
|
||||||
|
|
2
kopano/mig_blorand.csv
Normal file
2
kopano/mig_blorand.csv
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# Source IMAP IP;Source IMAP login;Source IMAP password;Destination IMAP IP (localhost);Destination IMAP login;Destination IMAP password
|
||||||
|
# Be sure to not have ";" in password
|
Can't render this file because it contains an unexpected character in line 2 and column 23.
|
36
kopano/mig_blorand.sh
Executable file
36
kopano/mig_blorand.sh
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
IMAPSYNC_BIN=/usr/bin/kopano-migration-imap
|
||||||
|
|
||||||
|
#imapsync \
|
||||||
|
# --host1 test1.lamiral.info --user1 test1 --password1 secret1 \
|
||||||
|
# --host2 test2.lamiral.info --user2 test2 --password2 secret2
|
||||||
|
|
||||||
|
cat mig_blorand.csv | grep -v '^#' | while read line ; do
|
||||||
|
ORIG_IMAP_SRV=`echo $line | awk -F':' '{ print $1 }'`
|
||||||
|
ORIG_IMAP_LOGIN=`echo $line | awk -F':' '{ print $2 }'`
|
||||||
|
ORIG_IMAP_PASS=`echo $line | awk -F':' '{ print $3 }'`
|
||||||
|
DEST_IMAP_SRV=`echo $line | awk -F':' '{ print $4 }'`
|
||||||
|
DEST_IMAP_LOGIN=`echo $line | awk -F':' '{ print $5 }'`
|
||||||
|
DEST_IMAP_PASS=`echo $line | awk -F':' '{ print $6 }'`
|
||||||
|
|
||||||
|
IMAPSYNC_LOG="$IMAPSYNC_LOGDIR/$ORIG_IMAP_LOGIN-`date +%y%m%d-%H:%M:%S`.log"
|
||||||
|
|
||||||
|
$IMAPSYNC_BIN \
|
||||||
|
--noreleasecheck --timeout1 1200 --timeout2 1200 \
|
||||||
|
--host1 $ORIG_IMAP_SRV --user1 $ORIG_IMAP_LOGIN --password1 "$ORIG_IMAP_PASS" \
|
||||||
|
--host2 $DEST_IMAP_SRV --user2 $DEST_IMAP_LOGIN --password2 "$DEST_IMAP_PASS" \
|
||||||
|
--useheader "Message-Id" \
|
||||||
|
--exclude 'Notes' \
|
||||||
|
--delete2 --delete2duplicates --expunge2 \
|
||||||
|
--regextrans2 's/Sent/&AMk-l&AOk-ments envoy&AOk-s/' \
|
||||||
|
--regextrans2 's/Drafts/Brouillons/' \
|
||||||
|
--regextrans2 's/Junk/Courrier ind&AOk-sirable/' \
|
||||||
|
--regextrans2 's/Trash/&AMk-l&AOk-ments supprim&AOk-s/'
|
||||||
|
|
||||||
|
if [ "$?" == "0" ] ; then
|
||||||
|
echo " : OK"
|
||||||
|
else
|
||||||
|
echo " : NOK"
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in New Issue
Block a user