mysql: Fix updating the package.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 26 Jan 2014 15:55:33 +0000 (16:55 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 26 Jan 2014 18:29:37 +0000 (19:29 +0100)
The mysql server daemon will now be stopped before the update
is executed and all configuration and data files will be
backed up.

config/backup/includes/mysql [new file with mode: 0644]
config/rootfiles/packages/mysql
lfs/mysql
src/paks/mysql/install.sh
src/paks/mysql/uninstall.sh
src/paks/mysql/update.sh

diff --git a/config/backup/includes/mysql b/config/backup/includes/mysql
new file mode 100644 (file)
index 0000000..bcb837c
--- /dev/null
@@ -0,0 +1,2 @@
+/etc/my.cnf
+/srv/mysql
index b03ee11c73ebbcecb278720905f25e35e773e50c..0beaca8bd0a58d1b67b67846c72ccf3963fc0354 100644 (file)
@@ -299,4 +299,5 @@ usr/share/mysql
 #usr/share/mysql/swedish/errmsg.sys
 #usr/share/mysql/ukrainian
 #usr/share/mysql/ukrainian/errmsg.sys
+var/ipfire/backup/addons/includes/mysql
 var/run/mysql
index aa5c3579f05e6258d92f56d00e4c453e154068a8..edcd651f8904946739f3a339dd49b115d98c35cd 100644 (file)
--- a/lfs/mysql
+++ b/lfs/mysql
@@ -100,5 +100,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
        chgrp -v mysql /srv/mysql{,/test,/mysql}
        chown mysql.mysql /srv/mysql/
        install -v -m755 -o mysql -g mysql -d /var/run/mysql
+       install -v -m 644 $(DIR_SRC)/config/backup/includes/mysql \
+               /var/ipfire/backup/addons/includes/mysql
        @rm -rf $(DIR_APP)
        @$(POSTBUILD)
index 20a9924caa5170ac860fcc27b1dc79989f8d4a1d..a27d09ed6130782f77f27cd1e11164b461112d16 100644 (file)
 ############################################################################
 #
 . /opt/pakfire/lib/functions.sh
+
 extract_files
+
 ln -svf  ../init.d/mysql /etc/rc.d/rc0.d/K26mysql
 ln -svf  ../init.d/mysql /etc/rc.d/rc3.d/S34mysql
 ln -svf  ../init.d/mysql /etc/rc.d/rc6.d/K26mysql
-/etc/init.d/mysql start
+
+restore_backup "${NAME}"
+
+start_service "${NAME}"
+
 COUNTER=0
 while [ "$COUNTER" -lt "10" ]; do
        [ -e "/var/run/mysql/mysql.sock" ] && break
@@ -34,6 +40,8 @@ while [ "$COUNTER" -lt "10" ]; do
        sleep 5
        COUNTER=$(($COUNTER + 1))
 done 
+
 [ -e "/var/run/mysql/mysql.sock" ] || (echo "MySQL still noch running... Exiting."; \
        exit 1)
+
 mysqladmin -u root --password='' password 'mysqlfire'
index ed4ff02e82ee58a4031471104c360f4c3d0e14f6..a312b2e18eba15ce493bd5bdb753a1b78998787d 100644 (file)
 ############################################################################
 #
 . /opt/pakfire/lib/functions.sh
+
+# Stop the mysql service
+stop_service "${NAME}"
+
+# Make backup
+make_backup "${NAME}"
+
 remove_files
+
+# Remove start links.
 rm -rvf /etc/rc.d/rc*.d/*mysql
index 89c40d0d7c5d3dd57b5944f3af4977d5f8d76760..548b9dbd3b50244d0a112450d75d33639e757634 100644 (file)
 ############################################################################
 #
 . /opt/pakfire/lib/functions.sh
-./uninstall.sh
-./install.sh
+
+# Create backup include file if it is missing.
+if [ ! -e "/var/ipfire/backup/addons/includes/mysql" ]; then
+       cat <<EOF > /var/ipfire/backup/addons/includes/mysql
+/etc/my.cnf
+/srv/mysql
+EOF
+fi
+
+# Stop the mysql service
+stop_service "${NAME}"
+
+# Make backup
+make_backup "${NAME}"
+
+# Update files
+remove_files
+extract_files
+
+# Restore backup
+restore_backup "${NAME}"
+
+# Restart the service
+start_service "${NAME}"
+
+exit 0