Hi all
I have scripted this installation to remove the manual aspects of the process and to verify that all files have been downloaded before the upgrade proceeds.
I just used it to update a server I am building and it showed up a coupla minor bugs (typos, doh!) that I have already fixed.
Please treat it as beta but it works for me
#!/bin/sh
clear
echo "Install script for MySQL 4.1.8"
# Info taken from posts on contribs.org by Greg Swallow & Ergin Ă–zdemir
# Written by Graeme Fleming - smeghead on January 5, 2005
cd /root
rpm -qa > rpmlist
# Only for SME 6.0.x or above
IS_SME60=pic rpmlist | grep -c SMEServer-6.0
if [ $IS_SME60 -eq 0 ]
then
echo "This installation only supports SME 6.0.x - Exiting..."
cd /root
exit
fi
# Only install over V4.0 as per MySQL site recommendation
echo "Checking for current MySQL version, needs to be V4.0.x ..."
IS_V3x=grep -c mysql-3 rpmlist
if [ $IS_V3x -ne 0 ]
then
echo ".. MySQL V3 found, please upgrade to V4.0 before installing V4.1 as recommended at
http://www.mysql.org"
cd /root
exit
fi
IS_V40=grep -c mysql-4.0 rpmlist
if [ $IS_V40 -ne 0 ]
then
# Set var for downloaded files location for this script
# create the MySQL download directory
cd /root
mkdir -p mysql4.1.8
cd mysql4.1.8
DL_DIR=/root/mysql4.1.8
echo "MySQL V4.0 found, starting the upgrade process ..." | tee $DL_DIR/install.log
echo ""
fi
echo "First, lets backup our all our databases just in case ..."
mkdir -p $DL_DIR/backup
cd $DL_DIR/backup
mysqldump --opt --all-databases > all_databases.sql | tee $DL_DIR/install.log
echo "Backup complete - located in "$DL_DIR"/backup if required"
cd ..
# Setup download source locations
MYSQL_DL=ftp://mysql.mirrored.ca/MySQL-4.1
PERL_DL=http://www.quantumlinux.com/~kevin/rpmpan/rpm
PHPMY_DL=http://mirror.contribs.org/smeserver/contribs/nightspirit
echo "Downloading MySQL V4.1 files ..."
wget -nc -nd -S $MYSQL_DL/MySQL-server-4.1.8-0.i386.rpm -a $DL_DIR/install.log
wget -nc -nd -S $MYSQL_DL/MySQL-devel-4.1.8-0.i386.rpm -a $DL_DIR/install.log
wget -nc -nd -S $MYSQL_DL/MySQL-client-4.1.8-0.i386.rpm -a $DL_DIR/install.log
wget -nc -nd -S $MYSQL_DL/MySQL-shared-compat-4.1.8-0.i386.rpm -a $DL_DIR/install.log
echo "Downloading required Perl modules ..."
wget -nc -nd -S $PERL_DL/perl-DBI-1.45-8.i386.rpm -a $DL_DIR/install.log
wget -nc -nd -S $PERL_DL/perl-DBD-mysql-2.9004-8.i386.rpm -a $DL_DIR/install.log
echo "Downloading phpmyadmin required module ..."
wget -nc -nd -S $PHPMY_DL/e-smith-phpmyadmin/e-smith-phpmyadmin-2.6.0-12.noarch.rpm -a $DL_DIR/install.log
# Test to make sure all files were downloaded correctly and none are missing before trying to run install
# Build list of files and then test against this list
# We really don't want to run this unless we have all the bits
ls -1 > dllist
if [ pic dllist | grep MySQL-server-4 | wc -l -eq 0 ]
then
echo ".. MySQL-server-4.1.8-0.i386.rpm failed to download from" $MYSQL_DL "correctly, please excute script again at a later time, or check manually for the missing file"
exit
fi
if [ pic dllist | grep MySQL-devel-4 | wc -l -eq 0 ]
then
echo ".. MySQL-devel-4.1.8-0.i386.rpm failed to download from" $MYSQL_DL "correctly, please excute script again at a later time, or check manually for the missing file"
exit
fi
if [ pic dllist | grep MySQL-client-4 | wc -l -eq 0 ]
then
echo ".. MySQL-client-4.1.8-0.i386.rpm failed to download from" $MYSQL_DL "correctly, please excute script again at a later time, or check manually for the missing file"
exit
fi
if [ pic dllist | grep MySQL-shared-compat-4 | wc -l -eq 0 ]
then
echo ".. MySQL-shared-compat-4.1.8-0.i386.rpm failed to download from" $MYSQL_DL "correctly, please excute script again at a later time, or check manually for the missing file"
exit
fi
if [ pic dllist | grep perl-DBI | wc -l -eq 0 ]
then
echo ".. perl-DBI-1.45-8.i386.rpm failed to download from" $PERL_DL "correctly, please excute script again at a later time, or check manually for the missing file"
exit
fi
if [ pic dllist | grep perl-DBD-mysql | wc -l -eq 0 ]
then
echo ".. perl-DBD-mysql-2.9004-8.i386.rpm failed to download from" $PERL_DL "correctly, please excute script again at a later time, or check manually for the missing file"
exit
fi
if [ pic dllist | grep e-smith-phpmyadmin | wc -l -eq 0 ]
then
echo ".. e-smith-phpmyadmin failed to download from" $PHPMY_DL "correctly, please excute script again at a later time, or check manually for the missing file"
exit
fi
# Remove dllist file, no longer required
rm -f dllist
echo "Downloading completed without errors, proceeding with the install ..." | tee $DL_DIR/install.log
# Install phpmyadmin - needed to find default mysql root password
echo "Installing phpmysqladmin ..."
rpm -Uvh e-smith-phpmyadmin-*.rpm
# Parsing MySQL password from phpmyadmin config file; assumes there will be no semicolon/single quote in password
echo "Extracting MySQL password from config.inc.php ..." | tee $DL_DIR/install.log
MYSQL_PW=grep \'Servers\' /opt/administration/phpmyadmin/config.inc.php | grep \'password\' | awk ' { print $3 } ' | sed "/'';/d; s/\;//g; s/'//g"
echo "MySQL password is: "$MYSQL_PW | tee $DL_DIR/install.log
# Install Perl modules
echo "Installing Perl modules ..."
rpm -Uvh perl-*.rpm
# Install MySQL 4.1 files
echo "Installing MySQL 4.1 modules ..."
service mysqld stop
rpm -Uvh MySQL-*.rpm
# Run configuration routines
echo ".. configuring MySQL 4.1 to suit SME, this will take a few moments ..."
/sbin/chkconfig --levels 2345 mysql on
# Recreate symlink to auto start MySQL on boot
rm /etc/rc.d/rc7.d/S90mysqld
ln -s /etc/rc.d/init.d/mysqld /etc/rc.d/rc7.d/S90mysqld
# Configure MySQL to allow non-local connections (other than from localhost (127.0.0.1))
/sbin/e-smith/config setprop mysqld LocalNetworkingOnly no
# MySQL 4.1.8 uses new password format, but can be used with old format passwords by invoking with the --old-passwords option
# Make a template fragment to start mysqld with option --old-passwords
mkdir -p /etc/e-smith/templates-custom/etc/my.cnf/
# Add just one line of text 'old-passwords' - without the quotes
touch /etc/e-smith/templates-custom/etc/my.cnf/010oldpasswords
echo old-passwords > /etc/e-smith/templates-custom/etc/my.cnf/010oldpasswords
chmod 644 /etc/e-smith/templates-custom/etc/my.cnf/010oldpasswords
# Update mysql config file due to template additons
/sbin/e-smith/expand-template /etc/my.cnf
# Create service symlink & start MySQL
ln -s /usr/sbin/mysqld /usr/libexec/
service mysqld start
clear
# Reconfigure databases to suit MySQL 4.1.8
echo "Converting tables to MySQL 4.1.8 format ..."
/usr/bin/mysql_fix_privilege_tables --password=$MYSQL_PW
#if you typed it in exactly it should say - done - not give you an error
echo "If an error is reported here then the MySQL table upgrade routine failed, check on contribs for help"
echo "Press Ctrl/C to abort this script and not run post upgrade events, MySQL will not work until this problem is resolved"
echo "Once the problem is resolved please execute the fix.sh script"
echo ""
echo "If no error is reported then all is ok. Press enter to run post-upgrade event and rebooting the server"
echo ""
wait
/sbin/e-smith/signal-event post-upgrade
/sbin/e-smith/signal-event reboot
HTH