HEX
Server: Apache/2.4.65 (Debian)
System: Linux srv39710 6.1.0-41-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.158-1 (2025-11-09) x86_64
User: root (0)
PHP: 8.4.11
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,
Upload Files
File: /var/lib/dpkg/info/coremanager-pkg-mysql.postinst
#!/bin/bash
# postinst script for coremanager
#
# see: dh_installdeb(1)

#set -e

# summary of how this script can be called:
#        * <postinst> `configure' <most-recently-configured-version>
#        * <old-postinst> `abort-upgrade' <new version>
#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
#          <new-version>
#        * <postinst> `abort-remove'
#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
#          <failed-install-package> <version> `removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

COREDIR=/usr/local/mgr5
MGR=core
. ${COREDIR}/lib/pkgsh/core_pkg_funcs.sh 

if [ "${MYSQL_SERVICE}" = "mariadb" ]; then
	MYCNF=/etc/mysql/mariadb.conf.d/50-server.cnf
else
	MYCNF=/etc/mysql/mysql.conf.d/mysqld.cnf
fi

case "$1" in
    configure)
	if [ -z ${2} ]; then

		if [ "#${ISPCONVERT}" = "#yes" ]; then
			if [ -f ${COREDIR}/etc/common.conf ]; then
				if [ ! -f /root/.my.cnf ]; then
					PASS=$(sed -n -r '/section\s+name="mysql/,/\/section/{ /rootpassword/ s/\s*<\/*property(\sname="rootpassword")*>//gp }' ${COREDIR}/etc/common.conf)
					touch /root/.my.cnf
					chmod 0400 /root/.my.cnf
					echo "[client]" > /root/.my.cnf
					echo "user = root" >> /root/.my.cnf
					echo "password = ${PASS}" >> /root/.my.cnf
				fi
			fi
			ReloadMgr all
		else
			if [ "${MYSQL_SERVICE}" = "mysql" ]; then
				if [ -f /etc/mysql/my.cnf ] && [ -d /etc/mysql/mysql.conf.d ] && ! grep -qE '\!includedir /etc/mysql/mysql.conf.d/' /etc/mysql/my.cnf ; then
					echo '!includedir /etc/mysql/mysql.conf.d/' >> /etc/mysql/my.cnf
				fi
			fi
			# Fix #28109
			if ! check_mysql_param "innodb_file_per_table"; then
				add_mysql_param "$MYCNF" "mysqld" "innodb_file_per_table" "1"
			fi
			if ! check_mysql_param "log-error"; then
				add_mysql_param "$MYCNF" "mysqld" "log-error" "/var/log/mysql/mysql.log"
				if [ ! -d /var/log/mysql ]; then
					mkdir -p /var/log/mysql
					chown mysql:mysql /var/log/mysql
					chmod 750 /var/log/mysql
				fi
			fi

			# Fix #ISP-1299
			# libmariadb does not support caching_sha2_password password type. Fallback to native(for alt php)
			if [[ $(lsb_release -c -s) =~ focal|jammy|noble ]]; then
				if ! check_mysql_param "default-authentication-plugin" "mysql_native_password"; then
					sed -i -r '/\[mysqld\]/a default-authentication-plugin=mysql_native_password' ${MYCNF}
				fi
			fi

			# Fix #ISP6-767 Limit binlog to 7 days
			if ! check_mysql_param "binlog_expire_logs_seconds"; then
				MYSQLVER=$(/usr/sbin/mysqld -V 2>/dev/null | awk '{for(i=1;i<=NF;i++) if ($i ~ /[0-9]+\.[0-9]+\.[0-9]+/) print $i;}' | cut -d '-' -f1)
				if [ "${MYSQL_SERVICE}" = "mariadb" ]; then
					MIN_MYSQLVER="10.6"
					SECTION=mariadb
				else
					MIN_MYSQLVER="8.0"
					SECTION=mysqld
				fi
				if version_ge "${MYSQLVER}" "${MIN_MYSQLVER}" ; then
					add_mysql_param "$MYCNF" "$SECTION" "binlog_expire_logs_seconds" "604800"
				fi
			fi


			ReloadService ${MYSQL_SERVICE}
			ReloadMgr all
			# Afterinstall
			AfterinstallModule ${MGR} mysql
		fi
	fi
	if ! check_mysql_param "local-infile"; then
		add_mysql_param "$MYCNF" "mysqld" "local-infile" "0"
		ReloadService ${MYSQL_SERVICE}
	fi
	;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
    ;;
esac

# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.



exit 0