~jorge/charms/precise/mysql/fix-metadata

« back to all changes in this revision

Viewing changes to formulas/mysql/hooks/install

  • Committer: Clint Byrum
  • Date: 2011-03-17 20:43:05 UTC
  • mto: This revision was merged to the branch mainline in revision 38.
  • Revision ID: clint@ubuntu.com-20110317204305-8mfbh9bto61lndcs
- adding master/slave replication
- setting default storage engine to innodb to make replication snaps faster and provide better data integrity

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/bin/bash
2
2
 
3
 
 
4
 
sudo apt-get install -qqy debconf-utils python-mysqldb uuid
5
 
 
6
 
PASSWORD=`uuid`
7
 
 
8
 
echo $PASSWORD >> /var/lib/ensemble/mysql.passwd
 
3
sudo apt-get install -qqy debconf-utils python-mysqldb uuid augeas-tools augeas-lenses
 
4
 
 
5
PASSFILE=/var/lib/ensemble/mysql.passwd 
 
6
if ! [ -f $PASSFILE ] ; then
 
7
  uuid > $PASSFILE
 
8
fi
 
9
PASSWORD=`cat $PASSFILE`
9
10
 
10
11
echo mysql-server-5.1 mysql-server/root_password password $PASSWORD | debconf-set-selections
11
12
echo mysql-server-5.1 mysql-server/root_password_again password $PASSWORD | debconf-set-selections
12
13
 
13
14
DEBIAN_FRONTEND=noninteractive apt-get -y install -qq mysql-server
14
15
 
15
 
python -c "data = open('/etc/mysql/my.cnf').read().replace('127.0.0.1', '0.0.0.0'); open('/etc/mysql/my.cnf', 'w').write(data)"
16
 
 
17
 
service mysql restart
 
16
unit_id=`echo $ENSEMBLE_UNIT_NAME | cut -d/ -f2`
 
17
 
 
18
# augeas 0.8.0 and later knows about my.cnf format .. otherwise use ours
 
19
augvers=`dpkg -l augeas-lenses|awk '/^ii/ {print $3}'`
 
20
if dpkg --compare-versions $augvers '<' 0.8.0 || \
 
21
  ! [ -f /usr/share/augeas/dist/mysql.aug ] ; then
 
22
  echo augeas $augvers needs mysql.aug and inifile.aug file from formula...
 
23
  mv -f /usr/share/augeas/lenses/dist/inifile.aug /var/backups
 
24
  cp -v `dirname $0`/../inifile.aug /usr/share/augeas/lenses/dist
 
25
  cp -v `dirname $0`/../mysql.aug /usr/share/augeas/lenses/dist
 
26
else
 
27
  echo using mysql.aug from $augvers
 
28
fi
 
29
augtool <<EOF
 
30
defnode mysqld '/files/etc/mysql/my.cnf/target[. = "mysqld"]'
 
31
set \$mysqld/server_id $unit_id
 
32
set \$mysqld/log_bin /var/log/mysql/mysql-bin.log
 
33
set \$mysqld/default_storage_engine InnoDB
 
34
save
 
35
EOF
 
36
 
 
37
service mysql stop || :
 
38
service mysql start