source: trunk/install/mysql.sh @ 846

Revision 846, 3.3 KB checked in by olivier, 7 years ago (diff)

Correction du probleme de refus de connexion de pconnect en fin d'install

(dû à 127.0.0.1 retourné comme localhost.localdomain par defaut et non simplement localhost.

Maintenant les deux fonctionnent.)

  • Property svn:executable set to *
Line 
1#!/bin/sh -e
2#
3# $Id: mysql.sh,v 1.11 2006/01/11 22:51:28 anarcat Exp $
4# ----------------------------------------------------------------------
5# AlternC - Web Hosting System
6# Copyright (C) 2002 by the AlternC Development Team.
7# http://alternc.org/
8# ----------------------------------------------------------------------
9# Based on:
10# Valentin Lacambre's web hosting softwares: http://altern.org/
11# ----------------------------------------------------------------------
12# LICENSE
13#
14# This program is free software; you can redistribute it and/or
15# modify it under the terms of the GNU General Public License (GPL)
16# as published by the Free Software Foundation; either version 2
17# of the License, or (at your option) any later version.
18#
19# This program is distributed in the hope that it will be useful,
20# but WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22# GNU General Public License for more details.
23#
24# To read the license please visit http://www.gnu.org/copyleft/gpl.html
25# ----------------------------------------------------------------------
26# Original Author of file: Benjamin Sonntag
27# Purpose of file: Install a fresh new mysql database system
28# USAGE : "mysql.sh loginroot passroot systemdb"
29# ----------------------------------------------------------------------
30#
31rootlogin=$1
32rootpass=$2
33systemdb=$3
34
35datadir=/var/alternc/db
36
37mysql="mysql --defaults-file=/etc/mysql/debian.cnf"
38
39# move the rundir to the postfix chroot and symlink the original
40sockdir=/var/run/mysqld
41postsockdir=/var/spool/postfix/$sockdir
42mkdir -p /var/spool/postfix/var/run
43if [ ! -h $sockdir ]
44then
45    mv $sockdir $postsockdir
46    ln -s $postsockdir $sockdir
47fi
48
49mkdir -p $datadir
50echo -n "making sure we have our basic database structure in place"
51mysql_install_db --datadir=$datadir --user=mysql 2>&1 > /dev/null
52echo .
53
54# Write a temporary /etc/mysql/debian.cnf
55cp -a -f /etc/mysql/debian.cnf /etc/mysql/debian.cnf.tmp
56cat << EOF > /etc/mysql/debian.cnf
57[client]
58host     = localhost
59user     = root
60socket   = /var/run/mysqld/mysqld.sock
61EOF
62
63/etc/init.d/mysql start 2>&1 > /dev/null
64
65if ! $mysql mysql -e "SHOW TABLES" >/dev/null
66then
67    # is this an upgrade then?
68    mysql="mysql -u $rootlogin -p$rootpass" 
69    if ! $mysql mysql -e "SHOW TABLES" >/dev/null
70    then
71        echo "Can't get proper credentials, aborting"
72        exit 1
73    fi
74fi
75
76echo "Setting AlternC $systemdb system table and privileges "
77$mysql -e "CREATE DATABASE IF NOT EXISTS $systemdb;" 
78echo "Installing AlternC schema "
79$mysql $systemdb < /usr/share/alternc/install/mysql.sql
80
81echo "Granting users "
82$mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'localhost' IDENTIFIED BY '$rootpass' WITH GRANT OPTION" 
83
84myrandom=`sed -n -e '/^password/s/password = //p' < /etc/mysql/debian.cnf.tmp`
85
86$mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY '$myrandom' WITH GRANT OPTION; "
87$mysql -e "GRANT ALL PRIVILEGES ON *.* TO 'debian-sys-maint'@'localhost.localdomain' IDENTIFIED BY '$myrandom' WITH GRANT OPTION; "
88# drop the root user
89$mysql -e "REVOKE ALL ON *.* FROM 'root'@'localhost'" 
90echo .
91
92mysql -u $rootlogin -p$rootpass $systemdb -e "SHOW TABLES" >/dev/null && echo "MYSQL.SH OK!" || echo "MYSQL.SH FAILED!"
93
94# Move back original to debian.cnf
95mv /etc/mysql/debian.cnf.tmp /etc/mysql/debian.cnf
96/etc/init.d/mysql stop
Note: See TracBrowser for help on using the repository browser.