#!/bin/bash #we need some stuff done like creating the /home/system/tmp postinst.sh post.syn3_scripts || exit 1 #(C)DatuX #update ld.so.conf paths if ! grep /usr/lib/mysql /etc/ld.so.conf; then echo /usr/lib/mysql >> /etc/ld.so.conf || exit 1 ldconfig fi svcstop /service/mysql || exit 1 #update config file mv /etc/my.cnf.new /etc/my.cnf #useless testfiles from a previous package that shouldnt be there rm -rf /usr/mysql-test/ /usr/sql-bench/ &>/dev/null #its important to delete old stuff like /usr/libexec/mysqld removepkg /var/log/packages/mysql-4.1.* if ! [ -e /var/log/packages/mysql-9999-i586-9998 ]; then removepkg /var/log/packages/mysql-* /var/log/packages/mysql5-* /var/log/packages/mysql51-* /var/log/packages/mysql55-* #just to be sure, otherwise very weird errors during new database initialisation rm /usr/libexec/mysqld #prevent reinstallation 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 fi #socket run-dir mkdir -p /var/run/mysql 2>/dev/null chown mysql /var/run/mysql #no mysql 5.x database yet? if [ ! -d /home/system/mysql5/mysql ]; then touch /etc/my.passwd #convert mysql4 database? #WARNING: you cant convert from 4.1 to 5.1 directly, you first need to upgrade from 4.1 to 5.0! if [ -d /home/system/mysql ]; then echo "* Converting mysql 4 database to 5.0:" svcstop /service/mysql || exit 1 #the database can be huge, so make sure nothing bad happens if cp gets aborted: rm -r /home/system/mysql5.tmp &>/dev/null cp -a /home/system/mysql /home/system/mysql5.tmp || exit 1 mv /home/system/mysql5.tmp /home/system/mysql5 || exit 1 #we need to run the database to update it svcstart /service/mysql || exit 1 mysql_upgrade --password=`cat /etc/my.passwd` || exit 1 #a restart is recommended after upgrading svcstop /service/mysql else #create new empty database svcstop /service/mysql || exit 1 mkdir -p /home/system/mysql5 || exit 1 chown mysql:mysql /home/system/mysql5 || exit 1 chmod 750 /home/system/mysql5 || exit 1 ln -s /etc/my.cnf /usr/share/mysql/my-default.cnf 2>/dev/null su mysql -c "mysql_install_db --force --keep-my-cnf --datadir=/home/system/mysql5/ --basedir=/usr" || exit 1 fi #fix the root password and other stuff if neccesary on the new/converted database: syn3-mysqlfix || exit 1 #database exists, upgrade it: else echo "* Running mysql database upgrade:" #run a 'regular' upgrade on any existing database svcstart /service/mysql || exit 1 mysql_upgrade --password=`cat /etc/my.passwd` #a restart is recommended after upgrading svcstop /service/mysql fi # since syn3 v5 we use an option file to specify the password, do we need to create it? if ! [ -e /root/.my.cnf ]; then syn3-mysqlfix || exit 1 fi svcreset /service/mysql || exit 1