Remplacement de kopano-cli par kopano-admin car kopano-cli est abandonné

This commit is contained in:
root 2020-07-16 22:13:11 +02:00
parent ce3251d183
commit 036bf197cf
2 changed files with 28 additions and 28 deletions

View File

@ -1,24 +1,24 @@
#!/bin/bash #!/bin/bash
CSV_FILE="$1" CSV_FILE="$1"
if [ -z "$CSV_FILE" ] ; then if [ -z "${CSV_FILE}" ] ; then
echo No CSV file supplied... Exiting echo No CSV file supplied... Exiting
exit 1 exit 1
fi fi
cat $CSV_FILE | grep -v '^#' | while read line ; do cat ${CSV_FILE} | grep -v '^#' | while read line ; do
MAIL=`echo $line | awk -F';' '{ print $1 }'` MAIL=`echo ${line} | awk -F';' '{ print $1 }'`
USERNAME="$MAIL" USERNAME="${MAIL}"
if kopano-cli --user=$USERNAME > /dev/null 2>&1 ; then if kopano-admin --details ${USERNAME} > /dev/null 2>&1 ; then
if kopano-cli --user=$USERNAME | awk '/^Features/' | grep imap > /dev/null 2>&1 ; then if kopano-admin --details ${USERNAME} | awk '/PR_EC_ENABLED_FEATURES/' | grep imap > /dev/null 2>&1 ; then
echo imap already activated for $USERNAME echo imap already activated for ${USERNAME}
else else
echo Activating imap for $USERNAME echo Activating imap for ${USERNAME}
/usr/sbin/kopano-cli --user $USERNAME --add-feature imap /usr/sbin/kopano-admin -u ${USERNAME} --enable-feature imap
fi fi
else else
echo $USERNAME does not exist echo ${USERNAME} does not exist
fi fi
done done

View File

@ -1,33 +1,33 @@
#!/bin/bash #!/bin/bash
CSV_FILE="$1" CSV_FILE="$1"
if [ -z "$CSV_FILE" ] ; then if [ -z "${CSV_FILE}" ] ; then
echo No CSV file supplied... Exiting echo No CSV file supplied... Exiting
exit 1 exit 1
fi fi
cat $CSV_FILE | grep -v '^#' | while read line ; do cat ${CSV_FILE} | grep -v '^#' | while read line ; do
MAIL=`echo $line | awk -F';' '{ print $1 }'` MAIL=`echo ${line} | awk -F';' '{ print $1 }'`
USERNAME="$MAIL" USERNAME="${MAIL}"
PASSWORD=`echo $line | awk -F';' '{ print $3 }'` PASSWORD=`echo ${line} | awk -F';' '{ print $3 }'`
FULL_NAME=`echo $line | awk -F';' '{ print $2 }'` FULL_NAME=`echo ${line} | awk -F';' '{ print $2 }'`
if kopano-cli --user=$USERNAME > /dev/null 2>&1 ; then if kopano-admin --details ${USERNAME} > /dev/null 2>&1 ; then
echo $USERNAME already exist echo ${USERNAME} already exist
else else
TEMP_SH=`mktemp /tmp/create_mailbox.XXXX` TEMP_SH=`mktemp /tmp/create_mailbox.XXXX`
cat > $TEMP_SH << EOF cat > ${TEMP_SH} << EOF
#!/bin/sh #!/bin/sh
echo creating $USERNAME echo creating ${USERNAME}
/usr/sbin/kopano-cli --create \ /usr/sbin/kopano-admin \
--user '$USERNAME' \ -c '${USERNAME}' \
--password '$PASSWORD' \ -p '${PASSWORD}' \
--email '$MAIL' \ -e '${MAIL}' \
--fullname '$FULL_NAME' \ -f '${FULL_NAME}' \
--admin-level 0 \ -a no \
--lang '$LANG' --lang '${LANG}'
EOF EOF
sh $TEMP_SH && rm $TEMP_SH sh ${TEMP_SH} && rm ${TEMP_SH}
fi fi
done done