source: trunk/install/alternc.install @ 889

Revision 889, 7.3 KB checked in by anarcat, 7 years ago (diff)

refaire le commit 1.12 du CVS sur mysql.sh. ce patch a été perdu dans
la migration. ceci n'est pas exactement le patch original, par contre,
mais est dans le meme esprit.

on retire en meme temps les manips de socket pour postfix et on met
127.0.0.1 comme MYSQL_HOST par defaut

Le log se lisait comme suit:

enlever le code qui installe, gère et manipule les bases de données
mysql de façon locale, sur /var/alternc/db.

mysql revient donc où il veut bien, et alternc lui parle seulement par
son socket, réseau ou autre. ceci ne devrait pas briser les install
existants ni les futurs, car la config de mysql reste et si
/var/alternc/db est configuré comme db, il va le rester.

ce qui part, par contre, c'est les DBs sous la gestion des quotas. mais
c'est une bonne chose, ça, parce que mysql réagit très mal à un
overquota sur une de ses tables.

Line 
1#!/bin/sh
2#
3# AlternC Main install script.
4# This script should be launched only once, when installing AlternC
5# on a new server. THIS SCRIPT ERASE ALL DATA ON THE AlternC SYSTEM !!
6# YOU HAVE BEEN WARNED !
7
8set -e
9
10#######################################################################
11# Script configuration
12#
13
14# Configuration template location
15TEMPLATE_DIR="/etc/alternc/templates"
16
17# Find needed configuration files (without the initial '/')
18CONFIG_FILES=""
19
20if [ -x /etc/init.d/apache ]; then
21    CONFIG_FILES="$CONFIG_FILES etc/apache/httpd.conf etc/php4/apache/php.ini"
22fi
23if [ -x /etc/init.d/apache-ssl ]; then
24    CONFIG_FILES="$CONFIG_FILES etc/apache-ssl/httpd.conf"
25fi
26if [ -x /usr/bin/php4-cgi ]; then
27    CONFIG_FILES="$CONFIG_FILES etc/php4/cgi/php.ini"
28fi
29if [ -x /etc/init.d/bind9 ]; then
30    CONFIG_FILES="$CONFIG_FILES etc/bind/templates/zone.template
31                  etc/bind/templates/named.template etc/bind/named.conf"
32fi
33if [ -x /etc/init.d/courier-pop ]; then
34    CONFIG_FILES="$CONFIG_FILES etc/courier/authdaemonrc
35                  etc/courier/authmysqlrc"
36fi
37if [ -x /etc/init.d/postfix ]; then
38    CONFIG_FILES="$CONFIG_FILES etc/postfix/main.cf etc/postfix/myalias.cf
39                  etc/postfix/mydomain.cf etc/postfix/mygid.cf
40                  etc/postfix/myvirtual.cf etc/postfix/sasl/smtpd.conf"
41fi
42if [ -x /etc/init.d/proftpd ]; then
43    CONFIG_FILES="$CONFIG_FILES etc/proftpd.conf etc/welcome.msg"
44fi
45if [ -d /usr/share/squirrelmail ]; then
46    CONFIG_FILES="$CONFIG_FILES etc/squirrelmail/apache.conf"
47fi
48
49if [ -x /usr/sbin/saslauthd ]; then
50    CONFIG_FILES="$CONFIG_FILES etc/default/saslauthd"
51fi
52
53INSTALLED_CONFIG_TAR="/var/backups/alternc/etc-installed.tar.gz"
54
55#######################################################################
56# Look for modified configuration files
57#
58if [ -f "$INSTALLED_CONFIG_TAR" ]; then
59    CHANGED="`tar -zdf "$INSTALLED_CONFIG_TAR" -C / 2> /dev/null |
60              sed -e 's/^\([^:]*\).*/    \1/' | sort -u`"
61    if [ ! -z "$CHANGED" ]; then
62        echo "The following configuration files has changed since last AlternC"
63        echo "installation :"
64        echo "$CHANGED"
65        echo ""
66        if [ "$1" = "force" ]; then
67            echo "Replacing them as you requested."
68        else
69            echo "These configuration files should normally be modified by"
70            echo "changing the template in $TEMPLATE_DIR and then calling"
71            echo "$0 to perform the update."
72            echo ""
73            echo "Please examine the situation closely and call '$0 force'"
74            echo "if you still want to actually overwrite these files."
75            exit 1
76        fi
77    fi
78fi
79
80#######################################################################
81# Prepare template expansions
82#
83
84. /etc/alternc/local.sh
85
86WARNING="WARNING: Do not edit this file, edit the one in /etc/alternc/templates and launch alternc.install again."
87
88VERSION="`dpkg -s alternc | sed -n -e 's/^Version: \(.*\)/\1/p'`"
89
90# /var/alternc/dns/d/www.example.com
91FQDN_LETTER="`echo $FQDN | sed -e 's/.*\.\([^\.]\)[^\.]*\.[^\.]*$/\1/'`"
92if [ "$FQDN_LETTER" = "$FQDN" ] 
93then
94       FQDN_LETTER="_" 
95fi
96
97NS2_IP=`perl -e "\\$h = (gethostbyname(\"$NS2_HOSTNAME\"))[4];
98                 @ip = unpack('C4', \\$h);
99                 print join (\".\", @ip);"`
100
101if [ ! -z "$BIND_INTERNAL" ]; then
102    BIND_INTERNAL="$BIND_INTERNAL;"
103fi
104
105if [ -z "$MONITOR_IP" ]; then
106    MONITOR_IP="127.0.0.1"
107fi
108
109SED_SCRIPT="
110s\\%%hosting%%\\$HOSTING\\;
111s\\%%fqdn%%\\$FQDN\\;
112s\\%%public_ip%%\\$PUBLIC_IP\\;
113s\\%%internal_ip%%\\$INTERNAL_IP\\;
114s\\%%monitor_ip%%\\$MONITOR_IP\\;
115s\\%%ns1%%\\$NS1_HOSTNAME\\;
116s\\%%ns2%%\\$NS2_HOSTNAME\\;
117s\\%%bind_internal%%\\$BIND_INTERNAL\\;
118s\\%%mx%%\\$DEFAULT_MX\\;
119s\\%%dbhost%%\\$MYSQL_HOST\\;
120s\\%%dbname%%\\$MYSQL_DATABASE\\;
121s\\%%dbuser%%\\$MYSQL_USER\\;
122s\\%%dbpwd%%\\$MYSQL_PASS\\;
123s\\%%ALTERNC_LOC%%\\$ALTERNC_LOC\\;
124s\\%%mynetwork%%\\$SMTP_RELAY_NETWORKS\\;
125s\\%%warning_message%%\\$WARNING\\;
126s\\%%fqdn_lettre%%\\$FQDN_LETTER\\;
127s\\%%version%%\\$VERSION\\;
128s\\%%ns2_ip%%\\$NS2_IP\\;
129"
130
131#######################################################################
132# Backup configuration files
133#
134BACKUP_FILE="/var/backups/alternc/etc-original-`date +%Y%m%d-%H%M`.tar.gz"
135
136# Only backup what we are really going to replace
137BACKUPS=""
138for file in $CONFIG_FILES; do
139    TEMPLATE="$TEMPLATE_DIR/${file##etc/}"
140    if [ -f "$TEMPLATE" ]; then
141        BACKUPS="$BACKUPS $file"
142    fi
143done
144
145tar -zcf "$BACKUP_FILE" -C / $BACKUPS 2>/dev/null || true
146
147#######################################################################
148# Expand templates in the right place
149#
150for file in $CONFIG_FILES; do
151    TEMPLATE="$TEMPLATE_DIR/${file##etc/}"
152    if [ -f "$TEMPLATE" ]; then
153        sed -e "$SED_SCRIPT" < $TEMPLATE > /$file
154    fi
155done
156
157#######################################################################
158# Save installed files to check them during next install
159#
160tar -zcf "$INSTALLED_CONFIG_TAR" -C / $CONFIG_FILES
161
162######################################################################
163# Initialize database
164#
165if [ -x /etc/init.d/mysql ]; then
166    echo "Setup MySQL and database..."
167    /usr/share/alternc/install/mysql.sh "$MYSQL_USER" "$MYSQL_PASS" "$MYSQL_DATABASE"
168fi
169
170########################################################################
171# Ad-hoc fixes
172#
173# Add access to the management panel
174ln -nsf /var/alternc/bureau /var/alternc/dns/$FQDN_LETTER/$FQDN
175
176# Update l18n files
177/usr/share/alternc/install/dopo.sh
178
179# Bind stuff
180touch /var/alternc/bind/automatic.conf /var/alternc/bind/slaveip.conf
181chown root:bind /var/alternc/bind/automatic.conf /var/alternc/bind/slaveip.conf
182chmod 640 /var/alternc/bind/automatic.conf /var/alternc/bind/slaveip.conf
183touch /var/run/alternc/refresh_slave
184/usr/lib/alternc/slave_dns
185
186# Apache will not start without this file
187touch /var/alternc/apacheconf/override_php.conf
188
189# Copy postfix *_checks if they do not exist
190for file in body_checks header_checks; do
191    if [ ! -e "/etc/postfix/$file" ]; then
192        cp /usr/share/alternc/install/$file /etc/postfix
193    fi
194done
195
196#######################################################################
197# Reload services
198#
199for service in apache apache-ssl postfix bind9 courier-authdaemon \
200               courier-imap courier-imap-ssl courier-pop courier-pop-ssl \
201               cron proftpd; do
202    test -x /etc/init.d/$service && /etc/init.d/$service force-reload || true
203done
204
205#######################################################################
206# Last touches
207#
208
209# Add basedir protection
210/usr/lib/alternc/basedir_prot.sh
211
212# Creating root user if needed
213HAS_ROOT="`mysql -h"$MYSQL_HOST" -u"$MYSQL_USER" -p"$MYSQL_PASS" "$MYSQL_DATABASE" -e "SELECT COUNT(*) FROM membres WHERE login = 'root'" | tail -1`"
214if [ "$HAS_ROOT" != "1" ]; then
215    echo "Creating root user..."
216    su - www-data -c /usr/share/alternc/install/newone.php
217    echo ""
218    echo "*******************************************"
219    echo "*                                         *"
220    echo "*               Root account              *"
221    echo "*               ------------              *"
222    echo "*                                         *"
223    echo "* user: root               password: root *"
224    echo "*                                         *"
225    echo "* Please change this as soon as possible! *"
226    echo "*                                         *"
227    echo "*******************************************"
228fi
229
Note: See TracBrowser for help on using the repository browser.