3 # ----------------------------------------------------------------------
4 # AlternC - Web Hosting System
5 # Copyright (C) 2000-2012 by the AlternC Development Team.
7 # ----------------------------------------------------------------------
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License (GPL)
12 # as published by the Free Software Foundation; either version 2
13 # of the License, or (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # To read the license please visit http://www.gnu.org/copyleft/gpl.html
21 # ----------------------------------------------------------------------
22 # Purpose of file: Install roundcube conf files.
23 # ----------------------------------------------------------------------
25 if [ "$1" = "templates" ]
27 echo "Installing Roundcube Templates ..."
28 # cp -f /etc/alternc/templates/roundcube/avelsieve-config.php /etc/alternc/templates/roundcube/apache.conf /etc/roundcube/
29 # cp -f /etc/alternc/templates/javascript-common/javascript-common.conf /etc/javascript-common/
31 LOGIN="0000_roundcube"
32 PASSWORD="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)'`"
33 DESKEY="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..24)'`"
35 # Add new variables to the sed script ...
36 SED_SCRIPT="/tmp/alternc-roundcube.sedscript"
37 # cf alternc.install for more explanations on this horror :
38 eval `sed -n -e "/=/{s/ *= *\"\?/='/;s/\"\?\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_USER/;s/password/MYSQL_PASS/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/my.cnf`
39 . /etc/alternc/local.sh
40 # Configuration template location
41 TEMPLATE_DIR="/etc/alternc/templates"
42 CONFIG_FILES="etc/roundcube/main.inc.php etc/roundcube/plugins/password/config.inc.php etc/roundcube/plugins/managesieve/config.inc.php"
44 cat > $SED_SCRIPT <<EOF
45 s\\%%ALTERNC_LOC%%\\$ALTERNC_LOC\\;
46 s\\%%dbhost%%\\$MYSQL_HOST\\;
47 s\\%%dbname%%\\$MYSQL_DATABASE\\;
48 s\\%%roundcube-login%%\\$LOGIN\\;
49 s\\%%roundcube-password%%\\$PASSWORD\\;
50 s\\%%deskey%%\\$DESKEY\\;
52 for file in $CONFIG_FILES; do
53 TEMPLATE="$TEMPLATE_DIR/${file##etc/}"
55 if [ -f "$TEMPLATE" ]; then
56 sed -f "$SED_SCRIPT" < $TEMPLATE > /$file
64 . /usr/lib/alternc/functions.sh
66 echo "giving write access to roundcube to the email password ..."
67 # now database host user and password are mysql root account values ;)
68 mysql_query "GRANT UPDATE (password) ON ${database}.address TO '${LOGIN}'@'${MYSQL_CLIENT}' IDENTIFIED BY '${PASSWORD}';"
69 mysql_query "GRANT SELECT ON ${database}.address TO '${LOGIN}'@'${MYSQL_CLIENT}';"
70 mysql_query "GRANT SELECT ON ${database}.domaines TO '${LOGIN}'@'${MYSQL_CLIENT}';"
73 echo "Setting roundcube domaintype"
74 mysql_query "INSERT IGNORE INTO domaines_type (name ,description ,target ,entry ,compatibility ,enable ,only_dns ,need_dns ,advanced )VALUES ('roundcube','Roundcube Webmail access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'txt', 'ALL', '0', '0', '0');"
77 echo "Migrating old webmail domaine type to roundcube one:"
78 # migration of the "webmail" hosts to "roundcube" hosts:
79 mysql_query "INSERT IGNORE INTO sub_domaines (compte, domaine, sub, valeur, type, web_action, web_result, enable) SELECT compte, domaine, sub, valeur,'roundcube', 'UPDATE',0, enable FROM sub_domaines WHERE type='WEBMAIL';"
80 mysql_query "UPDATE sub_domaines SET web_action='DELETE' WHERE type='WEBMAIL';"
83 echo "Deconfiguring javascript-common alias"
84 rm -f /etc/apache2/conf.d/javascript-common.conf
86 sed -i -e "s/^Alias \/javascript/# Do not uncomment, commented by AlternC to prevent a global alias\n#Alias \/javascript/" /etc/javascript-common/javascript-common.conf