1 | #!/bin/bash |
---|
2 | #(C)DatuX |
---|
3 | |
---|
4 | #update ld.so.conf paths |
---|
5 | if ! grep /usr/lib/mysql /etc/ld.so.conf; then |
---|
6 | echo /usr/lib/mysql >> /etc/ld.so.conf || exit 1 |
---|
7 | ldconfig |
---|
8 | fi |
---|
9 | |
---|
10 | svcstop /service/mysql || exit 1 |
---|
11 | |
---|
12 | #update config file |
---|
13 | mv /etc/my.cnf.new /etc/my.cnf |
---|
14 | |
---|
15 | #still uses old ib_logfile-size? |
---|
16 | if [ `stat -c %s /home/system/mysql5/ib_logfile0` -lt 60000000 ]; then |
---|
17 | mv /home/system/mysql5/ib_logfile0 /home/system/mysql5/ib_logfile0.old |
---|
18 | mv /home/system/mysql5/ib_logfile1 /home/system/mysql5/ib_logfile1.old |
---|
19 | fi |
---|
20 | |
---|
21 | #no mysql 5.x database yet? |
---|
22 | if [ ! -d /home/system/mysql5/mysql ]; then |
---|
23 | touch /etc/my.passwd |
---|
24 | #convert mysql4 database? |
---|
25 | #WARNING: you cant convert from 4.1 to 5.1 directly, you first need to upgrade from 4.1 to 5.0! |
---|
26 | if [ -d /home/system/mysql ]; then |
---|
27 | echo "* Converting mysql 4 database to 5.0:" |
---|
28 | svcstop /service/mysql || exit 1 |
---|
29 | |
---|
30 | #the database can be huge, so make sure nothing bad happens if cp gets aborted: |
---|
31 | rm -r /home/system/mysql5.tmp &>/dev/null |
---|
32 | cp -a /home/system/mysql /home/system/mysql5.tmp || exit 1 |
---|
33 | mv /home/system/mysql5.tmp /home/system/mysql5 || exit 1 |
---|
34 | |
---|
35 | #we need to run the database to update it |
---|
36 | svcstart /service/mysql || exit 1 |
---|
37 | mysql_upgrade --password=`cat /etc/my.passwd` || exit 1 |
---|
38 | |
---|
39 | #a restart is recommended after upgrading |
---|
40 | svcstop /service/mysql |
---|
41 | |
---|
42 | else |
---|
43 | #create new empty database |
---|
44 | svcstop /service/mysql || exit 1 |
---|
45 | mkdir -p /home/system/mysql5 || exit 1 |
---|
46 | chown mysql:mysql /home/system/mysql5 || exit 1 |
---|
47 | chmod 750 /home/system/mysql5 || exit 1 |
---|
48 | su mysql -c "mysql_install_db --force" || exit 1 |
---|
49 | fi |
---|
50 | |
---|
51 | #fix the root password and other stuff if neccesary on the new/converted database: |
---|
52 | syn3-mysqlfix || exit 1 |
---|
53 | #database exists, upgrade it: |
---|
54 | else |
---|
55 | echo "* Running mysql database upgrade:" |
---|
56 | #run a 'regular' upgrade on any existing database |
---|
57 | svcstart /service/mysql || exit 1 |
---|
58 | mysql_upgrade --password=`cat /etc/my.passwd` |
---|
59 | #a restart is recommended after upgrading |
---|
60 | svcstop /service/mysql |
---|
61 | |
---|
62 | fi |
---|
63 | |
---|
64 | svcreset /service/mysql || exit 1 |
---|