source: npl/commonservers/mysql_conf/root/etc/postinst.d/post.mysqld @ 41c9558

gcc484perl-5.22
Last change on this file since 41c9558 was 41c9558, checked in by Edwin Eefting <edwin@datux.nl>, 7 years ago

remove old mysql

  • Property mode set to 100755
File size: 2.9 KB
Line 
1#!/bin/bash
2
3#we need some stuff done like creating the /home/system/tmp
4postinst.sh post.syn3_scripts || exit 1
5
6
7#(C)DatuX
8
9#update ld.so.conf paths
10if ! grep /usr/lib/mysql /etc/ld.so.conf; then
11    echo /usr/lib/mysql >> /etc/ld.so.conf || exit 1
12    ldconfig
13fi
14
15svcstop /service/mysql || exit 1
16
17#update config file
18mv /etc/my.cnf.new /etc/my.cnf
19
20#useless testfiles from a previous package that shouldnt be there
21rm -rf /usr/mysql-test/ /usr/sql-bench/ &>/dev/null
22
23
24#its important to delete old stuff like /usr/libexec/mysqld
25removepkg /var/log/packages/mysql-4.1.*
26
27if ! [ -e /var/log/packages/mysql-9999-i586-9998 ]; then
28        removepkg /var/log/packages/mysql-* /var/log/packages/mysql5-* /var/log/packages/mysql51-* /var/log/packages/mysql55-*
29        #just to be sure, otherwise very weird errors during new database initialisation
30        rm /usr/libexec/mysqld
31        #prevent reinstallation
32        touch /var/log/packages/mysql-9999-i586-9998 /var/log/packages/mysql5-9999-i586-9999 /var/log/packages/mysql51-9999-i586-9999 /var/log/packages/mysql55-9999-i586-9999
33fi
34
35#socket run-dir
36mkdir -p /var/run/mysql 2>/dev/null
37chown mysql /var/run/mysql
38
39
40#no mysql 5.x database yet?
41if [ ! -d /home/system/mysql5/mysql ]; then
42        touch /etc/my.passwd
43        #convert mysql4 database?
44        #WARNING: you cant convert from 4.1 to 5.1 directly, you first need to upgrade from 4.1 to 5.0!
45        if [ -d /home/system/mysql ]; then
46                echo "* Converting mysql 4 database to 5.0:"
47                svcstop /service/mysql || exit 1
48
49                #the database can be huge, so make sure nothing bad happens if cp gets aborted:
50                rm -r /home/system/mysql5.tmp &>/dev/null
51                cp -a /home/system/mysql /home/system/mysql5.tmp || exit 1
52                mv /home/system/mysql5.tmp /home/system/mysql5 || exit 1
53
54                #we need to run the database to update it
55                svcstart /service/mysql || exit 1
56                mysql_upgrade --password=`cat /etc/my.passwd` || exit 1
57               
58                #a restart is recommended after upgrading
59                svcstop /service/mysql
60
61        else
62                #create new empty database
63                svcstop /service/mysql || exit 1
64                mkdir -p /home/system/mysql5 || exit 1
65                chown mysql:mysql /home/system/mysql5 || exit 1
66                chmod 750 /home/system/mysql5 || exit 1
67                ln -s /etc/my.cnf /usr/share/mysql/my-default.cnf 2>/dev/null
68                su mysql -c "mysql_install_db --force  --keep-my-cnf --datadir=/home/system/mysql5/ --basedir=/usr" || exit 1
69        fi
70
71        #fix the root password and other stuff if neccesary on the new/converted database:
72        syn3-mysqlfix || exit 1
73#database exists, upgrade it:
74else
75        echo "* Running mysql database upgrade:"
76        #run a 'regular' upgrade on any existing database
77        svcstart /service/mysql || exit 1
78        mysql_upgrade --password=`cat /etc/my.passwd`
79        #a restart is recommended after upgrading
80        svcstop /service/mysql
81
82fi
83
84# since syn3 v5 we use an option file to specify the password, do we need to create it?
85if ! [ -e /root/.my.cnf ]; then
86        syn3-mysqlfix || exit 1
87fi
88
89svcreset /service/mysql || exit 1
Note: See TracBrowser for help on using the repository browser.