Просмотр исходного кода

Fix SpamAssassin service name for Ubuntu 24.04 (#5162)

* Fix SpamAssassin service name for Ubuntu 24.04

Ubuntu 24.04 renamed the SpamAssassin service from `spamassassin` to `spamd`, preventing Hestia from restarting it via the Web UI.

- Use `spamd` for Ubuntu 24.04+ in installer
- Add migration logic in upgrade script for existing installations
- Preserve `spamassassin` for older Ubuntu versions
sahsanu 3 месяцев назад
Родитель
Сommit
675f5b543d
2 измененных файлов с 17 добавлено и 1 удалено
  1. 6 1
      install/hst-install-ubuntu.sh
  2. 11 0
      install/upgrade/versions/1.9.5.sh

+ 6 - 1
install/hst-install-ubuntu.sh

@@ -1380,7 +1380,12 @@ if [ "$exim" = 'yes' ]; then
 		write_config_value "ANTIVIRUS_SYSTEM" "clamav-daemon"
 	fi
 	if [ "$spamd" = 'yes' ]; then
-		write_config_value "ANTISPAM_SYSTEM" "spamassassin"
+		release_short="$(cut -d '.' -f1 <<< "$release")"
+		if [[ -n "$release_short" ]] && [[ $release_short -lt 24 ]]; then
+			write_config_value "ANTISPAM_SYSTEM" "spamassassin"
+		else
+			write_config_value "ANTISPAM_SYSTEM" "spamd"
+		fi
 	fi
 	if [ "$dovecot" = 'yes' ]; then
 		write_config_value "IMAP_SYSTEM" "dovecot"

+ 11 - 0
install/upgrade/versions/1.9.5.sh

@@ -43,3 +43,14 @@ for netplan_file in /etc/netplan/*hestia*; do
 	echo "[ * ] Setting permissions on '$netplan_file' to 600"
 	chmod 600 "$netplan_file"
 done
+
+# Fix: Hestia can't restart SpamAssassin from the Web UI because it tries to restart
+# the 'spamassassin' service, but in Ubuntu 24.04 the service name is 'spamd'
+if [[ -n "$ANTISPAM_SYSTEM" ]]; then
+	installed_services="$(systemctl list-units --type=service 2>&1)"
+	if [[ $installed_services == *spamassassin.service* ]]; then
+		write_config_value "ANTISPAM_SYSTEM" "spamassassin"
+	elif [[ $installed_services == *spamd.service* ]]; then
+		write_config_value "ANTISPAM_SYSTEM" "spamd"
+	fi
+fi