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

gcc484ntopperl-5.22
Last change on this file since c5c522c was c5c522c, checked in by Edwin Eefting <edwin@datux.nl>, 8 years ago

initial commit, transferred from cleaned syn3 svn tree

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