Vacation - Gestionnaire d'Absence ====== Préparation du plugin ====== Récupérez le plugin vacation vacation-1.9.9.zip pour Roundcube http://downloads.sourceforge.net/project/rcubevacation/vacation-1.9.9.zip et installez les paquets perl manquants à vacation pour le bon fonctionnement # apt-get install libmail-sender-perl libdbd-mysql-perl libemail-valid-perl libmime-perl liblog-log4perl-perl liblog-dispatch-perl libgetopt-argvfile-perl libmime-charset-perl libmime-encwords-perl Une fois l'archive récupérée, décompressez là dans le répertoire des plugins de roundcube et activez le plugin # unzip vacation-1.9.9.zip -d /var/www/roundcubemail/plugins/ # chown -R www-data.www-data vacation Pour l'activer # vi /var/www/roundcubemail/config/main.inc.php // ---------------------------------- // PLUGINS // ---------------------------------- // List of active plugins (in plugins/ directory) $rcmail_config['plugins'] = array('managesieve','vacation'); Le plugin souffre d'un petit bug d'affichage facile à régler. Ouvrez le fichier (..)/vacation/skins/default/vacation.css et remplacez #pagecontent { width: 800px; } par #pagecontent { width: 800px; position: absolute; bottom: 20px; left: 250px; right: 20px; top: 85px; } Si vous utilisez Roundcube.0.9.x, il faut patcher le plugin Vacation. Télécharger le patch http://sourceforge.net/p/rcubevacation/patches/20/attachment/virtual.class.php.diff.patch Déposez le dans le répertoire /var/www/roundcubemail/plugins/vacation/lib puis patchez le fichier virtual.class.php # patch -p0 < virtual.class.php.diff.patch ====== Modification des tables ====== Passons aux tables "vacation" et "vacation_notification" qui vont recevoir les datas du plugin vacation On se connecte en root sur la base postfix pour supprimer les tables "vacation" et "vacation_notification" actuelles de la base postfix pour les remplacer par celles fournies dans vacation/extra/virtual_vacation # mysql -u root -p password : xxxxxx use postfix DROP TABLES vacation_notification; DROP TABLES vacation; CREATE TABLE `vacation` ( `email` varchar(255) NOT NULL, `subject` varchar(255) CHARACTER SET utf8 NOT NULL, `body` text CHARACTER SET utf8 NOT NULL, `cache` text NOT NULL, `domain` varchar(255) NOT NULL, `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', `active` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`email`), KEY `email` (`email`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='Postfix Admin - Virtual Vacation'; CREATE TABLE `vacation_notification` ( `on_vacation` varchar(255) CHARACTER SET latin1 NOT NULL, `notified` varchar(255) CHARACTER SET latin1 NOT NULL, `notified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`on_vacation`,`notified`), CONSTRAINT `vacation_notification_pkey` FOREIGN KEY (`on_vacation`) REFERENCES `vacation` (`email`) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Postfix Admin - Virtual Vacation Notifications'; ALTER TABLE `vacation_notification` -> ADD CONSTRAINT `vacation_notification_ibfk_1` FOREIGN KEY (`on_vacation`) REFERENCES `vacation` (`email`) ON DELETE CASCADE; ====== Création de l'espace de travail ====== Pour que cela fonctionne, nous allons créer un utilisateur dédié à "vacation" avec * comme mot de passe ainsi que son espace de travail # groupadd -r -g 30000 vacation # useradd -g vacation -u 30000 vacation -d /var/spool/vacation -m -s /sbin/nologin On copie dedans le script vacation.pl # cp /var/www/roundcubemail/plugins/vacation/extra/virtual_vacation/vacation.pl /var/spool/vacation/vacation.pl Et on donne les bons droits # chown -R vacation:vacation /var/spool/vacation/ && chmod 700 /var/spool/vacation/vacation.pl ouvrez le ficher vacation.pl pour le paramétrer # vi /var/spool/vacation/vacation.pl et renseignez les variables comprises entre # =========== begin configuration =========== our $db_type = 'mysql'; # leave empty for connection via UNIX socket our $db_host = 'localhost'; # connection details our $db_username = postfixadmin; our $db_password = mon-password; our $db_name = postfix; our $vacation_domain = 'autoreply.mon-domaine'; # smtp server used to send vacation e-mails our $smtp_server = 'localhost'; our $smtp_server_port = 25; # path to logfile, when empty logging is supressed # change to e.g. /dev/null if you want nothing logged. # if we can't write to this, and $log_to_file is 1 (below) the script will abort. our $logfile='/var/log/vacation.log'; # 2 = debug + info, 1 = info only, 0 = error only our $log_level = 2; # Whether to log to file or not, 0 = do not write to a log file our $log_to_file = 1; # =========== end configuration =========== créer le fichier : **/var/www/postfixadmin/vacation.conf** et intégrer les variables d’'accès à la base de données $db_type = 'mysql'; $db_host = 'localhost'; $db_username = 'postfixadmin'; $db_password = 'mon-password'; $db_name = 'postfix'; Maintenant, nous allons relier tout ce beau monde. Ici on ne s'occupe que du driver "virtuel" Faites une copie de sauvegarde du fichier de configuration # cp /var/www/roudcubemail/plugins/vacation/config.ini /var/www/roudcubemail/plugins/vacation/config.ini.sos ouvrez le # vi /var/www/roudcubemail/plugins/vacation/config.ini commentez toutes les lignes, et rajoutez à la fin les lignes suivantes [default] driver = "virtual" subject = "Default subject" body = "default.txt" transport = "autoreply.mon-domaine" dbase = "postfix" always_keep_message = true dsn = "mysql://postfixadmin:mon-password@localhost/postfix" select_query = "SELECT goto FROM %m.alias WHERE address='%e' AND goto='%g'" insert_query = "INSERT INTO %m.alias (domain,address,goto) VALUES ('%i','%e','%g')" delete_query = "DELETE FROM %m.alias WHERE address='%e'" ====== Mise à jour de postfix ====== Passons maintenant a postfix. Ouvrez le fichier **/etc/postfix/master.cf** et rajoutez la ligne suivante vacation unix - n n - - pipe flags=Rq user=vacation:vacation argv=/var/spool/vacation/vacation.pl -f ${sender} -- ${recipient} Allez dans le répertoire /etc/postfix et créez le fichier de la table transport # vi /etc/postfix/transport rajoutez dedans autoreply.mon-domaine vacation: et recréez la database : # postmap /etc/postfix/transport Ouvrez le fichier **/etc/postfix/main.cf** et rajoutez la ligne : transport_maps = hash:/etc/postfix/transport et pour éviter de recevoir les nofifications en double dans **/etc/posftix/main.cf** vacation_destination_recipient_limit = 1 Redémarrage de posftix # /etc/init.d/postfix restart La partie postfix est terminée, passons maintenant à postfixadmin ====== Mise à jour de postfixadmin ====== Ouvrez le fichier : # vi /var/www/postfixadmin/config.inc.php et modifier les variables suivantes. remplacez $CONF['vacation'] = 'NO' par $CONF['vacation'] = 'YES'; renseignez votre non de domaine $CONF['vacation_domain'] = 'autoreply.mon-domain';