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 squirrelmail conf files.
23 # ----------------------------------------------------------------------
25 if [ "$1" = "templates" ]
27 echo "Installing Squirrelmail Templates ..."
28 cp -f /etc/alternc/templates/squirrelmail/avelsieve-config.php /etc/alternc/templates/squirrelmail/apache.conf /etc/squirrelmail/
31 PASSWORD="`perl -e 'print map{("a".."z","A".."Z",0..9)[int(rand(62))]}(1..10)'`"
33 # Add new variables to the sed script ...
34 SED_SCRIPT="/tmp/alternc-squirrelmail.sedscript"
35 # cf alternc.install for more explanations on this horror :
36 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`
37 . /etc/alternc/local.sh
38 # Configuration template location
39 TEMPLATE_DIR="/etc/alternc/templates"
41 cat > $SED_SCRIPT <<EOF
42 s\\%%ALTERNC_LOC%%\\$ALTERNC_LOC\\;
43 s\\%%dbhost%%\\$MYSQL_HOST\\;
44 s\\%%dbname%%\\$MYSQL_DATABASE\\;
45 s\\%%squirrelmail-login%%\\$LOGIN\\;
46 s\\%%squirrelmail-password%%\\$PASSWORD\\;
49 file="etc/squirrelmail/alternc-changepass.conf"
50 TEMPLATE="$TEMPLATE_DIR/${file##etc/}"
52 if [ -f "$TEMPLATE" ]; then
53 sed -f "$SED_SCRIPT" < $TEMPLATE > /$file
59 . /usr/lib/alternc/functions.sh
61 echo "giving write access to squirrelmail to the email password ..."
62 # now database host user and password are mysql root account values ;)
63 mysql_query "GRANT UPDATE (password) ON ${database}.address TO '${LOGIN}'@'${MYSQL_CLIENT}' IDENTIFIED BY '${PASSWORD}';"
64 mysql_query "GRANT SELECT ON ${database}.address TO '${LOGIN}'@'${MYSQL_CLIENT}';"
65 mysql_query "GRANT SELECT ON ${database}.domaines TO '${LOGIN}'@'${MYSQL_CLIENT}';"
68 echo "Setting squirrelmail domaintype"
69 mysql_query "INSERT IGNORE INTO domaines_type (name ,description ,target ,entry ,compatibility ,enable ,only_dns ,need_dns ,advanced )VALUES ('squirrelmail','Squirrelmail Webmail access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'txt', 'ALL', '0', '0', '0');"
72 echo "Migrating old webmail domaine type to squirrelmail one:"
73 # migration of the "webmail" hosts to "squirrelmail" hosts:
74 mysql_query "INSERT IGNORE INTO sub_domaines (compte, domaine, sub, valeur, type, web_action, web_result, enable) SELECT compte, domaine, sub, valeur,'squirrelmail', 'UPDATE',0, enable FROM sub_domaines WHERE type='webmail' AND web_action='OK';"
75 mysql_query "UPDATE sub_domaines SET web_action='DELETE' WHERE type='webmail' AND web_action='OK';"
78 echo "Deconfiguring javascript-common alias"
79 rm -f /etc/apache2/conf.d/javascript-common.conf
81 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