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/dovecot.conf etc/dovecot/dovecot-sql.conf etc/dovecot/dovecot-dict-quota.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$/php\1/' | tail -1`"
283 ln -fs /etc/alternc/alternc.ini /etc/$php/apache2/conf.d/alternc.ini || true
284 ln -fs /etc/alternc/alternc.ini /etc/$php/cli/conf.d/alternc.ini || true
285 if [ -x /usr/sbin/apache2 ]; then
287 run-parts --arg=apache2 /usr/lib/alternc/install.d
290 # unused from AlternC 1.0, FIXME: remove it later
291 if [ -L /etc/apache2/mods-enabled/vhost_alias.load ]
296 if ! [ -L /etc/apache2/mods-enabled/$php.load ]
300 if ! [ -L /etc/apache2/mods-enabled/rewrite.load ]
304 if [ -e /etc/alternc/apache.pem ]; then
305 # We enable proftpd tls module
306 cat /etc/proftpd/modules.conf | sed -e 's/^#LoadModule mod_tls.c/LoadModule mod_tls.c/' > /etc/proftpd/modules.conf.alternc-new
307 mv /etc/proftpd/modules.conf.alternc-new /etc/proftpd/modules.conf
308 cp /etc/proftpd/modules.conf /etc/alternc/templates/proftpd/
309 # We enable apache2 SSL :
310 if [ ! -L /etc/apache2/mods-enabled/ssl.load ] ; then
314 if [ ! -h /etc/apache2/conf.d/alternc-ssl.conf ] && [ -e /etc/apache2/conf.d/ ]; then
315 ln -sf /etc/alternc/apache2-ssl.conf /etc/apache2/conf.d/alternc-ssl.conf
319 # We enable dovecot SSL certificate instructions: (on wheezy we should use a new file in /etc/dovecot/conf.d/ )
320 sed -i -e 's#^ssl_cert_file.*$#ssl_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem#' -e 's#^ssl_key_file.*$#ssl_key_file = /etc/ssl/private/ssl-cert-snakeoil.key#' /etc/dovecot/dovecot.conf
323 # We disable proftpd tls module
324 cat /etc/proftpd/modules.conf | sed -e 's/^LoadModule mod_tls.c/#LoadModule mod_tls.c/' > /etc/proftpd/modules.conf.alternc-new
325 mv /etc/proftpd/modules.conf.alternc-new /etc/proftpd/modules.conf
326 cp /etc/proftpd/modules.conf /etc/alternc/templates/proftpd/
328 # We disable dovecot SSL certificate instructions: (on wheezy we should remove a file in /etc/dovecot/conf.d/ )
329 sed -i -e 's#^ssl_cert_file.*$#ssl_cert_file = /etc/ssl/certs/ssl-cert-snakeoil.pem#' -e 's#^ssl_key_file.*$#ssl_key_file = /etc/ssl/private/ssl-cert-snakeoil.key#' /etc/dovecot/dovecot.conf
331 echo "SSL not configured"
332 echo "create a certificate in /etc/alternc/apache.pem and rerun alternc.install"
334 if [ ! -h /etc/apache2/conf.d/alternc.conf ] && [ -e /etc/apache2/conf.d/ ]; then
335 ln -sf /etc/alternc/apache2.conf /etc/apache2/conf.d/alternc.conf
338 if [ -e /etc/apache2/sites-enabled/000-default ]; then
342 SERVICES="$SERVICES $s"
345 # Manage sudoers.d include appearing in Squeeze:
346 # if the "includedir" is not here, we add it ONLY IF visudo -c is happy.
347 if ! grep -q "#includedir */etc/sudoers.d" /etc/sudoers ; then
348 if ! cat /etc/sudoers.d/* | visudo -c -f - >/dev/null ; then
349 echo -e "\033[31m**********************************************"
351 echo "* ALTERNC ACTION REQUESTED *"
353 echo "* SUDO is NOT configured properly *"
354 echo "* check your files in /etc/sudoers.d ! *"
355 echo "* then launch alternc.install again *"
357 echo "**********************************************"
361 echo "#includedir */etc/sudoers.d" >>/etc/sudoers
365 # Copy postfix *_checks if they do not exist
366 for file in body_checks header_checks; do
367 if [ ! -e "/etc/postfix/$file" ]; then
368 cp /usr/share/alternc/install/$file /etc/postfix
372 # Attribute the correct rights to critical postfix files
373 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
374 chown root:postfix /etc/postfix/my*
375 chmod 640 /etc/postfix/my*
378 if [ ! -f /etc/postfix/main.cf ]
380 echo -e "\033[31m**********************************************"
382 echo "* ALTERNC ACTION REQUESTED *"
384 echo "* POSTFIX is NOT configured properly *"
385 echo "* launch dpkg-reconfigure -plow postfix *"
386 echo "* and choose 'Internet Site' *"
387 echo "* then launch alternc.install again *"
389 echo "**********************************************"
394 # configure Postfix appropriatly for our needs
395 if [ "$slave" = "1" ]; then
396 postfix_conf=/etc/alternc/postfix/postfix-slave.cf
398 postfix_conf=/etc/alternc/postfix/postfix.cf
400 grep -v '^\ *#' $postfix_conf |while read line ; do
401 if echo "$line" | grep -qi '^smtpd_tls_dcert_file' ;then
402 line_strip=`echo "$line"|tr -d '[:blank:]'`
404 cert_file=${line_strip#$pattern}
408 if [ -e $cert_file ];then
411 echo -e "\033[31m*****************************************************"
412 echo "* The certificate file : $cert_file does not exists *"
413 echo "* If you want to be able to use SSL/TLS *"
414 echo "* please go to https://alternc.com/SSL *"
415 echo "* to get information on how to create a certificate *"
416 echo "* Finally relaunch alternc.install *"
417 echo "*****************************************************"
425 # Conviguring delivery used by Postfix
426 /usr/lib/alternc/alternc_add_policy_dovecot
428 # Bug #1215: configure mydestination when $FQDN is not in
429 OLDDESTINATION=`postconf mydestination | awk -F '=' '{print $2}'`
430 echo "$OLDDESTINATION" | grep -q -v "$FQDN" && postconf -e "mydestination = $FQDN, $OLDDESTINATION"
432 # Remove phpmyadmin apache2 configuration
433 rm -f /etc/apache2/conf.d/phpmyadmin.conf || true
435 # Configure PHPMyAdmin
436 include_str='include("/etc/alternc/phpmyadmin.inc.php")'
437 pma_config='/etc/phpmyadmin/config.inc.php'
439 # Sur une configuration vierge, inclure la configuration alternc
440 if ! grep -e "${include_str/\"/\\\"}" $pma_config > /dev/null 2>&1; then
441 echo "$include_str;" >> $pma_config
444 # Le template de /etc/alternc/phpmyadmin.inc.php viens d'être réappliqué, on
445 # regénére la liste des serveurs MySQL disponible dedans.
446 mysql_query "select id,host,name from db_servers;" | while read id host name ; do
448 // Server #$id in db_servers
450 \$cfg['Servers'][\$i]['connect_type'] = 'tcp'; // How to connect to MySQL server ('tcp' or 'socket')
451 \$cfg['Servers'][\$i]['auth_type'] = 'cookie'; // Authentication method (config, http or cookie based)?
452 \$cfg['Servers'][\$i]['hide_db'] = 'information_schema';
453 \$cfg['Servers'][\$i]['verbose'] = '$name'; // human name
454 \$cfg['Servers'][\$i]['host'] = '$host'; // MySQL hostname or IP address
455 " >> '/etc/alternc/phpmyadmin.inc.php'
458 # Reload incron. Useless, but who know?
459 SERVICES="$SERVICES incron"
461 if [ -e /etc/proftpd.conf ] ; then
462 chmod 640 /etc/proftpd/proftpd.conf
465 if [ -x /usr/sbin/locale-gen ] ; then
466 touch /etc/locale.gen
468 # Add de_DE ISO-8859-1, en_US ISO-8859-1, es_ES ISO-8859-1, fr_FR ISO-8859-1 to the locales :
469 if ! grep -q "^de_DE ISO-8859-1$" /etc/locale.gen ; then
470 echo "de_DE ISO-8859-1" >>/etc/locale.gen
473 if ! grep -q "^en_US ISO-8859-1$" /etc/locale.gen ; then
474 echo "en_US ISO-8859-1" >>/etc/locale.gen
477 if ! grep -q "^es_ES ISO-8859-1$" /etc/locale.gen ; then
478 echo "es_ES ISO-8859-1" >>/etc/locale.gen
481 if ! grep -q "^fr_FR ISO-8859-1$" /etc/locale.gen ; then
482 echo "fr_FR ISO-8859-1" >>/etc/locale.gen
485 if ! grep -q "^de_DE.UTF-8 UTF-8$" /etc/locale.gen ; then
486 echo "de_DE.UTF-8 UTF-8" >>/etc/locale.gen
489 if ! grep -q "^fr_FR.UTF-8 UTF-8$" /etc/locale.gen ; then
490 echo "fr_FR.UTF-8 UTF-8" >>/etc/locale.gen
493 if ! grep -q "^es_ES.UTF-8 UTF-8$" /etc/locale.gen ; then
494 echo "es_ES.UTF-8 UTF-8" >>/etc/locale.gen
497 if ! grep -q "^en_US.UTF-8 UTF-8$" /etc/locale.gen ; then
498 echo "en_US.UTF-8 UTF-8" >>/etc/locale.gen
501 if ! grep -q "^it_IT.UTF-8 UTF-8$" /etc/locale.gen ; then
502 echo "it_IT.UTF-8 UTF-8" >>/etc/locale.gen
505 if ! grep -q "^nl_NL.UTF-8 UTF-8$" /etc/locale.gen ; then
506 echo "nl_NL.UTF-8 UTF-8" >>/etc/locale.gen
509 if [ "$LOCALECHANGED" ] ; then
514 # remaining steps are only for the master
515 if [ "$slave" = "1" ]; then
519 #######################################################################
520 # populate alternc database with the mailname used by postfix to send mail for each vhost
522 # If mailname does not exist, create it. Fix #1495
523 test -e "/etc/mailname" || hostname -f > "/etc/mailname"
524 # Allow for all the users to view /etc/mailname
525 chmod +r "/etc/mailname"
527 #######################################################################
528 # Save installed files to check them during next install
530 tar -zcf "$INSTALLED_CONFIG_TAR" -C / $CONFIG_FILES
532 #######################################################################
536 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 {} \;
539 if [ ! -e "/var/log/alternc/bureau.log" ]; then
540 test -d "/var/log/alternc/" || mkdir -p "/var/log/alternc/"
541 touch "/var/log/alternc/bureau.log"
544 if [ ! -e "/var/log/alternc/update_domains.log" ]; then
545 test -d "/var/log/alternc/" || mkdir -p "/var/log/alternc/"
546 touch "/var/log/alternc/update_domains.log"
549 # Be sure of the owner of the logs files
550 chmod 640 /var/log/alternc/bureau.log /var/log/alternc/update_domains.log
551 chown alterncpanel:adm /var/log/alternc/bureau.log /var/log/alternc/update_domains.log
553 # Creating admin user if needed
554 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`
556 if [ "$HAS_ROOT" != "1" ]; then
557 echo "Creating admin user..."
560 if su - alterncpanel -s /bin/bash -c /usr/share/alternc/install/newone.php
562 echo "*******************************************"
564 echo "* Admin account *"
565 echo "* ------------ *"
567 echo "* user: admin password: admin *"
569 echo "* Please change this as soon as possible! *"
571 echo "*******************************************"
573 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."
576 ##UPDATE default db_server following /etc/alternc/my.cnf values
577 if [ "$MYSQL_HOST" == "localhost" ]; then
578 MYSQL_HOST_CLIENT="localhost"
580 MYSQL_HOST_CLIENT="%"
582 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';"
585 #giving vmail user read access on dovecot sql file
586 chgrp vmail /etc/dovecot/dovecot.conf
587 chmod g+r /etc/dovecot/dovecot.conf
589 # We force the re-computing of the DNS zones, since we may have changed the IP address (see #460)
590 /usr/bin/mysql --defaults-file="/etc/alternc/my.cnf" -B -e "update domaines set dns_action='UPDATE' WHERE gesdns=1;"
592 # We ensure localhost is trusted to opendkim
593 mkdir -p "/etc/opendkim/keys"
594 touch /etc/opendkim/TrustedHosts /etc/opendkim/SigningTable /etc/opendkim/KeyTable
595 grep -q "^127.0.0.1\$" /etc/opendkim/TrustedHosts || echo "127.0.0.1" >>/etc/opendkim/TrustedHosts
596 grep -q "^localhost\$" /etc/opendkim/TrustedHosts || echo "localhost" >>/etc/opendkim/TrustedHosts
597 grep -q "^$PUBLIC_IP\$" /etc/opendkim/TrustedHosts || echo "$PUBLIC_IP" >>/etc/opendkim/TrustedHosts
598 if [ "$(lsb_release -s -c)" == 'stretch' ] ; then
599 /lib/opendkim/opendkim.service.generate
600 # Without adding '-u opendkim' after the service file is generated, opendkim
601 # will run as root, which we do not want.
602 if [ "$(grep -c 'u opendkim' /etc/systemd/system/opendkim.service.d/override.conf)" == 0 ] ; then
603 sed -i -e 's/inet:8891@127.0.0.1/& -u opendkim/' /etc/systemd/system/opendkim.service.d/override.conf
605 systemctl daemon-reload
608 # Add opendkim to service to restart
609 SERVICES="$SERVICES opendkim"
612 run-parts --arg=before-reload /usr/lib/alternc/install.d
614 #######################################################################
617 for service in postfix bind9 apache2 dovecot cron proftpd ; do
618 invoke-rc.d $service force-reload || true
621 # We should restart apaches after all configuration stuff ...
622 for service in $SERVICES; do
623 test -x /etc/init.d/$service && invoke-rc.d $service stop || true
625 for service in $SERVICES; do
626 test -x /etc/init.d/$service && invoke-rc.d $service start || true
629 echo "Fix all the permission. May be quite long..."
630 echo "YOU CAN INTERUPT THIS BY USING Ctrl-c THEN y TO BYPASS THE ERROR."
631 /usr/lib/alternc/fixperms.sh
632 echo "Compile PO files"
634 # TODO : includes the .MO in debian package ;)
635 find /usr/share/alternc/panel/locales -maxdepth 1 -mindepth 1 -type d -name "*_*" | while read A
639 rm -f alternc.mo alternc.po
640 msgcat --use-first *.po alternc >alternc.po
641 msgfmt alternc.po -o alternc.mo
645 # Fix phpmyadmin import trac#1557
646 test -d "/var/lib/phpmyadmin/tmp" && dpkg-statoverride --update --add www-data alterncpanel 0775 "/var/lib/phpmyadmin/tmp" 2>/dev/null || true
647 test -f "/etc/phpmyadmin/config-db.php" && dpkg-statoverride --update --add www-data alterncpanel 0644 "/etc/phpmyadmin/config-db.php" 2>/dev/null || true
650 run-parts --arg=end /usr/lib/alternc/install.d
655 # Rebuild all web configuration
656 /usr/lib/alternc/rebuild_all_webconf.sh --force