diff --git a/install_mysql-5.7.sh b/install_mysql-5.7.sh index d74ae8d..73e75f9 100755 --- a/install_mysql-5.7.sh +++ b/install_mysql-5.7.sh @@ -591,7 +591,7 @@ echo "" ## - if [ -d $logdir ]; then echononl "Verschiebe exitierendes Logverzeichnis ..." - mv ${logdir $logdir}.$_backup_date + mv "$logdir" "${logdir}.$_backup_date" if [ "$?" = "0" ]; then echo_ok else @@ -1292,21 +1292,23 @@ if $SYMLINK_INITSCRIPT ; then fi -echononl "Füge `dirname $MYSQL_INSTALL_DIR`/mysql/bin zur PATH Variable hinzu .." +_checkdir="$(dirname "$MYSQL_INSTALL_DIR")/mysql/bin" +echononl "Füge '$_checkdir' zur PATH Variable hinzu .." if [ -f /etc/profile ]; then - _mysql_bin_dir="`dirname $MYSQL_INSTALL_DIR`/mysql/bin" - if ! grep -e "PATH=.*$_mysql_bin_dir" /etc/profile > /dev/null 2<&1 ; then + if ! grep -e "$_checkdir" /etc/profile > /dev/null 2<&1 ; then echo "" >> ${logdir}/main.log - echo "perl -i -n -p -e \"s#^([ ]*export[ ]*PATH.*$)#check_dir=\$_mysql_bin_dir\nif [ -d \\\"\\\\\\\$check_dir\\\" ];then\n PATH=\\\\\\\${check_dir}:\\\\\\\$PATH\nfi\n\n\1#\" /etc/profile" >> ${logdir}/main.log 2<&1 - perl -i -n -p -e "s#^([ ]*export[ ]*PATH.*$)#check_dir=$_mysql_bin_dir\nif [ -d \"\\\$check_dir\" ];then\n PATH=\\\${check_dir}:\\\$PATH\nfi\n\n\1#" /etc/profile >> ${logdir}/main.log 2<&1 + echo "perl -i -n -p -e \"s#^([ ]*export[ ]*PATH.*$)#check_dir=\$_checkdir\nif [ -d \\\"\\\\\\\$check_dir\\\" ];then\n PATH=\\\\\\\${check_dir}:\\\\\\\$PATH\nfi\n\n\1#\" /etc/profile" >> ${logdir}/main.log 2<&1 + + perl -i -n -p -e "s#^([ ]*export[ ]*PATH.*$)#check_dir=$_checkdir\nif [ -d \"\\\$check_dir\" ];then\n PATH=\\\${check_dir}:\\\$PATH\nfi\n\n\1#" /etc/profile >> ${logdir}/main.log 2<&1 + if [ "$?" = "0" ]; then echo_ok else echo_failed fi - if ! echo "$PATH" | grep $_mysql_bin_dir >> ${logdir}/main.log 2>&1 ; then - export PATH=${_mysql_bin_dir}:$PATH + if ! echo "$PATH" | grep $_checkdir >> ${logdir}/main.log 2>&1 ; then + export PATH=${_checkdir}:$PATH fi else @@ -1438,9 +1440,11 @@ _new_cnf_needed=false if $UPDATE_MYSQL ; then echononl "Copy 'my.cnf from old installation to the new one.." echo "" >> ${logdir}/main.log - echo "cp -a \"$(realpath ${MYSQL_CUR_INSTALL_DIR}/my.cnf)\" \"${MYSQL_INSTALL_DIR}/my.cnf\"" >> ${logdir}/main.log - if [[ -f "${MYSQL_CUR_INSTALL_DIR}/my.cnf" ]] ; then - cp -a "$(realpath ${MYSQL_CUR_INSTALL_DIR}/my.cnf)" "${MYSQL_INSTALL_DIR}/my.cnf" >> ${logdir}/main.log + if [[ "$CURRENT_VERSION" = "$MYSQL_VERSION" ]] ; then + echo "cp -a \"$(realpath ${MYSQL_CUR_INSTALL_DIR}).${_backup_date}/my.cnf\" \"${MYSQL_INSTALL_DIR}/my.cnf\"" \ + >> ${logdir}/main.log + cp -a "$(realpath ${MYSQL_CUR_INSTALL_DIR}).${_backup_date}/my.cnf" "${MYSQL_INSTALL_DIR}/my.cnf" \ + >> ${logdir}/main.log 2>&1 if [ "$?" = "0" ]; then echo_ok else @@ -1449,7 +1453,20 @@ if $UPDATE_MYSQL ; then error "Konnte Konfigurationsdatei 'my.cnf' nicht vom alten in das neue Installations Verz.kopieren.." fi else - echo_skipped + echo "cp -a \"$(realpath ${MYSQL_CUR_INSTALL_DIR})/my.cnf\" \"${MYSQL_INSTALL_DIR}/my.cnf\"" \ + >> ${logdir}/main.log + cp -a "$(realpath ${MYSQL_CUR_INSTALL_DIR}/)my.cnf" "${MYSQL_INSTALL_DIR}/my.cnf" \ + >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + _new_cnf_needed=true + error "Konnte Konfigurationsdatei 'my.cnf' nicht vom alten in das neue Installations Verz.kopieren.." + fi + fi + + if [[ ! -f "${MYSQL_INSTALL_DIR}/my.cnf" ]] ; then _new_cnf_needed=true fi fi @@ -2394,6 +2411,8 @@ else error Konnte MySQL Datenbankserver nicht starten.. fi +sleep 2 + if ! $UPDATE_MYSQL ; then ## - Delete rows with empty 'User' from table mysql.user @@ -2456,11 +2475,11 @@ _sys_maint_cnf_needed=false if $UPDATE_MYSQL ; then echononl "Copy 'sys-maint.cnf from old installation to the new one.." echo "" >> ${logdir}/main.log - echo "cp -a \"$(realpath ${MYSQL_CUR_INSTALL_DIR}/sys-maint.cnf)\" \"${MYSQL_INSTALL_DIR}/sys-maint.cnf\"" \ - >> ${logdir}/main.log - if [[ -f "${MYSQL_CUR_INSTALL_DIR}/sys-maint.cnf" ]] ; then - cp -a "$(realpath ${MYSQL_CUR_INSTALL_DIR}/sys-maint.cnf)" "${MYSQL_INSTALL_DIR}/sys-maint.cnf" \ + if [[ "$CURRENT_VERSION" = "$MYSQL_VERSION" ]] ; then + echo "cp -a \"$MYSQL_INSTALL_DIR.$_backup_date/sys-maint.cnf\" \"${MYSQL_INSTALL_DIR}/sys-maint.cnf\"" \ >> ${logdir}/main.log + cp -a $MYSQL_INSTALL_DIR.$_backup_date/sys-maint.cnf "${MYSQL_INSTALL_DIR}/sys-maint.cnf" \ + >> ${logdir}/main.log 2>&1 if [ "$?" = "0" ]; then echo_ok else @@ -2469,6 +2488,20 @@ if $UPDATE_MYSQL ; then error "Konnte Konfigurationsdatei 'sys-maint.cnf' nicht vom alten in das neue Installations Verz.kopieren.." fi else + echo "cp -a \"$(realpath ${MYSQL_CUR_INSTALL_DIR}/sys-maint.cnf)\" \"${MYSQL_INSTALL_DIR}/sys-maint.cnf\"" \ + >> ${logdir}/main.log + cp -a "$(realpath ${MYSQL_CUR_INSTALL_DIR}/sys-maint.cnf)" "${MYSQL_INSTALL_DIR}/sys-maint.cnf" \ + >> ${logdir}/main.log 2>&1 + if [ "$?" = "0" ]; then + echo_ok + else + echo_failed + _sys_maint_cnf_needed=true + error "Konnte Konfigurationsdatei 'sys-maint.cnf' nicht vom alten in das neue Installations Verz.kopieren.." + fi + fi + + if [[ ! -f "${MYSQL_INSTALL_DIR}/sys-maint.cnf" ]] ; then _sys_maint_cnf_needed=true fi fi