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: Main install script, launch it anytime ;)
23 # ----------------------------------------------------------------------
25 # Somes check before start operations
26 if [ `id -u` -ne 0 ]; then
27 echo "must be launched as root"
34 export force=1; shift;;
36 export slave=1; shift;;
40 echo "unknown option $i"; shift;;
44 . /usr/lib/alternc/functions.sh
50 run-parts --arg=startup /usr/lib/alternc/install.d
52 #######################################################################
53 # Script configuration
56 # Configuration template location
57 TEMPLATE_DIR="/etc/alternc/templates"
59 # Find needed configuration files (without the initial '/')
60 # replace this one unconditionnally
61 CONFIG_FILES="etc/alternc/bureau.conf etc/apache2/envvars etc/alternc/apache2.conf etc/alternc/apache_logformat.conf etc/alternc/phpmyadmin.inc.php"
63 if [ -e /etc/bind/named.conf ]; then
64 CONFIG_FILES="$CONFIG_FILES etc/bind/named.conf.options"
66 if [ -d /etc/postfix ]; then
67 CONFIG_FILES="$CONFIG_FILES etc/postfix/master.cf etc/postfix/myalias.cf etc/postfix/myrelay.cf
68 etc/postfix/mydomain.cf etc/postfix/myrelay-domain.cf etc/postfix/mymail2mail.cf etc/postfix/mygid.cf etc/postfix/myquota.cf
69 etc/postfix/myvirtual.cf etc/postfix/mytransport.cf etc/postfix/sasl/smtpd.conf
70 etc/alternc/postfix/postfix.cf etc/alternc/postfix/postfix-slave.cf
71 etc/opendkim.conf etc/default/opendkim"
73 if [ -e /etc/proftpd/proftpd.conf ]; then
74 CONFIG_FILES="$CONFIG_FILES etc/proftpd/proftpd.conf etc/proftpd/welcome.msg etc/proftpd/modules.conf"
77 if [ -e /etc/default/saslauthd ]; then
78 CONFIG_FILES="$CONFIG_FILES etc/default/saslauthd"
81 if [ -e /etc/dovecot/dovecot.conf ]; then
82 CONFIG_FILES="$CONFIG_FILES etc/dovecot/alternc-sql.conf etc/dovecot/alternc-dict-quota.conf etc/dovecot/conf.d/95_alternc.conf"
85 INSTALLED_CONFIG_TAR="/var/lib/alternc/backups/etc-installed.tar.gz"
87 #######################################################################
88 # Look for modified configuration files
90 if [ -f "$INSTALLED_CONFIG_TAR" ]; then
91 CHANGED="`env LANG=C tar -zdf "$INSTALLED_CONFIG_TAR" -C / 2> /dev/null |
92 grep -v 'postfix/main.cf' | grep -v 'Uid differs'|grep -v 'Gid differs' |grep -v 'Mode differs' |
93 sed -e 's#^\([^:]*\).*# /\1#' | sort -u`"
94 if [ ! -z "$CHANGED" ]; then
95 echo "The following configuration files has changed since last AlternC"
99 if [ "$force" = "1" ]; then
100 echo "Replacing them as you requested."
102 echo "These configuration files should normally be modified by"
103 echo "changing the template in $TEMPLATE_DIR and then calling"
104 echo "$0 to perform the update."
106 echo "Please examine the situation closely and call '$0 -f'"
107 echo "if you still want to actually overwrite these files."
113 # Upgrade the DATA and DB SCHEMA
114 /usr/share/alternc/install/upgrade_check.sh
115 # Launch upgrade of alternc modules
116 run-parts --arg=upgrade /usr/lib/alternc/install.d
119 #######################################################################
120 # Prepare template expansions
123 chown :alterncpanel /etc/alternc/local.sh
124 . /etc/alternc/local.sh
127 test -d /var/run/alternc || ( mkdir -p /var/run/alternc && chown alterncpanel:alterncpanel /var/run/alternc )
129 # Create the target directory
130 for i in "$ALTERNC_HTML" "$ALTERNC_MAIL" "$ALTERNC_LOGS" ; do
131 test -d "$i" || mkdir -p "$i"
134 for i in a b c d e f g h i j k l m n o p q r s t u v w x y z _ 0 1 2 3 4 5 6 7 8 9; do
135 test -d "$ALTERNC_HTML/$i" || ( mkdir -p "$ALTERNC_HTML/$i" && chown alterncpanel:alterncpanel "$ALTERNC_HTML/$i" && chmod 775 "$ALTERNC_HTML/$i" )
136 test -d "$ALTERNC_MAIL/$i" || ( mkdir -p "$ALTERNC_MAIL/$i" && chown vmail:vmail "$ALTERNC_MAIL/$i" && chmod 775 "$ALTERNC_MAIL/$i" )
139 find $ALTERNC_LOGS -maxdepth 1 -type d -exec chown alterncpanel:adm {} \;
140 find $ALTERNC_HTML -maxdepth 1 -type d -exec chown alterncpanel:alterncpanel {} \;
141 find $ALTERNC_MAIL -maxdepth 1 -type d -exec chown vmail:vmail {} \;
144 aclcheckfile="$ALTERNC_HTML/test-acl"
145 touch "$aclcheckfile"
146 setfacl -m u:root:rwx "$aclcheckfile" 2>/dev/null || ( echo "Error : ACL aren't activated on $ALTERNC_HTML . AlternC can't work without it." ; test -e "$aclcheckfile" && rm -f "$aclcheckfile" ; exit 2)
147 test -e "$aclcheckfile" && rm -f "$aclcheckfile"
149 # XXX: copy-paste from debian/config
150 if [ -r /etc/alternc/my.cnf ]; then
151 # make mysql configuration available as shell variables
152 # to convert from .cnf to shell syntax, we:
153 # * match only lines with "equal" in them (/=/)
154 # * remove whitespace around the = and add a left quote operator ' (;s)
155 # * add a right quote operator at the end of line (;s)
156 # * convert mysql variables into our MYSQL_ naming convention (;s)
157 # * print the result (;p)
158 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`
159 chown root:alterncpanel /etc/alternc/my.cnf
160 chmod 640 /etc/alternc/my.cnf
163 if [ -r /etc/alternc/my_mail.cnf ]; then
164 # make mysql configuration available as shell variables
165 # to convert from .cnf to shell syntax, we:
166 # * match only lines with "equal" in them (/=/)
167 # * remove whitespace around the = and add a left quote operator ' (;s)
168 # * add a right quote operator at the end of line (;s)
169 # * convert mysql variables into our MYSQL_ naming convention (;s)
170 # * print the result (;p)
171 eval `sed -n -e "/=/{s/ *= *\"\?/='/;s/\"\?\$/'/;s/host/MYSQL_HOST/;s/user/MYSQL_MAIL_USER/;s/password/MYSQL_MAIL_PASS/;s/database/MYSQL_DATABASE/;p}" /etc/alternc/my_mail.cnf`
172 chown root:alterncpanel /etc/alternc/my_mail.cnf
173 chmod 640 /etc/alternc/my_mail.cnf
176 WARNING="WARNING: Do not edit this file, edit the one in /etc/alternc/templates and launch alternc.install again."
178 if [ "$slave" = "1" ]; then
179 VERSION="`dpkg -s alternc-slave | sed -n -e 's/^Version: \(.*\)/\1/p'`"
181 VERSION="`dpkg -s alternc | sed -n -e 's/^Version: \(.*\)/\1/p'`"
184 # /var/ alternc/dns/d/www.example.com
185 FQDN_LETTER="`echo $FQDN | sed -e 's/.*\.\([^\.]\)[^\.]*\.[^\.]*$/\1/'`"
186 if [ "$FQDN_LETTER" = "$FQDN" ]
191 NS2_IP=`perl -e "\\$h = (gethostbyname(\"$NS2_HOSTNAME\"))[4];
192 @ip = unpack('C4', \\$h);
193 print join (\".\", @ip);"`
195 if [ -z "$MONITOR_IP" ]; then
196 MONITOR_IP="127.0.0.1"
199 PUBLIC_IP_BEGIN=$(echo $PUBLIC_IP|cut -c 1)
201 # Secret for PhpMyAdmin sessions
202 PHPMYADMIN_BLOWFISH="$(generate_string 24)"
204 # XXX: I assume this is secure if /tmp is sticky (+t)
205 # we should have a better way to deal with templating, of course.
206 SED_SCRIPT="/tmp/alternc.install.sedscript"
207 cat > $SED_SCRIPT <<EOF
208 s\\%%hosting%%\\$HOSTING\\;
209 s\\%%fqdn%%\\$FQDN\\;
210 s\\%%public_ip%%\\$PUBLIC_IP\\;
211 s\\%%public_ip_begin%%\\$PUBLIC_IP_BEGIN\\;
212 s\\%%internal_ip%%\\$INTERNAL_IP\\;
213 s\\%%monitor_ip%%\\$MONITOR_IP\\;
214 s\\%%ns1%%\\$NS1_HOSTNAME\\;
215 s\\%%ns2%%\\$NS2_HOSTNAME\\;
216 s\\%%mx%%\\$DEFAULT_MX\\;
217 s\\%%dbhost%%\\$MYSQL_HOST\\;
218 s\\%%dbname%%\\$MYSQL_DATABASE\\;
219 s\\%%dbuser%%\\$MYSQL_USER\\;
220 s\\%%dbpwd%%\\$MYSQL_PASS\\;
221 s\\%%db_mail_user%%\\$MYSQL_MAIL_USER\\;
222 s\\%%db_mail_pwd%%\\$MYSQL_MAIL_PASS\\;
223 s\\%%warning_message%%\\$WARNING\\;
224 s\\%%fqdn_lettre%%\\$FQDN_LETTER\\;
225 s\\%%version%%\\$VERSION\\;
226 s\\%%ns2_ip%%\\$NS2_IP\\;
227 s\\%%ALTERNC_HTML%%\\$ALTERNC_HTML\\;
228 s\\%%ALTERNC_MAIL%%\\$ALTERNC_MAIL\\;
229 s\\%%ALTERNC_LOGS%%\\$ALTERNC_LOGS\\;
230 s\\%%PHPMYADMIN_BLOWFISH%%\\$PHPMYADMIN_BLOWFISH\\;
234 test -d /usr/lib/alternc/install.d || mkdir -p /usr/lib/alternc/install.d
235 run-parts --arg=templates /usr/lib/alternc/install.d
238 ######################################################################
239 # Backup the Main database
240 DB_BACKUP="/var/lib/alternc/backups/${MYSQL_DATABASE}-db-`date +%Y%m%d-%H:%M:%S`.gz"
241 db_dump="mysqldump --defaults-file=/etc/alternc/my.cnf --add-drop-table --allow-keywords --quote-names --force --quick --add-locks --lock-tables --extended-insert ${MYSQL_DATABASE}"
242 $db_dump | /bin/gzip -c > $DB_BACKUP || echo "backup of the main database failed"
244 #######################################################################
245 # Backup configuration files
247 BACKUP_FILE="/var/lib/alternc/backups/etc-original-`date +%Y%m%d-%H%M`.tar.gz"
249 # Only backup what we are really going to replace
251 for file in $CONFIG_FILES; do
252 TEMPLATE="$TEMPLATE_DIR/${file##etc/}"
253 if [ -f "$TEMPLATE" ]; then
254 BACKUPS="$BACKUPS $file"
258 # also backup main.cf since we're doing major changes to it
259 BACKUPS="$BACKUPS etc/postfix/main.cf"
261 tar -zcf "$BACKUP_FILE" -C / $BACKUPS 2>/dev/null || true
262 chmod 600 "$BACKUP_FILE"
264 #######################################################################
265 # Expand templates in the right place
267 echo -n "Expanding variables in configuration files:"
268 for file in $CONFIG_FILES; do
269 TEMPLATE="$TEMPLATE_DIR/${file##etc/}"
271 if [ -f "$TEMPLATE" ]; then
272 sed -f "$SED_SCRIPT" < $TEMPLATE > /$file
278 ########################################################################
282 php="`ls /usr/lib/apache*/*/*php*.so | sed -e 's/^.*libphp\(.*\)\.so$/\1/' | tail -1`"
283 if [ "$php" = "7.0" ]
285 ln -fs /etc/alternc/alternc.ini /etc/php/$php/apache2/conf.d/alternc.ini || true
286 ln -fs /etc/alternc/alternc.ini /etc/php/$php/cli/conf.d/alternc.ini || true
288 ln -fs /etc/alternc/alternc.ini /etc/php$php/apache2/conf.d/alternc.ini || true
289 ln -fs /etc/alternc/alternc.ini /etc/php$php/cli/conf.d/alternc.ini || true
292 if [ -x /usr/sbin/apache2 ]; then
294 run-parts --arg=apache2 /usr/lib/alternc/install.d
298 # unused from AlternC 1.0, FIXME: remove it later
299 if [ -L /etc/apache2/mods-enabled/vhost_alias.load ]
304 if ! [ -L /etc/apache2/mods-enabled/php$php.load ]
308 if ! [ -L /etc/apache2/mods-enabled/rewrite.load ]
312 if [ -e /etc/alternc/apache.pem ]; then
313 # We enable proftpd tls module
314 cat /etc/proftpd/modules.conf | sed -e 's/^#LoadModule mod_tls.c/LoadModule mod_tls.c/' > /etc/proftpd/modules.conf.alternc-new
315 mv /etc/proftpd/modules.conf.alternc-new /etc/proftpd/modules.conf
316 cp /etc/proftpd/modules.conf /etc/alternc/templates/proftpd/
317 # We enable apache2 SSL :
318 if [ ! -L /etc/apache2/mods-enabled/ssl.load ] ; then
322 if [ ! -h /etc/apache2/conf-available/alternc-ssl.conf ] && [ -e /etc/apache2/conf-available/ ]; then
323 ln -sf /etc/alternc/apache2-ssl.conf /etc/apache2/conf-available/alternc-ssl.conf
328 # We enable dovecot SSL certificate instructions: (on wheezy we should use a new file in /etc/dovecot/conf.d/ )
329 ( echo "# Don't change this file, it will be overwriten by alternc.install. Change ssl parameters in a file named 99_ssl.conf instead" ; echo "ssl_cert = </etc/alternc/apache.pem" ; echo "ssl_key = </etc/alternc/apache.pem" ) >/etc/dovecot/conf.d/96_ssl.conf
332 # We disable proftpd tls module
333 cat /etc/proftpd/modules.conf | sed -e 's/^LoadModule mod_tls.c/#LoadModule mod_tls.c/' > /etc/proftpd/modules.conf.alternc-new
334 mv /etc/proftpd/modules.conf.alternc-new /etc/proftpd/modules.conf
335 cp /etc/proftpd/modules.conf /etc/alternc/templates/proftpd/
337 # We disable dovecot SSL certificate instructions: (on wheezy we should remove a file in /etc/dovecot/conf.d/ )
338 ( echo "# Don't change this file, it will be overwriten by alternc.install. Change ssl parameters in a file named 99_ssl.conf instead" ; echo "ssl_cert = </etc/ssl/certs/ssl-cert-snakeoil.pem" ; echo "ssl_key = </etc/ssl/private/ssl-cert-snakeoil.key" ) >/etc/dovecot/conf.d/96_ssl.conf
340 echo "SSL not configured"
341 echo "create a certificate in /etc/alternc/apache.pem and rerun alternc.install"
343 if [ ! -h /etc/apache2/conf-available/alternc.conf ] && [ -e /etc/apache2/conf-available/ ]; then
344 ln -sf /etc/alternc/apache2.conf /etc/apache2/conf-available/alternc.conf
345 a2enconf alternc.conf
348 if [ -e /etc/apache2/sites-enabled/000-default.conf ]; then
349 a2dissite 000-default
352 SERVICES="$SERVICES $s"
355 # Manage sudoers.d include appearing in Squeeze:
356 # if the "includedir" is not here, we add it ONLY IF visudo -c is happy.
357 if ! grep -q "#includedir */etc/sudoers.d" /etc/sudoers ; then
358 if ! cat /etc/sudoers.d/* | visudo -c -f - >/dev/null ; then
359 echo -e "\033[31m**********************************************"
361 echo "* ALTERNC ACTION REQUESTED *"
363 echo "* SUDO is NOT configured properly *"
364 echo "* check your files in /etc/sudoers.d ! *"
365 echo "* then launch alternc.install again *"
367 echo "**********************************************"
371 echo "#includedir */etc/sudoers.d" >>/etc/sudoers
375 # Copy postfix *_checks if they do not exist
376 for file in body_checks header_checks; do
377 if [ ! -e "/etc/postfix/$file" ]; then
378 cp /usr/share/alternc/install/$file /etc/postfix
382 # Attribute the correct rights to critical postfix files
383 if [ -e /etc/postfix/myalias.cf -o -e /etc/postfix/mydomain.cf -o -e /etc/postfix/mygid.cf -o -e /etc/postfix/myrelay-domain.sh -o -e /etc/postfix/myvirtual.cf -o -e /etc/postfix/myrelay.cf -o -e /etc/postfix/myquota.cf ]; then
384 chown root:postfix /etc/postfix/my*
385 chmod 640 /etc/postfix/my*
388 if [ ! -f /etc/postfix/main.cf ]
390 echo -e "\033[31m**********************************************"
392 echo "* ALTERNC ACTION REQUESTED *"
394 echo "* POSTFIX is NOT configured properly *"
395 echo "* launch dpkg-reconfigure -plow postfix *"
396 echo "* and choose 'Internet Site' *"
397 echo "* then launch alternc.install again *"
399 echo "**********************************************"
404 # configure Postfix appropriatly for our needs
405 if [ "$slave" = "1" ]; then
406 postfix_conf=/etc/alternc/postfix/postfix-slave.cf
408 postfix_conf=/etc/alternc/postfix/postfix.cf
410 grep -v '^\ *#' $postfix_conf |while read line ; do
411 if echo "$line" | grep -qi '^smtpd_tls_dcert_file' ;then
412 line_strip=`echo "$line"|tr -d '[:blank:]'`
414 cert_file=${line_strip#$pattern}
418 if [ -e $cert_file ];then
421 echo -e "\033[31m*****************************************************"
422 echo "* The certificate file : $cert_file does not exists *"
423 echo "* If you want to be able to use SSL/TLS *"
424 echo "* please go to https://alternc.com/SSL *"
425 echo "* to get information on how to create a certificate *"
426 echo "* Finally relaunch alternc.install *"
427 echo "*****************************************************"
435 # Conviguring delivery used by Postfix
436 /usr/lib/alternc/alternc_add_policy_dovecot
438 # Bug #1215: configure mydestination when $FQDN is not in
439 OLDDESTINATION=`postconf mydestination | awk -F '=' '{print $2}'`
440 echo "$OLDDESTINATION" | grep -q -v "$FQDN" && postconf -e "mydestination = $FQDN, $OLDDESTINATION"
442 # Remove phpmyadmin apache2 configuration
445 # Configure PHPMyAdmin
446 include_str='include("/etc/alternc/phpmyadmin.inc.php")'
447 pma_config='/etc/phpmyadmin/config.inc.php'
449 # Sur une configuration vierge, inclure la configuration alternc
450 if ! grep -e "${include_str/\"/\\\"}" $pma_config > /dev/null 2>&1; then
451 echo "$include_str;" >> $pma_config
454 # Le template de /etc/alternc/phpmyadmin.inc.php viens d'être réappliqué, on
455 # regénére la liste des serveurs MySQL disponible dedans.
456 mysql_query "select id,host,name from db_servers;" | while read id host name ; do
458 // Server #$id in db_servers
460 \$cfg['Servers'][\$i]['connect_type'] = 'tcp'; // How to connect to MySQL server ('tcp' or 'socket')
461 \$cfg['Servers'][\$i]['auth_type'] = 'cookie'; // Authentication method (config, http or cookie based)?
462 \$cfg['Servers'][\$i]['hide_db'] = 'information_schema';
463 \$cfg['Servers'][\$i]['verbose'] = '$name'; // human name
464 \$cfg['Servers'][\$i]['host'] = '$host'; // MySQL hostname or IP address
465 " >> '/etc/alternc/phpmyadmin.inc.php'
468 # Reload incron. Useless, but who know?
469 SERVICES="$SERVICES incron"
471 if [ -e /etc/proftpd.conf ] ; then
472 chmod 640 /etc/proftpd/proftpd.conf
475 if [ -x /usr/sbin/locale-gen ] ; then
476 touch /etc/locale.gen
478 # Add de_DE ISO-8859-1, en_US ISO-8859-1, es_ES ISO-8859-1, fr_FR ISO-8859-1 to the locales :
479 if ! grep -q "^de_DE ISO-8859-1$" /etc/locale.gen ; then
480 echo "de_DE ISO-8859-1" >>/etc/locale.gen
483 if ! grep -q "^en_US ISO-8859-1$" /etc/locale.gen ; then
484 echo "en_US ISO-8859-1" >>/etc/locale.gen
487 if ! grep -q "^es_ES ISO-8859-1$" /etc/locale.gen ; then
488 echo "es_ES ISO-8859-1" >>/etc/locale.gen
491 if ! grep -q "^fr_FR ISO-8859-1$" /etc/locale.gen ; then
492 echo "fr_FR ISO-8859-1" >>/etc/locale.gen
495 if ! grep -q "^de_DE.UTF-8 UTF-8$" /etc/locale.gen ; then
496 echo "de_DE.UTF-8 UTF-8" >>/etc/locale.gen
499 if ! grep -q "^fr_FR.UTF-8 UTF-8$" /etc/locale.gen ; then
500 echo "fr_FR.UTF-8 UTF-8" >>/etc/locale.gen
503 if ! grep -q "^es_ES.UTF-8 UTF-8$" /etc/locale.gen ; then
504 echo "es_ES.UTF-8 UTF-8" >>/etc/locale.gen
507 if ! grep -q "^en_US.UTF-8 UTF-8$" /etc/locale.gen ; then
508 echo "en_US.UTF-8 UTF-8" >>/etc/locale.gen
511 if ! grep -q "^it_IT.UTF-8 UTF-8$" /etc/locale.gen ; then
512 echo "it_IT.UTF-8 UTF-8" >>/etc/locale.gen
515 if ! grep -q "^nl_NL.UTF-8 UTF-8$" /etc/locale.gen ; then
516 echo "nl_NL.UTF-8 UTF-8" >>/etc/locale.gen
519 if [ "$LOCALECHANGED" ] ; then
524 # remaining steps are only for the master
525 if [ "$slave" = "1" ]; then
529 #######################################################################
530 # populate alternc database with the mailname used by postfix to send mail for each vhost
532 # If mailname does not exist, create it. Fix #1495
533 test -e "/etc/mailname" || hostname -f > "/etc/mailname"
534 # Allow for all the users to view /etc/mailname
535 chmod +r "/etc/mailname"
537 #######################################################################
538 # Save installed files to check them during next install
540 tar -zcf "$INSTALLED_CONFIG_TAR" -C / $CONFIG_FILES
542 #######################################################################
546 find $ALTERNC_HTML -maxdepth 1 -type d -exec setfacl -b -k -m d:g:alterncpanel:-wx -m d:u:alterncpanel:-wx -m u:alterncpanel:-wx -m g:alterncpanel:-wx {} \;
549 if [ ! -e "/var/log/alternc/bureau.log" ]; then
550 test -d "/var/log/alternc/" || mkdir -p "/var/log/alternc/"
551 touch "/var/log/alternc/bureau.log"
554 if [ ! -e "/var/log/alternc/update_domains.log" ]; then
555 test -d "/var/log/alternc/" || mkdir -p "/var/log/alternc/"
556 touch "/var/log/alternc/update_domains.log"
559 # Be sure of the owner of the logs files
560 chmod 640 /var/log/alternc/bureau.log /var/log/alternc/update_domains.log
561 chown alterncpanel:adm /var/log/alternc/bureau.log /var/log/alternc/update_domains.log
563 # Creating admin user if needed
564 HAS_ROOT=`mysql --defaults-file=/etc/alternc/my.cnf -e "SELECT COUNT(*) FROM membres WHERE login = 'admin' OR login = 'root' and su = 1" | tail -1`
566 if [ "$HAS_ROOT" != "1" ]; then
567 echo "Creating admin user..."
570 if su - alterncpanel -s /bin/bash -c /usr/share/alternc/install/newone.php
572 echo "*******************************************"
574 echo "* Admin account *"
575 echo "* ------------ *"
577 echo "* user: admin password: admin *"
579 echo "* Please change this as soon as possible! *"
581 echo "*******************************************"
583 echo "Unable to create the first AlternC account (named 'admin'). newone.php returned $?. Check your MySQL database, PHP, and the /etc/alternc/local.sh file. Also check for any error above during install."
586 ##UPDATE default db_server following /etc/alternc/my.cnf values
587 if [ "$MYSQL_HOST" == "localhost" ]; then
588 MYSQL_HOST_CLIENT="localhost"
590 MYSQL_HOST_CLIENT="%"
592 mysql --defaults-file=/etc/alternc/my.cnf -e "UPDATE db_servers SET host='$MYSQL_HOST', login='$MYSQL_USER', password='$MYSQL_PASS', client='$MYSQL_HOST_CLIENT' WHERE name='Default';"
595 # giving vmail user read access on dovecot sql file
596 chgrp vmail /etc/dovecot/alternc-sql.conf
597 chmod g+r /etc/dovecot/alternc-sql.conf
598 # Override some dovecot 2.0 configuration that may have happened during dovecot postinst:
599 sed -i -e 's/^ *!include/#!include/' /etc/dovecot/conf.d/10-auth.conf
601 # Changing owner of web panel's files
602 chown -R alterncpanel:alterncpanel "/usr/share/alternc/panel/"
604 # We force the re-computing of the DNS zones, since we may have changed the IP address (see #460)
605 /usr/bin/mysql --defaults-file="/etc/alternc/my.cnf" -B -e "update domaines set dns_action='UPDATE' WHERE gesdns=1;"
607 # We ensure localhost is trusted to opendkim
608 mkdir -p "/etc/opendkim/keys"
609 touch /etc/opendkim/TrustedHosts /etc/opendkim/SigningTable /etc/opendkim/KeyTable
610 grep -q "^127.0.0.1\$" /etc/opendkim/TrustedHosts || echo "127.0.0.1" >>/etc/opendkim/TrustedHosts
611 grep -q "^localhost\$" /etc/opendkim/TrustedHosts || echo "localhost" >>/etc/opendkim/TrustedHosts
612 grep -q "^$PUBLIC_IP\$" /etc/opendkim/TrustedHosts || echo "$PUBLIC_IP" >>/etc/opendkim/TrustedHosts
614 # Add opendkim to service to restart
615 SERVICES="$SERVICES opendkim bind9"
618 run-parts --arg=before-reload /usr/lib/alternc/install.d
620 #######################################################################
623 for service in postfix dovecot cron proftpd ; do
624 invoke-rc.d $service force-reload || true
627 # We should restart apaches after all configuration stuff ...
628 for service in $SERVICES; do
629 test -x /etc/init.d/$service && invoke-rc.d $service stop || true
632 # on Jessie, apache2 does not stop/start properly due to "service" and "apache2ctl" having different behavior pid-file-wise
635 for service in $SERVICES; do
636 test -x /etc/init.d/$service && invoke-rc.d $service start || true
639 echo "Fix all the permission. May be quite long..."
640 echo "YOU CAN INTERUPT THIS BY USING Ctrl-c THEN y TO BYPASS THE ERROR."
641 /usr/lib/alternc/fixperms.sh
642 echo "Compile PO files"
644 # TODO : includes the .MO in debian package ;)
645 find /usr/share/alternc/panel/locales -maxdepth 1 -mindepth 1 -type d -name "*_*" | while read A
649 rm -f alternc.mo alternc.po
650 msgcat --use-first *.po alternc >alternc.po
651 msgfmt alternc.po -o alternc.mo
655 # Fix phpmyadmin import trac#1557
656 test -d "/var/lib/phpmyadmin/tmp" && dpkg-statoverride --update --add www-data alterncpanel 0775 "/var/lib/phpmyadmin/tmp" 2>/dev/null || true
657 test -f "/etc/phpmyadmin/config-db.php" && dpkg-statoverride --update --add www-data alterncpanel 0644 "/etc/phpmyadmin/config-db.php" 2>/dev/null || true
660 run-parts --arg=end /usr/lib/alternc/install.d
665 # Rebuild all web configuration
666 /usr/lib/alternc/rebuild_all_webconf.sh --force