root/alternc/branches/larpoux-unstable/install/mysql.sh

Revision 846, 3.3 kB (checked in by olivier, 3 years ago)

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 #
31 rootlogin=$1
32 rootpass=$2
33 systemdb=$3
34
35 datadir=/var/alternc/db
36
37 mysql="mysql --defaults-file=/etc/mysql/debian.cnf"
38
39 # move the rundir to the postfix chroot and symlink the original
40 sockdir=/var/run/mysqld
41 postsockdir=/var/spool/postfix/$sockdir
42 mkdir -p /var/spool/postfix/var/run
43 if [ ! -h $sockdir ]
44 then
45     mv $sockdir $postsockdir
46     ln -s $postsockdir $sockdir
47 fi
48
49 mkdir -p $datadir
50 echo -n "making sure we have our basic database structure in place"
51 mysql_install_db --datadir=$datadir --user=mysql 2>&1 > /dev/null
52 echo .
53
54 # Write a temporary /etc/mysql/debian.cnf
55 cp -a -f /etc/mysql/debian.cnf /etc/mysql/debian.cnf.tmp
56 cat << EOF > /etc/mysql/debian.cnf
57 [client]
58 host     = localhost
59 user     = root
60 socket   = /var/run/mysqld/mysqld.sock
61 EOF
62
63 /etc/init.d/mysql start 2>&1 > /dev/null
64
65 if ! $mysql mysql -e "SHOW TABLES" >/dev/null
66 then
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
74 fi
75
76 echo "Setting AlternC $systemdb system table and privileges "
77 $mysql -e "CREATE DATABASE IF NOT EXISTS $systemdb;"
78 echo "Installing AlternC schema "
79 $mysql $systemdb < /usr/share/alternc/install/mysql.sql
80
81 echo "Granting users "
82 $mysql -e "GRANT ALL ON *.* TO '$rootlogin'@'localhost' IDENTIFIED BY '$rootpass' WITH GRANT OPTION"
83
84 myrandom=`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'" 
90 echo .
91
92 mysql -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
95 mv /etc/mysql/debian.cnf.tmp /etc/mysql/debian.cnf
96 /etc/init.d/mysql stop
Note: See TracBrowser for help on using the browser.