install_postfixadmin.sh: add support for versions 4.x

This commit is contained in:
2026-02-04 21:08:22 +01:00
parent 7163b2dccf
commit e82b464115

View File

@@ -187,10 +187,9 @@ detect_mysql_version () {
# -
systemd_supported=false
systemd=$(which systemd)
systemctl=$(which systemctl)
if [[ -n "$systemd" ]] && [[ -n "$systemctl" ]] ; then
if [[ -n "$systemctl" ]] ; then
systemd_supported=true
fi
@@ -256,6 +255,14 @@ do
echo -e "\n\t\033[33m\033[1mA version number is required!\033[m\n"
fi
done
IFS='.' read -r PF_ADMIN_MAJOR_VERSION PF_ADMIN_MINOR_VERSION PF_ADMIN_PATCH_LEVEL <<< "$PF_ADMIN_VERSION"
#echo ""
#echo "PF_ADMIN_MAJOR_VERSION: $PF_ADMIN_MAJOR_VERSION"
#echo "PF_ADMIN_MINOR_VERSION: $PF_ADMIN_MINOR_VERSION"
#echo "PF_ADMIN_PATCH_LEVEL: $PF_ADMIN_PATCH_LEVEL"
#exit
echo ""
echo -e "\033[32m--\033[m"
echo ""
@@ -275,6 +282,9 @@ DEFAULT_APACHE_SERVER_CERT="server-bundle.crt"
DEFAULT_APACHE_SERVER_KEY="server.key"
DEFAULT_DEBIAN_APACHE_VHOST_DIR="/etc/apache2/sites-available"
DEFAULT_APACHE_VHOST_DIR="/usr/local/apache2/conf/vhosts"
DEFAULT_COMPOSER="/usr/local/bin/composer"
DEFAULT_POSTFIX_DB_HOST_PGSQL="/run/postgresql"
if [[ -S "/tmp/mysql.sock" ]] ; then
DEFAULT_POSTFIX_DB_HOST_MYSQL="unix:/tmp/mysql.sock"
@@ -379,6 +389,8 @@ if [[ -z "$APACHE_VHOST_DIR" ]] ; then
fi
fi
[[ -n "${COMPOSER}" ]] || COMPOSER=${DEFAULT_COMPOSER}
[[ -n "$POSTFIX_DB_TYPE" ]] || fatal "Database Type of Postfix Database (POSTFIX_DB_TYPE) not present!"
[[ -n "$POSTFIX_DB_HOST_MYSQL" ]] || POSTFIX_DB_HOST_MYSQL="$DEFAULT_POSTFIX_DB_HOST_MYSQL"
[[ -n "$POSTFIX_DB_HOST_PGSQL" ]] ||POSTFIX_DB_HOST_PGSQL="$DEFAULT_POSTFIX_DB_HOST_PGSQL"
@@ -931,6 +943,64 @@ else
fi
echo -e "\n\n\t\033[37m\033[1mInstall (global) composer..\033[m\n"
echononl "\tDownload composer from 'getcomposer.org'.."
php -r "copy('https://getcomposer.org/installer', '${_src_base_dir}/composer-setup.php');" > $log_file 2>&1
if [[ "$?" = "0" ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
echononl "\tcontinue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Script terminated by user input.."
fi
echononl "\tInstall composer to ${COMPOSER}"
php ${_src_base_dir}/composer-setup.php --install-dir=$(dirname ${COMPOSER}) \
--filename=$(basename ${COMPOSER}) > $log_file 2>&1
if [[ "$?" = "0" ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
echononl "\tcontinue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Script terminated by user input.."
fi
echononl "\tRemove the installer"
php -r "unlink('${_src_base_dir}/composer-setup.php');" > $log_file 2>&1
if [[ "$?" = "0" ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
echononl "\tcontinue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Script terminated by user input.."
fi
echo -e "\n\n\t\033[37m\033[1mBase install Postfixadmin..\033[m\n"
@@ -1102,6 +1172,37 @@ else
echo_ok
fi
echononl "\tInstall PHP dependencies ( composer install --no-dev ... ).."
if [[ ${PF_ADMIN_MAJOR_VERSION} -gt 3 ]] ; then
if $PHP_DEBIAN_INSTALLATION ; then
su ${HTTP_USER} -c"cd ${WEBSITE_BASEDIR}/postfixadmin-${PF_ADMIN_VERSION}
php /usr/local/bin/composer install --prefer-dist --no-interaction --no-dev" -s /bin/bash \
> $log_file 2>&1
else
su ${HTTP_USER} -c"cd ${WEBSITE_BASEDIR}/postfixadmin-${PF_ADMIN_VERSION}
/usr/local/php-${php_latest_ver}/bin/php /usr/local/bin/composer --prefer-dist \
--no-interaction install --no-dev" -s /bin/bash > $log_file 2>&1
fi
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
echononl "\tcontinue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Script terminated by user input.."
fi
else
echo_skipped
fi
echononl "\tRemove existing symlink '${WEBSITE_BASEDIR}/htdocs'"
if [[ -h "${WEBSITE_BASEDIR}/htdocs" ]]; then
@@ -3496,6 +3597,26 @@ else
error "$(cat $log_file)"
fi
echononl "\tRestart Apache Webservice.."
if [[ -n "$APACHE_SERVICE_FILE" ]] || [[ -n "$APACHE_INIT_SCRIPT" ]] ; then
if [[ -n "$APACHE_SERVICE_FILE" ]] ; then
systemctl restart $APACHE_SERVICE_FILE > $log_file 2>&1
else
$APACHE_INIT_SCRIPT restart > $log_file 2>&1
fi
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
warn "Neither an init-script nor a service file for 'apache2' webservice found!"
fi
# - Start all PHP FPM engines
# -
if [[ -n "$php_major_versions" ]]; then
@@ -3543,7 +3664,7 @@ fi
echo ""
info "Browse to \033[1mhttp://${WEBSITE_NAME}/setup.php\033[m to create a 'setup password'\n$(cat <<EOF
info "Browse to \033[1mhttps://${WEBSITE_NAME}/setup.php\033[m to create a 'setup password'\n$(cat <<EOF
\t \033[33mIn caes of updating postfix.admin browse this URL and \033[1mlogin with your
\t setup_password\033[m\033[33m, because only after that the database '${POSTFIX_DB_NAME}'