summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Igo <bob@stormlogic.com>2009-06-06 19:25:52 (GMT)
committerBob Igo <bob@stormlogic.com>2009-06-06 19:25:52 (GMT)
commit4a83beff4da2f4d4cd52d63c7b3abc9e999f8fca (patch)
tree297623a95e61b8b73209614f738836c164d8a47c
parenta04843d226f76ff8dfd537352b7796064ee2dcdc (diff)
downloadlinhes_pkgbuild-4a83beff4da2f4d4cd52d63c7b3abc9e999f8fca.zip
linhes_pkgbuild-4a83beff4da2f4d4cd52d63c7b3abc9e999f8fca.tar.gz
linhes_pkgbuild-4a83beff4da2f4d4cd52d63c7b3abc9e999f8fca.tar.bz2
mysql server was not always working properly in chroot within install_db_chroot.sh
-rwxr-xr-xabs/core-testing/LinHES-config-svn/install_db_chroot.sh14
-rwxr-xr-xabs/core-testing/LinHES-config/install_db_chroot.sh130
2 files changed, 102 insertions, 42 deletions
diff --git a/abs/core-testing/LinHES-config-svn/install_db_chroot.sh b/abs/core-testing/LinHES-config-svn/install_db_chroot.sh
index f187ba8..6dcbfd5 100755
--- a/abs/core-testing/LinHES-config-svn/install_db_chroot.sh
+++ b/abs/core-testing/LinHES-config-svn/install_db_chroot.sh
@@ -11,11 +11,19 @@ echo "install_db_chroot hostname is $hostname"
. $MV_ROOT/bin/install_functions.sh
#myhost=`cat /etc/hostname`
+# Before this script is called, the mysqld that facilitated the installation is killed.
+# We need to make sure to stop and start the mysqld that will be used post-install so
+# that the database can be initialized.
+
+/etc/rc.d/mysqld stop
+/etc/rc.d/mysqld stop
+/etc/rc.d/mysqld start
+
# Put a limit on how many times we try to (re-)start MySQL
success_test() {
# parameter: number of tries to start mysqld so far
PID=`pidof -o %PPID /usr/sbin/mysqld`
- if [ -z "$PID" ]; then
+ if [ -z "$PID" ]; then # mysqld isn't running
if [ $1 -gt 3 ]; then
echo "ERROR: Failed to start MySQL server in $1 attempts."
sleep 5
@@ -24,9 +32,11 @@ success_test() {
echo "Tried $1 time(s) to start MySQL server."
return 1
fi
- else
+ else # mysqld is running
return 0
fi
+ # should never get here
+ return 1
}
mysqld_tries=0
diff --git a/abs/core-testing/LinHES-config/install_db_chroot.sh b/abs/core-testing/LinHES-config/install_db_chroot.sh
index 1a0131e..6dcbfd5 100755
--- a/abs/core-testing/LinHES-config/install_db_chroot.sh
+++ b/abs/core-testing/LinHES-config/install_db_chroot.sh
@@ -11,53 +11,103 @@ echo "install_db_chroot hostname is $hostname"
. $MV_ROOT/bin/install_functions.sh
#myhost=`cat /etc/hostname`
-#mount -t proc none /proc
-pacman --noconfirm -Sf mysql
-/etc/rc.d/mysqld
-
-status=1
-mysqlstatus=1
-while [ ! $status = 0 ]
-do
- /etc/rc.d/mysqld stop
- sleep 1
- /etc/rc.d/mysqld start
- mysqlstatus=$?
- if [ $mysqlstatus = 0 ]
- then
- mysql -e "show databases;"
- showstatus=$?
- if [ $showstatus = 0 ]
- then
- pacman --noconfirm -R mythdb-initial
- pacman --noconfirm -S mythdb-initial
- $MV_ROOT/bin/restore_default_settings.sh -c load
- DISPLAY=127.0.0.1:0 $MV_ROOT/bin/MythVantage -t restore,default_1
- $MV_ROOT/bin/restore_default_settings.sh -c restore -t syssettings
- $MV_ROOT/bin/systemconfig.sh misc,hostype,this_is_install
-
- update_db_settings HostServiceMythWEB "1"
- echo 'UseMythWEB="1"' >> /etc/systemconfig
-
- #update database to allow user jobs on this host.
- $MV_ROOT/bin/restore_default_settings.sh -c USERJOBALLOW
- $MV_ROOT/bin/restore_default_settings.sh -c ACCESSCONTROL
- if [ -d /data/srv/mysql/mythconverg ]
- #if [ -d /var/lib/mysql/mythconverg ]
- then
+# Before this script is called, the mysqld that facilitated the installation is killed.
+# We need to make sure to stop and start the mysqld that will be used post-install so
+# that the database can be initialized.
+
+/etc/rc.d/mysqld stop
+/etc/rc.d/mysqld stop
+/etc/rc.d/mysqld start
+
+# Put a limit on how many times we try to (re-)start MySQL
+success_test() {
+ # parameter: number of tries to start mysqld so far
+ PID=`pidof -o %PPID /usr/sbin/mysqld`
+ if [ -z "$PID" ]; then # mysqld isn't running
+ if [ $1 -gt 3 ]; then
+ echo "ERROR: Failed to start MySQL server in $1 attempts."
+ sleep 5
+ exit 1
+ else
+ echo "Tried $1 time(s) to start MySQL server."
+ return 1
+ fi
+ else # mysqld is running
+ return 0
+ fi
+ # should never get here
+ return 1
+}
+
+mysqld_tries=0
+# See if MySQL server is running; try several ways to start it if it's not.
+while true; do
+ success_test $mysqld_tries
+ if [ $? -eq 0 ]; then
+ echo "MySQL server is running"
+ break
+ else
+ echo "MySQL server is not running. Trying to start it."
+ # Maybe it just needs to be started
+ /etc/rc.d/mysqld start
+ mysqld_tries=$((mysqld_tries + 1))
+ success_test $mysqld_tries
+ if [ $? -eq 0 ]; then
+ echo "MySQL server has been started"
+ break
+ else
+ echo "MySQL server may not be installed. Trying to install it."
+ # Maybe it's not installed; try (re-)installing it and starting it
+ pacman --noconfirm -Sf mysql
+ /etc/rc.d/mysqld start
+ mysqld_tries=$((mysqld_tries + 1))
+ success_test $mysqld_tries
+ if [ $? -eq 0 ]; then
+ echo "MySQL server has been installed and started"
+ break
+ else
+ echo "MySQL server would not start, even after (re-)installing it."
+ fi
+ fi
+ fi
+done
+
+# At this point, MySQL server should be up and running
+
+while true; do
+ mysql -e "show databases;"
+
+ if [ $? -eq 0 ]; then
+ pacman --noconfirm -R mythdb-initial
+ pacman --noconfirm -S mythdb-initial
+ $MV_ROOT/bin/restore_default_settings.sh -c load
+ DISPLAY=127.0.0.1:0 $MV_ROOT/bin/MythVantage -t restore,default_1
+ $MV_ROOT/bin/restore_default_settings.sh -c restore -t syssettings
+ $MV_ROOT/bin/systemconfig.sh misc,hostype,this_is_install
+
+ update_db_settings HostServiceMythWEB "1"
+ echo 'UseMythWEB="1"' >> /etc/systemconfig
+
+ #update database to allow user jobs on this host.
+ $MV_ROOT/bin/restore_default_settings.sh -c USERJOBALLOW
+ $MV_ROOT/bin/restore_default_settings.sh -c ACCESSCONTROL
+ #if [ -d /var/lib/mysql/mythconverg ]
+ if [ -d /data/srv/mysql/mythconverg ]; then
# pacman --noconfirm -R webcalendar
# pacman --noconfirm --nodeps -S webcalendar
- status=0
- fi
+ break
+ else
+ echo "Failed to create mythconverg database. Will re-try."
+ sleep 1
+ fi
# if [ $SystemType = "Master_backend" ]
# then
# $MV_ROOT/bin/restore_default_settings.sh -c BECONFIG -s master -a $dbhost
# fi
- fi
+ else
+ echo "Failed to look for databases. Will re-try."
+ sleep 1
fi
done
/etc/rc.d/mysqld stop
#umount /proc
-
-
-